X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fhw%2Fswitch_ctx_avr.S;h=cb10b5f81ab3640bf589ce064d59bf01837393b6;hb=32d1445272120a254d77ce8d1af1f527da7a2c17;hp=50280292ad7a2e90f73aabc4b8f557a380071bc2;hpb=fe0a14d1434098bfd0780d06a2a7e55f27940d27;p=bertos.git diff --git a/bertos/cpu/avr/hw/switch_ctx_avr.S b/bertos/cpu/avr/hw/switch_ctx_avr.S index 50280292..cb10b5f8 100644 --- a/bertos/cpu/avr/hw/switch_ctx_avr.S +++ b/bertos/cpu/avr/hw/switch_ctx_avr.S @@ -47,12 +47,9 @@ asm_switch_context: ; r0 is the TEMP REG and can be used freely. ; r1 is the ZERO REG and must always contain 0. ; -; Stack frame is 19 byte, remember to update +; Stack frame is 18 byte, remember to update ; CPU_SAVED_REGS_CNT if you change pushed regs. - in r0,SREG-__SFR_OFFSET - push r0 -; push r1 ;zero-reg push r2 push r3 push r4 @@ -69,20 +66,9 @@ asm_switch_context: push r15 push r16 push r17 -; push r18 ;caller-save -; push r19 ;caller-save -; push r20 ;caller-save -; push r21 ;caller-save -; push r22 ;caller-save -; push r23 ;caller-save -; push r24 ;caller-save -; push r25 ;caller-save -; push r26 ;caller-save -; push r27 ;caller-save + push r28 push r29 -; push r30 ;caller-save -; push r31 ;caller-save in r18,SPL-__SFR_OFFSET ; r18:r19 = SP in r19,SPH-__SFR_OFFSET @@ -100,25 +86,15 @@ asm_switch_context: ; Two instructions are required to update SP ; so an IRQ can sneak in between them. ; So IRQ *MUST* be disabled and then restored. + in r0, SREG-__SFR_OFFSET cli ; Disable interrupt out SPL-__SFR_OFFSET,r18 ; SP = *new_sp out SPH-__SFR_OFFSET,r19 out SREG-__SFR_OFFSET,r0 ; Restore previous IRQ state -; pop r31 ;caller-save -; pop r30 ;caller-save pop r29 pop r28 -; pop r27 ;caller-save -; pop r26 ;caller-save -; pop r25 ;caller-save -; pop r24 ;caller-save -; pop r23 ;caller-save -; pop r22 ;caller-save -; pop r21 ;caller-save -; pop r20 ;caller-save -; pop r19 ;caller-save -; pop r18 ;caller-save + pop r17 pop r16 pop r15 @@ -135,8 +111,5 @@ asm_switch_context: pop r4 pop r3 pop r2 -; pop r1 ;zero-reg - pop r0 - out SREG-__SFR_OFFSET,r0 ret