3 # Make a system call with various numbers of arguments
8 ;add R0, R0, R0 ; Delay Slot.
11 .macro syscall1 call arg1
15 .macro syscall2 call arg1 arg2
19 .macro syscall3 call arg1 arg2 arg3
21 syscall2 \call,\arg1,\arg2
25 # Exit with return code
30 # Fill r3/r4 here rather than via syscall3()
31 .macro write_stdout string,len
37 # Exit with return code
44 write_stdout passmsg,5
50 write_stdout failmsg,5
59 # Assert that the contents of reg1 equals the contents of reg2.
60 .macro assertr reg1 reg2
61 breq \reg1, \reg2, exit\@
62 ;add R0, R0, R0 ; Delay slot.
68 # Assert that a register contains 0.
71 ;add R0, R0, R0 ; Delay Slot.
77 # Assert that the contents of register reg match val.
78 .macro assertv reg val
79 addui R10,R0,#%hi16(\val)
81 addui R10, R10, #%lo16(\val)
82 breq \reg, R10, exit\@
83 ;dd R0, R0, R0 ; Delay Slot.
89 # Load the a word from memory into register reg.
90 # This is not for putting the address of a label into
91 .macro loadwl reg label
92 addui R10, R0, #%hi16(\label)
94 addui R10, R10, #%lo16(\label) ; Address of label is now in R8.
95 ldw \reg, R10, #0 ; Put the word at label in reg.
99 # Load the a value into register reg. Note that if you want to
100 # put the address of a label into a register, you use this.
101 # Maybe I should duplicate this as loadaddr to avoid confusion.
102 .macro loadval reg val
103 addui R10, R0, #%hi16(\val)
105 addui R10, R10, #%lo16(\val) ; Address of label is now in R8.
106 addui \reg, R10, #0 ; Put the word at label in reg.
113 # Canonical test case header