Link to home
Start Free TrialLog in
Avatar of ravipal
ravipal

asked on

Switching Stacks

Inside a Interrupt Service Routine, I need to change the presently running program's Stack to the ISR's Stack. I have two questions.

1. What is the Code for this in Microsoft C? or can I use     inline assembly?
2. How do I determine where to put the Stack Pointer? i.e     how do I determine the amount of stack used?
Avatar of viktornet
viktornet
Flag of United States of America image

to do this you need to use assembler....

for C/C++ the inline asm is like this..

{
  //Code
  asm {
  //asm code goes here,,
  }
}

SP(Stack Pointer) is the assembler register....
ASKER CERTIFIED SOLUTION
Avatar of bculver
bculver

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
Avatar of ravipal
ravipal

ASKER

Thanks bculver, I need few clarifications on your code.

The 1024 you put in the char stack array, Is is a assumed figure ? or is that a fixed figure??

Why do you put 1024-2 to get ptr to the top of the stack?, is it not 1024-1?

What is the reason behind moving values to AX before moving them to SP and SS respectively?

Would appreciate your clarifications very much.