Download ST7 USER GUIDE
Transcript
4 - Architecture of the ST7 core 0 1 4 0 h T o p o f th e s ta c k 6 4 b y te s o f R A M 0 1 7 F h B o tto m o f th e s ta c k ( R e s e t v a lu e ) S ta c k o r g a n iz a tio n o f th e S T 7 2 2 5 1 04-stack When a value is stored using the stack pointer, the stack is decremented, so that the next value stored will be placed at the address just below the previous one. This process of storing and decrementing the pointer is called Pushing, and can be done either by a PUSH instruction or by a CALL instruction that pushes the return address. When the data is read back from the stack, the SP is incremented so that the next data retrieved will be the one situated at the address above the previous value retrieved. This is called popping the data, and can be done using the POP instruction or the RET instruction that pops one address off the stack and jumps to that address. If several addresses are stored successively because several CALLs were executed successively, the first RET instruction will pop the last address pushed, the second RET will pop the one-but-last address, and so on. This feature provides for the nesting of subroutines, where the last called is the first exited. Interrupts, being a kind of subroutine call, also use the stack to store the context of the interrupted process. Since interrupts occur at unexpected times, all the core registers must be saved on entering the interrupt service routine. This is performed automatically by the interrupt mechanism that pushes in order PC, X, A and CC. The return from interrupt must thus use a different instruction from the return from subroutine, where only the PC was saved. The instruction IRET is supplied for this purpose, and restores the initial values of these registers. It should be noted that the Y index register is not saved automatically. The industry-standard 69/315