This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with Reentrant Function's Argument List

I have a reentrant function as shown below...

void Move(char X, char Sen, char Flag_Case) reentrant
{
	while(1)
	{
		if(Flag_Case == 1)
		{
			switch(X)
			{ .... 

I am calling the function Move() from Main()as shown below...

void main()
{
	TMOD = 0X01;
	IE = 0X82;
        while(1)
	{
		Move(4,5,6);
	}

But when i read, the variables, X, Sen and Flag_Case inside the reentrant function Move(), all the three variables show up '0'. Why is this happening? And what changes do i need to do?

Thanks in advance.

Avinash

  • Solution found. I had to modify the STARTUP.A51 to initialise the stack pointer for the reentrant function Move(). so id did the following changes in the STARTUP.A51 file, which i copied to my project directory and included it in my project...

    ;  Stack Space for reentrant functions in the SMALL model.
    IBPSTACK        EQU     1       ; set to 1 if small reentrant is used.
    IBPSTACKTOP     EQU     40H+1  ; set top of stack to highest location+1.
    ;

    As you can see above, i have initialised the stack pointer to 41H in SMALL model.

    Now, i have two more reentrant functions in my program and both are in SMALL model, like the Move() function is. So how do i initialise the stack pointer for those reentrant functions????

    Avinash

  • how do i initialise the stack pointer for those reentrant functions????

    You should not need to. The functions using a particular memory model share the appropriate simulated stack - e.g. all SMALL memory model functions share the simulated stack in idata.

  • Ok, now i get it. Thanks Franck.