1 1.1 christos # You'll find a bunch of nop opcodes in the below macros. They are 2 1.1 christos # there to keep the code correctly aligned. Be careful to maintain 3 1.1 christos # them when changing the code. 4 1.1 christos 5 1.1 christos comment "subroutine declare" 6 1.1 christos .purgem gdbasm_declare 7 1.1 christos .macro gdbasm_declare name 8 1.1 christos .align 1 9 1.1 christos .global \name 10 1.1 christos \name: 11 1.1 christos .endm 12 1.1 christos 13 1.1 christos comment "subroutine prologue" 14 1.1 christos .macro gdbasm_enter 15 1.1 christos mov.l r14,@-r15 16 1.1 christos sts.l pr,@-r15 17 1.1 christos mov r15,r14 18 1.1 christos nop 19 1.1 christos .endm 20 1.1 christos 21 1.1 christos comment "subroutine epilogue" 22 1.1 christos .macro gdbasm_leave 23 1.1 christos mov r14,r15 24 1.1 christos lds.l @r15+,pr 25 1.1 christos mov.l @r15+,r14 26 1.1 christos rts 27 1.1 christos nop 28 1.1 christos nop 29 1.1 christos .endm 30 1.1 christos 31 1.1 christos comment "subroutine end" 32 1.1 christos .purgem gdbasm_end 33 1.1 christos .macro gdbasm_end name 34 1.1 christos .size \name, . - \name 35 1.1 christos .align 1 36 1.1 christos .endm 37 1.1 christos 38 1.1 christos comment "subroutine call" 39 1.1 christos .macro gdbasm_call subr 40 1.1 christos mov.l .Lconst\@,r1 41 1.1 christos bra .Lafterconst\@ 42 1.1 christos nop 43 1.1 christos nop 44 1.1 christos .Lconst\@: 45 1.1 christos .align 2 46 1.1 christos .long \subr 47 1.1 christos .align 1 48 1.1 christos .Lafterconst\@: 49 1.1 christos jsr @r1 50 1.1 christos nop 51 1.1 christos .endm 52 1.1 christos 53 1.1 christos .macro gdbasm_several_nops 54 1.1 christos nop 55 1.1 christos nop 56 1.1 christos nop 57 1.1 christos nop 58 1.1 christos .endm 59 1.1 christos 60 1.1 christos comment "exit (0)" 61 1.1 christos .macro gdbasm_exit0 62 1.1 christos sleep 63 1.1 christos nop 64 1.1 christos .endm 65 1.1 christos 66 1.1 christos comment "crt0 startup" 67 1.1 christos .macro gdbasm_startup 68 1.1 christos comment "If there is a _stack symbol, use it for setting up the stack" 69 1.1 christos comment "pointer. In hosted mode (when there is no _stack symbol)," 70 1.1 christos comment "the operating system will have initialized it already." 71 1.1 christos mov.l .stackaddr, r0 72 1.1 christos tst r0, r0 73 1.1 christos bt .afterstackaddr 74 1.1 christos mov r0, r15 75 1.1 christos bra .afterstackaddr 76 1.1 christos nop 77 1.1 christos .align 2 78 1.1 christos .stackaddr: 79 1.1 christos .weak _stack 80 1.1 christos .long _stack 81 1.1 christos .align 1 82 1.1 christos .afterstackaddr: 83 1.1 christos .endm 84 1.1 christos 85 1.1 christos comment "Declare a data variable" 86 1.1 christos .purgem gdbasm_datavar 87 1.1 christos .macro gdbasm_datavar name value 88 1.1 christos .data 89 1.1 christos .align 2 90 1.1 christos .type \name, @object 91 1.1 christos .size \name, 4 92 1.1 christos \name: 93 1.1 christos .long \value 94 1.1 christos .endm 95