7 #define ext16(v) (((v) & 0xffff) | (((v) & 0x8000) * 0x1ffffffe))
8 #define mul16(a, b) ((ext16(a) * ext16(b)))
10 .macro assert_acc_value v
12 movi a5, (\v) & 0xffffffff
20 .macro init_reg sr, reg, val
29 .macro test_mulxx mulop, comb, s, t, a, b
30 init_reg \comb & 2, \s, \a
31 init_reg \comb & 1, \t, \b
34 assert_acc_value mul16(\a, \b)
37 assert_acc_value mul16(\a, (\b >> 16))
40 assert_acc_value mul16((\a >> 16), \b)
43 assert_acc_value mul16((\a >> 16), (\b >> 16))
47 test_mulxx mul.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f
51 test_mulxx mul.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f
55 test_mulxx mul.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f
59 test_mulxx mul.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f
64 movi a4, (\iv) & 0xffffffff
70 .macro test_mulxxx mulop, comb, s, t, a, b, iv, op
71 init_reg \comb & 2, \s, \a
72 init_reg \comb & 1, \t, \b
76 assert_acc_value (\iv \op mul16(\a, \b))
80 assert_acc_value (\iv \op mul16(\a, (\b >> 16)))
84 assert_acc_value (\iv \op mul16((\a >> 16), \b))
88 assert_acc_value (\iv \op mul16((\a >> 16), (\b >> 16)))
93 test_mulxxx mula.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, +
97 test_mulxxx mula.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, +
101 test_mulxxx mula.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
105 test_mulxxx mula.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
110 test_mulxxx muls.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, -
114 test_mulxxx muls.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, -
118 test_mulxxx muls.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, -
122 test_mulxxx muls.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, -
141 1: .word 0x55aa137f, 0x12345678, 0x137fa5a5
160 .word 0x55aa137f, 0x12345678
166 .macro test_mulxxx_ld mulop, ldop, comb, w, x, s, t, a, b, iv, op
167 init_reg \comb & 2, \s, \a
168 init_reg \comb & 1, \t, \b
171 \mulop\().ll.\ldop \w, \x, \s, \t
172 assert_acc_value (\iv \op mul16(\a, \b))
175 \mulop\().lh.\ldop \w, \x, \s, \t
176 assert_acc_value (\iv \op mul16(\a, (\b >> 16)))
179 \mulop\().hl.\ldop \w, \x, \s, \t
180 assert_acc_value (\iv \op mul16((\a >> 16), \b))
183 \mulop\().hh.\ldop \w, \x, \s, \t
184 assert_acc_value (\iv \op mul16((\a >> 16), (\b >> 16)))
189 test_mulxxx_ld mula.da, ldinc, 2, m1, a2, m1, a3, \
190 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
197 1: .word 0xf7315a5a, 0xf7315a5a, 0xf7315a5a, 0x12345678
203 test_mulxxx_ld mula.dd, ldinc, 3, m2, a2, m1, m2, \
204 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
211 1: .word 0xa5a5137f, 0xa5a5137f, 0xa5a5137f, 0x12345678
217 test_mulxxx_ld mula.da, lddec, 2, m1, a2, m1, a3, \
218 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
225 .word 0x12345678, 0xf7315a5a, 0xf7315a5a, 0xf7315a5a
232 test_mulxxx_ld mula.dd, lddec, 3, m2, a2, m1, m2, \
233 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
240 .word 0x12345678, 0xa5a5137f, 0xa5a5137f, 0xa5a5137f