Additional corrections to state restore logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@466 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
d4e294e617
commit
6978a7091b
@ -70,13 +70,13 @@
|
||||
*/
|
||||
|
||||
#define XCPT_I (0) /* Offset 0: Saved I w/interrupt state in carry */
|
||||
#define XCPT_AF (1) /* Offset 1: Saved AF register */
|
||||
#define XCPT_BC (2) /* Offset 2: Saved BC register */
|
||||
#define XCPT_DE (3) /* Offset 3: Saved DE register */
|
||||
#define XCPT_HL (4) /* Offset 4: Saved HL register */
|
||||
#define XCPT_IX (5) /* Offset 5: Saved IX register */
|
||||
#define XCPT_IY (6) /* Offset 6: Saved IY register */
|
||||
#define XCPT_SP (7) /* Offset 7: Offset to SP at time of interrupt */
|
||||
#define XCPT_BC (1) /* Offset 1: Saved BC register */
|
||||
#define XCPT_DE (2) /* Offset 2: Saved DE register */
|
||||
#define XCPT_IX (3) /* Offset 3: Saved IX register */
|
||||
#define XCPT_IY (4) /* Offset 4: Saved IY register */
|
||||
#define XCPT_SP (5) /* Offset 5: Offset to SP at time of interrupt */
|
||||
#define XCPT_HL (6) /* Offset 6: Saved HL register */
|
||||
#define XCPT_AF (7) /* Offset 7: Saved AF register */
|
||||
#define XCPT_PC (8) /* Offset 8: Offset to PC at time of interrupt */
|
||||
|
||||
#define XCPTCONTEXT_REGS (9)
|
||||
|
@ -49,7 +49,6 @@
|
||||
; up_restoreusercontext
|
||||
;**************************************************************************
|
||||
|
||||
; .area _CODE (ABS,OVR)
|
||||
_up_restoreusercontext:
|
||||
; On entry, stack contains return address (not used), then address
|
||||
; of the register save structure
|
||||
@ -79,9 +78,7 @@ _up_restoreusercontext:
|
||||
pop ix ; Offset 3: IX
|
||||
pop iy ; Offset 4: IY
|
||||
exx ; Use alternate BC/DE/HL
|
||||
ld hl, #-2 ; Offset of SP to account for ret addr on stack
|
||||
pop de ; Offset 5: HL' = Stack pointer after return
|
||||
add hl, de ; HL = Stack pointer value before return
|
||||
pop hl ; Offset 5: HL' = Stack pointer after return
|
||||
exx ; Restore original BC/DE/HL
|
||||
pop hl ; Offset 6: HL
|
||||
pop af ; Offset 7: AF
|
||||
@ -89,7 +86,9 @@ _up_restoreusercontext:
|
||||
; Restore the stack pointer
|
||||
|
||||
exx ; Use alternate BC/DE/HL
|
||||
pop de ; DE' = return address
|
||||
ld sp, hl ; Set SP = saved stack pointer value before return
|
||||
push de ; Save return address for ret instruction
|
||||
exx ; Restore original BC/DE/HL
|
||||
|
||||
; Restore interrupt state
|
||||
@ -97,8 +96,8 @@ _up_restoreusercontext:
|
||||
ex af, af' ; Recover interrupt state
|
||||
jr nc, noinrestore ; No carry, IFF2=0, means disabled
|
||||
ex af, af' ; Restore AF (before enabling interrupts)
|
||||
ei ; yes
|
||||
ret
|
||||
ei ; yes.. Enable interrupts
|
||||
ret ; and return
|
||||
noinrestore:
|
||||
ex af, af' ; Restore AF
|
||||
ret
|
||||
ret ; Return with interrupts disabled
|
||||
|
Loading…
Reference in New Issue
Block a user