mac.S 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. /* Tests the MAC instructions.
  2. Copyright (C) 2017-2022 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. # mach: or1k
  14. # output: report(0x00000000);\n
  15. # output: report(0x00000006);\n
  16. # output: report(0x00000000);\n
  17. # output: report(0x0000000c);\n
  18. # output: report(0x00000001);\n
  19. # output: report(0x00000000);\n
  20. # output: report(0x40000000);\n
  21. # output: report(0x00000000);\n
  22. # output: report(0x00000000);\n
  23. # output: report(0x00000000);\n
  24. # output: report(0xffffffff);\n
  25. # output: report(0x00000006);\n
  26. # output: report(0x80000000);\n
  27. # output: report(0x00000006);\n
  28. # output: report(0x00000000);\n
  29. # output: report(0x7ffffffe);\n
  30. # output: report(0x00000000);\n
  31. # output: report(0x80000000);\n
  32. # output: report(0x00000001);\n
  33. # output: report(0x00000000);\n
  34. # output: report(0x7fffffff);\n
  35. # output: report(0xffffffff);\n
  36. # output: report(0x00000000);\n
  37. # output: report(0x7ffffffd);\n
  38. # output: report(0x00000000);\n
  39. # output: report(0x00000000);\n
  40. # output: report(0xffffffff);\n
  41. # output: report(0x00000000);\n
  42. # output: report(0x00000000);\n
  43. # output: report(0x00000006);\n
  44. # output: report(0x00000000);\n
  45. # output: report(0x0000000c);\n
  46. # output: report(0x00000000);\n
  47. # output: report(0x00000005);\n
  48. # output: report(0xffffffff);\n
  49. # output: report(0xfffffffa);\n
  50. # output: report(0x00000000);\n
  51. # output: report(0x00000006);\n
  52. # output: report(0x00000000);\n
  53. # output: report(0xffffffff);\n
  54. # output: report(0x7fffffff);\n
  55. # output: report(0xfffffff9);\n
  56. # output: report(0xffffffff);\n
  57. # output: report(0xfffffff9);\n
  58. # output: report(0xfffffffe);\n
  59. # output: report(0xffffffff);\n
  60. # output: report(0x80000000);\n
  61. # output: report(0x00000000);\n
  62. # output: report(0xffffffff);\n
  63. # output: report(0x80000000);\n
  64. # output: report(0xffffffff);\n
  65. # output: report(0x80000006);\n
  66. # output: report(0x00000000);\n
  67. # output: report(0x00000000);\n
  68. # output: report(0x7fffffff);\n
  69. # output: report(0x7fffffff);\n
  70. # output: report(0xffffffff);\n
  71. # output: report(0x7fffffff);\n
  72. # output: report(0xfffffffe);\n
  73. # output: report(0xffffffff);\n
  74. # output: report(0x80000000);\n
  75. # output: report(0x00000000);\n
  76. # output: report(0x00000000);\n
  77. # output: report(0x00000006);\n
  78. # output: report(0x00000000);\n
  79. # output: report(0x0000000c);\n
  80. # output: report(0x00000001);\n
  81. # output: report(0x00000000);\n
  82. # output: report(0x40000000);\n
  83. # output: report(0x00000000);\n
  84. # output: report(0x00000000);\n
  85. # output: report(0x00000000);\n
  86. # output: report(0xffffffff);\n
  87. # output: report(0x00000006);\n
  88. # output: report(0x80000000);\n
  89. # output: report(0x00000006);\n
  90. # output: report(0x00000000);\n
  91. # output: report(0x7ffffffe);\n
  92. # output: report(0x00000000);\n
  93. # output: report(0x80000000);\n
  94. # output: report(0x00000001);\n
  95. # output: report(0x00000000);\n
  96. # output: report(0x7fffffff);\n
  97. # output: report(0xffffffff);\n
  98. # output: report(0x00000000);\n
  99. # output: report(0x7ffffffd);\n
  100. # output: report(0x00000000);\n
  101. # output: report(0x00000000);\n
  102. # output: report(0xffffffff);\n
  103. # output: report(0x00000000);\n
  104. # output: report(0x00000000);\n
  105. # output: report(0x00000006);\n
  106. # output: report(0x00000000);\n
  107. # output: report(0x0000000c);\n
  108. # output: report(0x00000000);\n
  109. # output: report(0x00000005);\n
  110. # output: report(0xffffffff);\n
  111. # output: report(0xfffffffa);\n
  112. # output: report(0x00000000);\n
  113. # output: report(0x00000006);\n
  114. # output: report(0x00000000);\n
  115. # output: report(0xffffffff);\n
  116. # output: report(0x7fffffff);\n
  117. # output: report(0xfffffff9);\n
  118. # output: report(0xffffffff);\n
  119. # output: report(0xfffffff9);\n
  120. # output: report(0xfffffffe);\n
  121. # output: report(0xffffffff);\n
  122. # output: report(0x80000000);\n
  123. # output: report(0x00000000);\n
  124. # output: report(0xffffffff);\n
  125. # output: report(0x80000000);\n
  126. # output: report(0xffffffff);\n
  127. # output: report(0x80000006);\n
  128. # output: report(0x00000000);\n
  129. # output: report(0x00000000);\n
  130. # output: report(0x7fffffff);\n
  131. # output: report(0x7fffffff);\n
  132. # output: report(0xffffffff);\n
  133. # output: report(0x7fffffff);\n
  134. # output: report(0xfffffffe);\n
  135. # output: report(0xffffffff);\n
  136. # output: report(0x80000000);\n
  137. # output: report(0x00000000);\n
  138. # output: report(0x00000006);\n
  139. # output: report(0x0000000c);\n
  140. # output: report(0x00000000);\n
  141. # output: report(0x00000000);\n
  142. # output: report(0x00000000);\n
  143. # output: report(0x00000006);\n
  144. # output: report(0x00000006);\n
  145. # output: report(0x7ffffffe);\n
  146. # output: report(0x80000000);\n
  147. # output: report(0x00000000);\n
  148. # output: report(0xffffffff);\n
  149. # output: report(0x7ffffffd);\n
  150. # output: report(0x00000000);\n
  151. # output: report(0x00000000);\n
  152. # output: report(0x00000006);\n
  153. # output: report(0x0000000c);\n
  154. # output: report(0x00000005);\n
  155. # output: report(0xfffffffa);\n
  156. # output: report(0x00000006);\n
  157. # output: report(0xffffffff);\n
  158. # output: report(0xfffffff9);\n
  159. # output: report(0xfffffff9);\n
  160. # output: report(0xffffffff);\n
  161. # output: report(0x00000000);\n
  162. # output: report(0x80000000);\n
  163. # output: report(0x80000006);\n
  164. # output: report(0x00000000);\n
  165. # output: report(0x7fffffff);\n
  166. # output: report(0x7fffffff);\n
  167. # output: report(0xffffffff);\n
  168. # output: report(0x00000000);\n
  169. # output: report(0xffffffff);\n
  170. # output: report(0xfffffffa);\n
  171. # output: report(0x00000000);\n
  172. # output: report(0x00000006);\n
  173. # output: report(0x00000000);\n
  174. # output: report(0xfffffffa);\n
  175. # output: report(0x3fffffff);\n
  176. # output: report(0xfffffffa);\n
  177. # output: report(0xffffffff);\n
  178. # output: report(0xfffffff4);\n
  179. # output: report(0xfffffffe);\n
  180. # output: report(0xffffffff);\n
  181. # output: report(0x80000000);\n
  182. # output: report(0x00000000);\n
  183. # output: report(0xffffffff);\n
  184. # output: report(0x80000002);\n
  185. # output: report(0xffffffff);\n
  186. # output: report(0x80000004);\n
  187. # output: report(0x00000000);\n
  188. # output: report(0x00000004);\n
  189. # output: report(0x7ffffffe);\n
  190. # output: report(0xffffffff);\n
  191. # output: report(0xffffffff);\n
  192. # output: report(0x80000001);\n
  193. # output: report(0xffffffff);\n
  194. # output: report(0x00000004);\n
  195. # output: report(0xfffffffe);\n
  196. # output: report(0x00000004);\n
  197. # output: report(0x00000000);\n
  198. # output: report(0x00000000);\n
  199. # output: report(0x00000000);\n
  200. # output: report(0x00000006);\n
  201. # output: report(0xffffffff);\n
  202. # output: report(0xfffffff9);\n
  203. # output: report(0x00000000);\n
  204. # output: report(0x00000006);\n
  205. # output: report(0x00000000);\n
  206. # output: report(0x0000000c);\n
  207. # output: report(0x00000001);\n
  208. # output: report(0x00000005);\n
  209. # output: report(0x7fffffff);\n
  210. # output: report(0xffffffff);\n
  211. # output: report(0xffffffff);\n
  212. # output: report(0xffffffff);\n
  213. # output: report(0xffffffff);\n
  214. # output: report(0x00000005);\n
  215. # output: report(0x80000000);\n
  216. # output: report(0x00000006);\n
  217. # output: report(0x00000000);\n
  218. # output: report(0x80000000);\n
  219. # output: report(0x00000000);\n
  220. # output: report(0x80000006);\n
  221. # output: report(0x00000001);\n
  222. # output: report(0x00000000);\n
  223. # output: report(0x7fffffff);\n
  224. # output: report(0xffffffff);\n
  225. # output: report(0x00000000);\n
  226. # output: report(0x7fffffff);\n
  227. # output: report(0xffffffff);\n
  228. # output: report(0x7fffffff);\n
  229. # output: report(0x80000000);\n
  230. # output: report(0x80000000);\n
  231. # output: exit(0)\n
  232. #include "or1k-asm-test-helpers.h"
  233. .macro TEST_MACRC mac_hi, mac_lo, op1, op2
  234. LOAD_IMMEDIATE r2, \mac_hi
  235. MOVE_TO_SPR SPR_MACHI, r2
  236. LOAD_IMMEDIATE r2, \mac_lo
  237. MOVE_TO_SPR SPR_MACLO, r2
  238. LOAD_IMMEDIATE r5, \op1
  239. LOAD_IMMEDIATE r6, \op2
  240. l.mac r5, r6
  241. l.macrc r3
  242. REPORT_REG_TO_CONSOLE r3
  243. .endm
  244. .macro TEST_MAC mac_hi, mac_lo, op1, op2
  245. LOAD_IMMEDIATE r2, \mac_hi
  246. MOVE_TO_SPR SPR_MACHI, r2
  247. LOAD_IMMEDIATE r2, \mac_lo
  248. MOVE_TO_SPR SPR_MACLO, r2
  249. LOAD_IMMEDIATE r5, \op1
  250. LOAD_IMMEDIATE r6, \op2
  251. l.mac r5, r6
  252. MOVE_FROM_SPR r3, SPR_MACHI
  253. REPORT_REG_TO_CONSOLE r3
  254. MOVE_FROM_SPR r3, SPR_MACLO
  255. REPORT_REG_TO_CONSOLE r3
  256. .endm
  257. .macro TEST_MACI mac_hi, mac_lo, op1, op2_immediate
  258. LOAD_IMMEDIATE r2, \mac_hi
  259. MOVE_TO_SPR SPR_MACHI, r2
  260. LOAD_IMMEDIATE r2, \mac_lo
  261. MOVE_TO_SPR SPR_MACLO, r2
  262. LOAD_IMMEDIATE r5, \op1
  263. l.maci r5, \op2_immediate
  264. MOVE_FROM_SPR r3, SPR_MACHI
  265. REPORT_REG_TO_CONSOLE r3
  266. MOVE_FROM_SPR r3, SPR_MACLO
  267. REPORT_REG_TO_CONSOLE r3
  268. .endm
  269. .macro TEST_MSB mac_hi, mac_lo, op1, op2
  270. LOAD_IMMEDIATE r2, \mac_hi
  271. MOVE_TO_SPR SPR_MACHI, r2
  272. LOAD_IMMEDIATE r2, \mac_lo
  273. MOVE_TO_SPR SPR_MACLO, r2
  274. LOAD_IMMEDIATE r5, \op1
  275. LOAD_IMMEDIATE r6, \op2
  276. l.msb r5, r6
  277. MOVE_FROM_SPR r3, SPR_MACHI
  278. REPORT_REG_TO_CONSOLE r3
  279. MOVE_FROM_SPR r3, SPR_MACLO
  280. REPORT_REG_TO_CONSOLE r3
  281. .endm
  282. STANDARD_TEST_ENVIRONMENT
  283. .section .text
  284. start_tests:
  285. PUSH LINK_REGISTER_R9
  286. /* Test the l.mac instruction. */
  287. /* two small positive numbers */
  288. /* MAC two small positive numbers on a zero total */
  289. TEST_MAC 0x00000000, 0x00000000, 0x00000002, 0x00000003
  290. /* MAC two small positive numbers on a small positive total */
  291. TEST_MAC 0x00000000, 0x00000006, 0x00000002, 0x00000003,
  292. /* MAC two small positive numbers on a moderate positive total */
  293. TEST_MAC 0x00000000, 0xfffffffa, 0x00000002, 0x00000003
  294. /* MAC two small positive numbers on a large positive total */
  295. TEST_MAC 0x3fffffff, 0xfffffffa, 0x00000002, 0x00000003
  296. /* MAC two small positive numbers on a small negative total */
  297. TEST_MAC 0xffffffff, 0xfffffffa, 0x00000002, 0x00000003
  298. /* MAC two small positive numbers on a moderate negative total */
  299. TEST_MAC 0xffffffff, 0x00000000, 0x00000002, 0x00000003
  300. /* MAC two small positive numbers on a large negative total */
  301. TEST_MAC 0x80000000, 0x00000000, 0x00000002, 0x00000003
  302. /* two moderate positive numbers */
  303. /* MAC two moderate positive numbers on a zero total */
  304. TEST_MAC 0x00000000, 0x00000000, 0x00008001, 0x0000fffe
  305. /* MAC two moderate positive numbers on a small positive total */
  306. TEST_MAC 0x00000000, 0x00000002, 0x00008001, 0x0000fffe
  307. /* MAC two moderate positive numbers on a moderate positive total */
  308. TEST_MAC 0x00000000, 0x80000002, 0x00008001, 0x0000fffe
  309. /* MAC two moderate positive numbers on a large positive total */
  310. TEST_MAC 0x7fffffff, 0x80000001, 0x00008001, 0x0000fffe
  311. /* MAC two moderate positive numbers on a small negative total */
  312. TEST_MAC 0xffffffff, 0xffffffff, 0x00008001, 0x0000fffe
  313. /* MAC two moderate positive numbers on a moderate negative total */
  314. TEST_MAC 0xffffffff, 0x80000002, 0x00008001, 0x0000fffe
  315. /* MAC two moderate positive numbers on a large negative total */
  316. TEST_MAC 0xfffffffe, 0x80000002, 0x00008001, 0x0000fffe
  317. /* two small negative numbers */
  318. /* MAC two small negative numbers on a zero total */
  319. TEST_MAC 0x00000000, 0x00000000, 0xfffffffe, 0xfffffffd
  320. /* MAC two small negative numbers on a small positive total */
  321. TEST_MAC 0x00000000, 0x00000006, 0xfffffffe, 0xfffffffd
  322. /* MAC two small negative numbers on a small negative total */
  323. TEST_MAC 0xffffffff, 0xffffffff, 0xfffffffe, 0xfffffffd
  324. /* one small positive and one small negative */
  325. /* MAC one small positive and one small negative number on a zero
  326. total */
  327. TEST_MAC 0x00000000, 0x00000000, 0x00000002, 0xfffffffd
  328. /* MAC one small positive and one small negative number on a small
  329. positive total */
  330. TEST_MAC 0x00000000, 0x0000000c, 0x00000002, 0xfffffffd
  331. /* MAC one small positive and one small negative number on a
  332. moderate positive total */
  333. TEST_MAC 0x00000001, 0x00000005, 0x00000002, 0xfffffffd
  334. /* MAC one small positive and one small negative number on a large
  335. positive total */
  336. TEST_MAC 0x7fffffff, 0xffffffff, 0x00000002, 0xfffffffd
  337. /* MAC one small positive and one small negative number on a small
  338. negative total */
  339. TEST_MAC 0xffffffff, 0xffffffff, 0x00000002, 0xfffffffd
  340. /* MAC one small positive and one small negative number on a
  341. moderate negative total */
  342. TEST_MAC 0xffffffff, 0x00000005, 0x00000002, 0xfffffffd
  343. /* MAC one small positive and one small negative number on a large
  344. negative total */
  345. TEST_MAC 0x80000000, 0x00000006, 0x00000002, 0xfffffffd
  346. /* one moderate positive and one moderate negative number */
  347. /* MAC one moderate positive and one moderate negative number on a
  348. zero total */
  349. TEST_MAC 0x00000000, 0x00000000, 0x00008000, 0xffff0000
  350. /* MAC one moderate positive and one moderate negative number on a
  351. small positive total */
  352. TEST_MAC 0x00000000, 0x00000006, 0x00008000, 0xffff0000
  353. /* MAC one moderate positive and one moderate negative number on a
  354. moderate positive total */
  355. TEST_MAC 0x00000000, 0x80000000, 0x00008000, 0xffff0000
  356. /* MAC one moderate positive and one moderate negative number on a
  357. large positive total */
  358. TEST_MAC 0x7fffffff, 0xffffffff, 0x00008000, 0xffff0000
  359. /* MAC one moderate positive and one moderate negative number on a
  360. small negative total */
  361. TEST_MAC 0xffffffff, 0xffffffff, 0x00008000, 0xffff0000
  362. /* MAC one moderate positive and one moderate negative number on a
  363. moderate negative total */
  364. TEST_MAC 0xffffffff, 0x7fffffff, 0x00008000, 0xffff0000
  365. /* MAC one moderate positive and one moderate negative number on a
  366. large negative total */
  367. TEST_MAC 0x80000000, 0x80000000, 0x00008000, 0xffff0000
  368. /* Test the l.maci instruction. */
  369. /* two small positive numbers */
  370. /* MAC two small positive numbers on a zero total */
  371. TEST_MACI 0x00000000, 0x00000000, 0x00000002, 0x0003
  372. /* MAC two small positive numbers on a small positive total */
  373. TEST_MACI 0x00000000, 0x00000006, 0x00000002, 0x0003
  374. /* MAC two small positive numbers on a moderate positive total */
  375. TEST_MACI 0x00000000, 0xfffffffa, 0x00000002, 0x0003
  376. /* MAC two small positive numbers on a large positive total */
  377. TEST_MACI 0x3fffffff, 0xfffffffa, 0x00000002, 0x0003
  378. /* MAC two small positive numbers on a small negative total */
  379. TEST_MACI 0xffffffff, 0xfffffffa, 0x00000002, 0x0003
  380. /* MAC two small positive numbers on a moderate negative total */
  381. TEST_MACI 0xffffffff, 0x00000000, 0x00000002, 0x0003
  382. /* MAC two small positive numbers on a large negative total */
  383. TEST_MACI 0x80000000, 0x00000000, 0x00000002, 0x0003
  384. /* two moderate positive numbers */
  385. /* MAC two moderate positive numbers on a zero total */
  386. TEST_MACI 0x00000000, 0x00000000, 0x00010002, 0x7fff
  387. /* MAC two moderate positive numbers on a small positive total */
  388. TEST_MACI 0x00000000, 0x00000002, 0x00010002, 0x7fff
  389. /* MAC two moderate positive numbers on a moderate positive total */
  390. TEST_MACI 0x00000000, 0x80000002, 0x00010002, 0x7fff
  391. /* MAC two moderate positive numbers on a large positive total */
  392. TEST_MACI 0x7fffffff, 0x80000001, 0x00010002, 0x7fff
  393. /* MAC two moderate positive numbers on a small negative total */
  394. TEST_MACI 0xffffffff, 0xffffffff, 0x00010002, 0x7fff
  395. /* MAC two moderate positive numbers on a moderate negative total */
  396. TEST_MACI 0xffffffff, 0x80000002, 0x00010002, 0x7fff
  397. /* MAC two moderate positive numbers on a large negative total */
  398. TEST_MACI 0xfffffffe, 0x80000002, 0x00010002, 0x7fff
  399. /* two small negative numbers */
  400. /* MAC two small negative numbers on a zero total */
  401. TEST_MACI 0x00000000, 0x00000000, 0xfffffffe, 0xfffd
  402. /* MAC two small negative numbers on a small positive total */
  403. TEST_MACI 0x00000000, 0x00000006, 0xfffffffe, 0xfffd
  404. /* MAC two small negative numbers on a small negative total */
  405. TEST_MACI 0xffffffff, 0xffffffff, 0xfffffffe, 0xfffd
  406. /* one small positive and one small negative */
  407. /* MAC one small positive and one small negative number on a zero
  408. total */
  409. TEST_MACI 0x00000000, 0x00000000, 0x00000002, 0xfffd
  410. /* MAC one small positive and one small negative number on a small
  411. positive total */
  412. TEST_MACI 0x00000000, 0x0000000c, 0x00000002, 0xfffd
  413. /* MAC one small positive and one small negative number on a
  414. moderate positive total */
  415. TEST_MACI 0x00000001, 0x00000005, 0x00000002, 0xfffd
  416. /* MAC one small positive and one small negative number on a large
  417. positive total */
  418. TEST_MACI 0x7fffffff, 0xffffffff, 0x00000002, 0xfffd
  419. /* MAC one small positive and one small negative number on a small
  420. negative total */
  421. TEST_MACI 0xffffffff, 0xffffffff, 0x00000002, 0xfffd
  422. /* MAC one small positive and one small negative number on a
  423. moderate negative total */
  424. TEST_MACI 0xffffffff, 0x00000005, 0x00000002, 0xfffd
  425. /* MAC one small positive and one small negative number on a large
  426. negative total */
  427. TEST_MACI 0x80000000, 0x00000006, 0x00000002, 0xfffd
  428. /* one moderate positive and one moderate negative */
  429. /* MAC one moderate positive and one moderate negative number on a
  430. zero total */
  431. TEST_MACI 0x00000000, 0x00000000, 0x00010000, 0x8000
  432. /* MAC one moderate positive and one moderate negative number on a
  433. small positive total */
  434. TEST_MACI 0x00000000, 0x00000006, 0x00010000, 0x8000
  435. /* MAC one moderate positive and one moderate negative number on a
  436. moderate positive total */
  437. TEST_MACI 0x00000000, 0x80000000, 0x00010000, 0x8000
  438. /* MAC one moderate positive and one moderate negative number on a
  439. large positive total */
  440. TEST_MACI 0x7fffffff, 0xffffffff, 0x00010000, 0x8000
  441. /* MAC one moderate positive and one moderate negative number on a
  442. small negative total */
  443. TEST_MACI 0xffffffff, 0xffffffff, 0x00010000, 0x8000
  444. /* MAC one moderate positive and one moderate negative number on a
  445. moderate negative total */
  446. TEST_MACI 0xffffffff, 0x7fffffff, 0x00010000, 0x8000
  447. /* MAC one moderate positive and one moderate negative number on a
  448. large negative total */
  449. TEST_MACI 0x80000000, 0x80000000, 0x00010000, 0x8000
  450. /* Test the l.macrc instruction.
  451. Note that these tests use the same input data as the ones for
  452. l.mac above. The results are the same, but only the low 32-bits
  453. are compared. */
  454. /* two small positive numbers */
  455. /* MAC two small positive numbers on a zero total */
  456. TEST_MACRC 0x00000000, 0x00000000, 0x00000002, 0x00000003
  457. /* MAC two small positive numbers on a small positive total */
  458. TEST_MACRC 0x00000000, 0x00000006, 0x00000002, 0x00000003
  459. /* MAC two small positive numbers on a moderate positive total */
  460. TEST_MACRC 0x00000000, 0xfffffffa, 0x00000002, 0x00000003
  461. /* MAC two small positive numbers on a large positive total */
  462. TEST_MACRC 0x3fffffff, 0xfffffffa, 0x00000002, 0x00000003
  463. /* MAC two small positive numbers on a small negative total */
  464. TEST_MACRC 0xffffffff, 0xfffffffa, 0x00000002, 0x00000003
  465. /* MAC two small positive numbers on a moderate negative total */
  466. TEST_MACRC 0xffffffff, 0x00000000, 0x00000002, 0x00000003
  467. /* MAC two small positive numbers on a large negative total */
  468. TEST_MACRC 0x80000000, 0x00000000, 0x00000002, 0x00000003
  469. /* two moderate positive numbers */
  470. /* MAC two moderate positive numbers on a zero total */
  471. TEST_MACRC 0x00000000, 0x00000000, 0x00008001, 0x0000fffe
  472. /* MAC two moderate positive numbers on a small positive total */
  473. TEST_MACRC 0x00000000, 0x00000002, 0x00008001, 0x0000fffe
  474. /* MAC two moderate positive numbers on a moderate positive total */
  475. TEST_MACRC 0x00000000, 0x80000002, 0x00008001, 0x0000fffe
  476. /* MAC two moderate positive numbers on a large positive total */
  477. TEST_MACRC 0x7fffffff, 0x80000001, 0x00008001, 0x0000fffe
  478. /* MAC two moderate positive numbers on a small negative total */
  479. TEST_MACRC 0xffffffff, 0xffffffff, 0x00008001, 0x0000fffe
  480. /* MAC two moderate positive numbers on a moderate negative total */
  481. TEST_MACRC 0xffffffff, 0x80000002, 0x00008001, 0x0000fffe
  482. /* MAC two moderate positive numbers on a large negative total */
  483. TEST_MACRC 0xfffffffe, 0x80000002, 0x00008001, 0x0000fffe
  484. /* two small negative numbers */
  485. /* MAC two small negative numbers on a zero total */
  486. TEST_MACRC 0x00000000, 0x00000000, 0xfffffffe, 0xfffffffd
  487. /* MAC two small negative numbers on a small positive total */
  488. TEST_MACRC 0x00000000, 0x00000006, 0xfffffffe, 0xfffffffd
  489. /* MAC two small negative numbers on a small negative total */
  490. TEST_MACRC 0xffffffff, 0xffffffff, 0xfffffffe, 0xfffffffd
  491. /* one small positive and one small negative number */
  492. /* MAC one small positive and one small negative number on a zero
  493. total */
  494. TEST_MACRC 0x00000000, 0x00000000, 0x00000002, 0xfffffffd
  495. /* MAC one small positive and one small negative number on a small
  496. positive total */
  497. TEST_MACRC 0x00000000, 0x0000000c, 0x00000002, 0xfffffffd
  498. /* MAC one small positive and one small negative number on a
  499. moderate positive total */
  500. TEST_MACRC 0x00000001, 0x00000005, 0x00000002, 0xfffffffd
  501. /* MAC one small positive and one small negative number on a large
  502. positive total */
  503. TEST_MACRC 0x7fffffff, 0xffffffff, 0x00000002, 0xfffffffd
  504. /* MAC one small positive and one small negative number on a small
  505. negative total */
  506. TEST_MACRC 0xffffffff, 0xffffffff, 0x00000002, 0xfffffffd
  507. /* MAC one small positive and one small negative number on a
  508. moderate negative total */
  509. TEST_MACRC 0xffffffff, 0x00000005, 0x00000002, 0xfffffffd
  510. /* MAC one small positive and one small negative number on a large
  511. negative total */
  512. TEST_MACRC 0x80000000, 0x00000006, 0x00000002, 0xfffffffd
  513. /* one moderate positive and one moderate negative */
  514. /* MAC one moderate positive and one moderate negative number on a
  515. zero total */
  516. TEST_MACRC 0x00000000, 0x00000000, 0x00008000, 0xffff0000
  517. /* MAC one moderate positive and one moderate negative number on a
  518. small positive total */
  519. TEST_MACRC 0x00000000, 0x00000006, 0x00008000, 0xffff0000
  520. /* MAC one moderate positive and one moderate negative number on a
  521. moderate positive total */
  522. TEST_MACRC 0x00000000, 0x80000000, 0x00008000, 0xffff0000
  523. /* MAC one moderate positive and one moderate negative number on a
  524. large positive total */
  525. TEST_MACRC 0x7fffffff, 0xffffffff, 0x00008000, 0xffff0000
  526. /* MAC one moderate positive and one moderate negative number on a
  527. small negative total */
  528. TEST_MACRC 0xffffffff, 0xffffffff, 0x00008000, 0xffff0000
  529. /* MAC one moderate positive and one moderate negative number on a
  530. moderate negative total */
  531. TEST_MACRC 0xffffffff, 0x7fffffff, 0x00008000, 0xffff0000
  532. /* MAC one moderate positive and one moderate negative number on a
  533. large negative total */
  534. TEST_MACRC 0x80000000, 0x80000000, 0x00008000, 0xffff0000
  535. /* Test the l.msb instruction. */
  536. /* MSB two small positive numbers on a zero total */
  537. TEST_MSB 0x00000000, 0x00000000, 0x00000002, 0x00000003
  538. /* MSB two small positive numbers on a small positive total */
  539. TEST_MSB 0x00000000, 0x0000000c, 0x00000002, 0x00000003
  540. /* MSB two small positive numbers on a moderate positive total */
  541. TEST_MSB 0x00000001, 0x00000000, 0x00000002, 0x00000003
  542. /* MSB two small positive numbers on a large positive total */
  543. TEST_MSB 0x40000000, 0x00000000, 0x00000002, 0x00000003
  544. /* MSB two small positive numbers on a small negative total */
  545. TEST_MSB 0xffffffff, 0xfffffffa, 0x00000002, 0x00000003
  546. /* MSB two small positive numbers on a moderate negative total */
  547. TEST_MSB 0xffffffff, 0x00000005, 0x00000002, 0x00000003
  548. /* MSB two small positive numbers on a large negative total */
  549. TEST_MSB 0x80000000, 0x00000006, 0x00000002, 0x00000003
  550. /* two moderate positive numbers */
  551. /* MSB two moderate positive numbers on a zero total */
  552. TEST_MSB 0x00000000, 0x00000000, 0x00008001, 0x0000fffe
  553. /* MSB two moderate positive numbers on a small positive total */
  554. TEST_MSB 0x00000000, 0x00000002, 0x00008001, 0x0000fffe
  555. /* MSB two moderate positive numbers on a moderate positive total */
  556. TEST_MSB 0x00000000, 0x80000002, 0x00008001, 0x0000fffe
  557. /* MSB two moderate positive numbers on a large positive total */
  558. TEST_MSB 0x7fffffff, 0x7ffffffd, 0x00008001, 0x0000fffe
  559. /* MSB two moderate positive numbers on a small negative total */
  560. TEST_MSB 0xffffffff, 0xffffffff, 0x00008001, 0x0000fffe
  561. /* MSB two moderate positive numbers on a moderate negative total */
  562. TEST_MSB 0xffffffff, 0x80000002, 0x00008001, 0x0000fffe
  563. /* MSB two moderate positive numbers on a large negative total */
  564. TEST_MSB 0xfffffffe, 0x80000002, 0x00008001, 0x0000fffe
  565. /* two small negative numbers */
  566. /* MSB two small negative numbers on a zero total */
  567. TEST_MSB 0x00000000, 0x00000006, 0xfffffffe, 0xfffffffd
  568. /* MSB two small negative numbers on a small positive total */
  569. TEST_MSB 0x00000000, 0x0000000c, 0xfffffffe, 0xfffffffd
  570. /* MSB two small negative numbers on a small negative total */
  571. TEST_MSB 0xffffffff, 0xffffffff, 0xfffffffe, 0xfffffffd
  572. /* one small positive and one small negative number */
  573. /* MSB one small positive and one small negative number on a zero
  574. total */
  575. TEST_MSB 0x00000000, 0x00000000, 0x00000002, 0xfffffffd
  576. /* MSB one small positive and one small negative number on a small
  577. positive total */
  578. TEST_MSB 0x00000000, 0x00000006, 0x00000002, 0xfffffffd
  579. /* MSB one small positive and one small negative number on a
  580. moderate positive total */
  581. TEST_MSB 0x00000000, 0xffffffff, 0x00000002, 0xfffffffd
  582. /* MSB one small positive and one small negative number on a large
  583. positive total */
  584. TEST_MSB 0x7fffffff, 0xfffffff9, 0x00000002, 0xfffffffd
  585. /* MSB one small positive and one small negative number on a small
  586. negative total */
  587. TEST_MSB 0xffffffff, 0xfffffff9, 0x00000002, 0xfffffffd
  588. /* MSB one small positive and one small negative number on a
  589. moderate negative total */
  590. TEST_MSB 0xfffffffe, 0xffffffff, 0x00000002, 0xfffffffd
  591. /* MSB one small positive and one small negative number on a large
  592. negative total */
  593. TEST_MSB 0x80000000, 0x00000000, 0x00000002, 0xfffffffd
  594. /* one moderate positive and one moderate negative number */
  595. /* MSB one moderate positive and one moderate negative number on a
  596. zero total */
  597. TEST_MSB 0x00000000, 0x00000000, 0x00008000, 0xffff0000
  598. /* MSB one moderate positive and one moderate negative number on a
  599. small positive total */
  600. TEST_MSB 0x00000000, 0x00000006, 0x00008000, 0xffff0000
  601. /* MSB one moderate positive and one moderate negative number on a
  602. moderate positive total */
  603. TEST_MSB 0x00000000, 0x80000000, 0x00008000, 0xffff0000
  604. /* MSB one moderate positive and one moderate negative number on a
  605. large positive total */
  606. TEST_MSB 0x7fffffff, 0x7fffffff, 0x00008000, 0xffff0000
  607. /* MSB one moderate positive and one moderate negative number on a
  608. small negative total */
  609. TEST_MSB 0xffffffff, 0xffffffff, 0x00008000, 0xffff0000
  610. /* MSB one moderate positive and one moderate negative number on a
  611. moderate negative total */
  612. TEST_MSB 0xfffffffe, 0xffffffff, 0x00008000, 0xffff0000
  613. /* MSB one moderate positive and one moderate negative number on a
  614. large negative total */
  615. TEST_MSB 0x80000000, 0x00000000, 0x00008000, 0xffff0000
  616. POP LINK_REGISTER_R9
  617. RETURN_TO_LINK_REGISTER_R9