Link to home
Start Free TrialLog in
Avatar of smediodia
smediodia

asked on

Stack System (Turbo C memory model : Small)

I try to know the number of arguments i receive in a function. The declaration of this is PCB fork(void (*function)(), ... ) and when im calling it I write running=fork(DrawBox,colour).

The probles is about the pointers SP and BP, because when I call the function , the pointer SP moves and I cant know where are the arguments in the stack system.

If i could know the number of arguments im sending, I could move SP to the begging when Im inside the function.

Thank you in advanced... :)
Avatar of smediodia
smediodia

ASKER

Adjusted points to 100
ASKER CERTIFIED SOLUTION
Avatar of Slarti
Slarti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thats one of the ideas I got, but I cant use it, because I have
the prototype of the function and I cant change it.
Another solution I thought is to add a new global variable which
contains the SP-BP. Thats the number of reserved memory I got in
main() for local variables. Then , when im in the fork() sub sp-2
(oh add sp+2) and I know the BP in main function and then add sp
the value of the global variable i declareted. Then I control the
return address in the stack and I got the arguments.
But , thanks Slarti.