Can I save register values inside of ISR code?

120 Views Asked by At

I am new to OS interrupts and wondering why do we need to save all the register values before going into ISR? Can we write the code to save register values inside of ISR code so that the register values can just get pushed to the stack by ISR's own code?

1

There are 1 best solutions below

0
AlanCui On

Answer is clear,it will be to complex to add a part of code to save context before every ISR and restore it.It's easy to reuse every code by macro.Surely,when you write a ISR,you'd rather use C than ASM.But when you using a C code,every action expected depends on your complier, it means that C code will do more than you write.