Hello --- I just signed up here --- I'm a complete newbie in regards to AVR assembly-language. The following questions may seem simple, but I couldn't find them in the documentation that came with Atmel Studio --- most likely I just haven't found adequate documentation yet, so some links might be the best response.
1.) I read that an ISR doesn't have the status-register (SREG) saved for it, and that this is the programmer's responsibility. How do I do that? On the 6502 we had the PHP and PLP instructions, but there seems to be nothing like this in the AVR. I assume that SREG is memory mapped somewhere (maybe all of the registers), similar to on the 8032. Is there a map of this stuff? I'm guessing that this is the lower 128 bytes, as I noticed that we have fast versions of LDS and STS for that region.
2.) How big is the stack? I found the PUSH and POP instructions, but there is no indication as to where the stack is or how big it is. Does this vary from chip to chip? I want to know if it is a good idea to push data here for temporary storage, or if this is likely to cause a stack overflow. Is it possible to store the return-stack pointer into Y or Z and access the data on the return-stack with indirect-with-displacement addressing? Pushing and popping upwards of 32 registers seems rather time-consuming --- is there no way to save the machine state more quickly?
I'm writing a Forth cross-compiler --- I want to be able to write ISRs in Forth, which is why I'm asking these questions about how ISRs work. Later on I may delve into writing an RTOS --- in any case, task-switching on the AVR seems to be pretty cumbersome, compared to the 6502 --- but maybe I just haven't found the correct documentation yet.
thanks in advance --- Hugh