5 #define ext16(v) (((v) & 0xffff) | (((v) & 0x8000) * 0x1ffffffe))
6 #define mul16(a, b) ((ext16(a) * ext16(b)))
8 .macro assert_acc_value v
10 movi a5, (\v) & 0xffffffff
18 .macro init_reg sr, reg, val
27 .macro test_mulxx mulop, comb, s, t, a, b
28 init_reg \comb & 2, \s, \a
29 init_reg \comb & 1, \t, \b
32 assert_acc_value mul16(\a, \b)
35 assert_acc_value mul16(\a, (\b >> 16))
38 assert_acc_value mul16((\a >> 16), \b)
41 assert_acc_value mul16((\a >> 16), (\b >> 16))
45 test_mulxx mul.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f
49 test_mulxx mul.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f
53 test_mulxx mul.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f
57 test_mulxx mul.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f
62 movi a4, (\iv) & 0xffffffff
68 .macro test_mulxxx mulop, comb, s, t, a, b, iv, op
69 init_reg \comb & 2, \s, \a
70 init_reg \comb & 1, \t, \b
74 assert_acc_value (\iv \op mul16(\a, \b))
78 assert_acc_value (\iv \op mul16(\a, (\b >> 16)))
82 assert_acc_value (\iv \op mul16((\a >> 16), \b))
86 assert_acc_value (\iv \op mul16((\a >> 16), (\b >> 16)))
91 test_mulxxx mula.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, +
95 test_mulxxx mula.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, +
99 test_mulxxx mula.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
103 test_mulxxx mula.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
108 test_mulxxx muls.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, -
112 test_mulxxx muls.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, -
116 test_mulxxx muls.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, -
120 test_mulxxx muls.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, -
139 1: .word 0x55aa137f, 0x12345678, 0x137fa5a5
158 .word 0x55aa137f, 0x12345678
164 .macro test_mulxxx_ld mulop, ldop, comb, w, x, s, t, a, b, iv, op
165 init_reg \comb & 2, \s, \a
166 init_reg \comb & 1, \t, \b
169 \mulop\().ll.\ldop \w, \x, \s, \t
170 assert_acc_value (\iv \op mul16(\a, \b))
173 \mulop\().lh.\ldop \w, \x, \s, \t
174 assert_acc_value (\iv \op mul16(\a, (\b >> 16)))
177 \mulop\().hl.\ldop \w, \x, \s, \t
178 assert_acc_value (\iv \op mul16((\a >> 16), \b))
181 \mulop\().hh.\ldop \w, \x, \s, \t
182 assert_acc_value (\iv \op mul16((\a >> 16), (\b >> 16)))
187 test_mulxxx_ld mula.da, ldinc, 2, m1, a2, m1, a3, \
188 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
195 1: .word 0xf7315a5a, 0xf7315a5a, 0xf7315a5a, 0x12345678
201 test_mulxxx_ld mula.dd, ldinc, 3, m2, a2, m1, m2, \
202 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
209 1: .word 0xa5a5137f, 0xa5a5137f, 0xa5a5137f, 0x12345678
215 test_mulxxx_ld mula.da, lddec, 2, m1, a2, m1, a3, \
216 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
223 .word 0x12345678, 0xf7315a5a, 0xf7315a5a, 0xf7315a5a
230 test_mulxxx_ld mula.dd, lddec, 3, m2, a2, m1, m2, \
231 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
238 .word 0x12345678, 0xa5a5137f, 0xa5a5137f, 0xa5a5137f