1 # Support macros for the Hitachi H8 assembly test cases.
3 ; Set up a minimal machine state
9 .if (sim_cpu == h8300s)
12 .if (sim_cpu == h8300h)
55 .global _write_and_exit
57 ;ssize_t write(int fd, const void *buf, size_t count);
58 ;Integer arguments have to be zero extended.
60 #if __INT_MAX__ == 32767
80 ; Exit with an exit code
88 mov.w #0, r0 ; fd == stdout
89 .if (sim_cpu == h8300)
90 mov.w #pass_str, r1 ; buf == "pass\n"
91 mov.w #5, r2 ; len == 5
93 mov.l #pass_str, er1 ; buf == "pass\n"
94 mov.l #5, er2 ; len == 5
101 mov.w #0, r0 ; fd == stdout
102 .if (sim_cpu == h8300)
103 mov.w #fail_str, r1 ; buf == "fail\n"
104 mov.w #5, r2 ; len == 5
106 mov.l #fail_str, er1 ; buf == "fail\n"
107 mov.l #5, er2 ; len == 5
113 ; Load an 8-bit immediate value into a general register
114 ; (reg must be r0l - r7l or r0h - r7h)
115 .macro mvi_h_gr8 val reg
119 ; Load a 16-bit immediate value into a general register
120 ; (reg must be r0 - r7)
121 .macro mvi_h_gr16 val reg
125 ; Load a 32-bit immediate value into a general register
126 ; (reg must be er0 - er7)
127 .macro mvi_h_gr32 val reg
131 ; Test the value of an 8-bit immediate against a general register
132 ; (reg must be r0l - r7l or r0h - r7h)
133 .macro test_h_gr8 val reg
140 ; Test the value of a 16-bit immediate against a general register
141 ; (reg must be r0 - r7)
142 .macro test_h_gr16 val reg h=h l=l
143 .if (sim_cpu == h8300)
144 test_h_gr8 (\val >> 8) \reg\h
145 test_h_gr8 (\val & 0xff) \reg\l
154 ; Test the value of a 32-bit immediate against a general register
155 ; (reg must be er0 - er7)
156 .macro test_h_gr32 val reg
163 ; Set a general register to the fixed pattern 'a5a5a5a5'
164 .macro set_gr_a5a5 reg
169 mov.l #0xa5a5a5a5, er\reg
173 ; Set all general registers to the fixed pattern 'a5a5a5a5'
186 mov.l #0xa5a5a5a5, er0
187 mov.l #0xa5a5a5a5, er1
188 mov.l #0xa5a5a5a5, er2
189 mov.l #0xa5a5a5a5, er3
190 mov.l #0xa5a5a5a5, er4
191 mov.l #0xa5a5a5a5, er5
192 mov.l #0xa5a5a5a5, er6
193 mov.l #0xa5a5a5a5, er7
197 ; Test that a general register contains the fixed pattern 'a5a5a5a5'
198 .macro test_gr_a5a5 reg
201 test_h_gr16 0xa5a5 r\reg
203 test_h_gr32 0xa5a5a5a5 er\reg
207 ; Test that all general regs contain the fixed pattern 'a5a5a5a5'
219 ; Set condition code register to an explicit value
224 ; Set all condition code flags to zero
229 ; Set carry flag true
230 .macro set_carry_flag
235 .macro clear_carry_flag
245 .macro clear_zero_flag
255 .macro clear_neg_flag
259 ; Test that carry flag is clear
260 .macro test_carry_clear
262 fail ; carry flag not clear
266 ; Test that carry flag is set
267 .macro test_carry_set
269 fail ; carry flag not clear
273 ; Test that overflow flag is clear
274 .macro test_ovf_clear
276 fail ; overflow flag not clear
280 ; Test that overflow flag is set
283 fail ; overflow flag not clear
287 ; Test that zero flag is clear
288 .macro test_zero_clear
290 fail ; zero flag not clear
294 ; Test that zero flag is set
297 fail ; zero flag not clear
301 ; Test that neg flag is clear
302 .macro test_neg_clear
304 fail ; negative flag not clear
308 ; Test that neg flag is set
311 fail ; negative flag not clear
315 ; Test ccr against an explicit value
329 ; Test that all (accessable) condition codes are clear
335 ; leaves H, I, U, and UI untested
338 ; Compare memory, fail if not equal (h8sx only, len > 0).
339 .macro memcmp src dst len