Hello, I'm having trouble understanding the NOAREG, AREG & USING options. I'm also confused with R0-R7 & AR0-AR7. I've read the support files and manual but i'm still confused. May I know a) How is it that using NOAREGs will allow me to disregard register bank currently used when writing function? ( will the registers be automatically saved to stack? ) b) What is the difference with R0 and AR0? How does the USING option affect R0 & AR0? (for example if i put the option "USING 2", have then use R4, does this mean that it is the actually R20 ie in bank 2, whiel AR4 is not affected by the using function) c) How does USING help me to save stack space? Best Regards, AL
Dear Andrew Neil, May I know where the PC value saved to? and is it possible to have direct access to PC value in your program? Regards, KC
No sorry, there is no way to address the PC (except for using a CALL instruction to a sub-routine that retrieves the return address from stack).
1) May I know where the PC value saved to? 2) and is it possible to have direct access to PC value in your program? 1) by hardware 2) why? Erik
The chip hardware pushes the PC to the stack. This is the only register saved by the hardware. All other regs are pushed by sofware. The PC is popped from the stack via the RET/RETI. The interrupt keyword in Keil C51 will create code to push all Regs needed to the stack and in reverse pop all stacked reg on exit or return. The using keyword creates code to do a context switch as Andy's code points out. As was pointed out, the best use of this keyword is for a fast context switch in an interrupt routine. Any time an interrupt uses more than 3 regs then a context switch is faster than the push/pop effort.