Skip to content

Instantly share code, notes, and snippets.

@siritori
Created July 23, 2010 18:32
Show Gist options
  • Save siritori/487845 to your computer and use it in GitHub Desktop.
Save siritori/487845 to your computer and use it in GitHub Desktop.
.h8300sx
.section .text
.global _switch_without_restore
.global _switch_with_restore
; void switch_without_restore(char *cur_sp, char *next_sp, function entry);
_switch_without_restore:
mov.l er6,@-er7
mov.l er7,er6
mov.l er0,@-er7 ; save general registers
mov.l er1,@-er7
mov.l er2,@-er7
mov.l er3,@-er7
mov.l er4,@-er7
mov.l er5,@-er7
mov.l er6,@-er7
mov.l er7,@er0 ; save SP
mov.l er1,er7 ; switch SP
jmp @er2 ; jump!
; void switch_without_restore(char *cur_sp, char *next_sp);
_switch_with_restore:
mov.l er6,@-er7
mov.l er7,er6
mov.l er0,@-er7 ; save general registers
mov.l er1,@-er7
mov.l er2,@-er7
mov.l er3,@-er7
mov.l er4,@-er7
mov.l er5,@-er7
mov.l er6,@-er7
mov.l er7,@er0 ; save SP
mov.l er1,er7 ; switch SP
mov.l @er7+,er6 ; restore general registers
mov.l @er7+,er5
mov.l @er7+,er4
mov.l @er7+,er3
mov.l @er7+,er2
mov.l @er7+,er1
mov.l @er7+,er0
rts/l er6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment