add_test.dta 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. ;
  2. ; Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
  3. ; Universitaet Berlin. See the accompanying file "COPYRIGHT" for
  4. ; details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  5. ;
  6. ;
  7. ; Lines starting with ' (in the first col) are echoed.
  8. ; Lines starting with " (in the first col) are echoed to stderr.
  9. ; Lines starting with ; or empty lines are ignored.
  10. ;
  11. ; The part after (including) a trailing '=' is what you expect;
  12. ; there will be output if the result is different.
  13. ;
  14. ; - and + by itself mean MIN_WORD and MAX_WORD, respectively;
  15. ; -- and ++ mean MIN_LONGWORD and MAX_LONGWORD.
  16. ;
  17. 'test the basic arithmetic operations used for the rpe-ltd filtering.
  18. '
  19. 'add ================
  20. ' basic
  21. add 0 0 = 0
  22. add 7 4 = 11
  23. add 4 6 = 10
  24. add 1 1 = 2
  25. ' negative operands
  26. add -7 4 = -3
  27. add 4 -6 = -2
  28. add -1 -3 = -4
  29. add 7 -4 = 3
  30. add -4 6 = 2
  31. ' positive overflow
  32. ; (max-word = 32767)
  33. add + 1 = +
  34. add + + = +
  35. add -1 + = 32766
  36. add 32766 2 = +
  37. add 1 32766 = +
  38. ' underflow
  39. ; (min-word = 32768)
  40. add - -1 = -
  41. add - - = -
  42. add 1 - = -32767
  43. add -32767 -2 = -
  44. add -1 -32766 = -32767
  45. add -32767 -1 = -
  46. add - + = -1
  47. add + - = -1
  48. add 0 - = -
  49. add 0 + = +
  50. '
  51. 'L_add ================
  52. ' basic
  53. L_add 0 0 = 0
  54. L_add 7 4 = 11
  55. L_add 4 6 = 10
  56. L_add 1 1 = 2
  57. ' negative operands
  58. L_add -7 4 = -3
  59. L_add 4 -6 = -2
  60. L_add -1 -3 = -4
  61. L_add 7 -4 = 3
  62. L_add -4 6 = 2
  63. L_add 0 -1 = -1
  64. ' positive overflow
  65. ; (max-longword = 2147483647)
  66. L_add ++ 1 = ++
  67. L_add ++ ++ = ++
  68. L_add -1 ++ = 2147483646
  69. L_add 2147483646 2 = ++
  70. L_add 1 2147483645 = 2147483646
  71. ' underflow
  72. ; (min-longword = -2147483648)
  73. L_add -- -1 = --
  74. L_add -- -- = --
  75. L_add 1 -- = -2147483647
  76. L_add -2147483647 -2 = --
  77. L_add -1 -2147483646 = -2147483647
  78. L_add -2147483647 -1 = --
  79. L_add -- ++ = -1
  80. L_add ++ -- = -1
  81. L_add 0 -- = --
  82. L_add 0 ++ = ++
  83. '
  84. 'sub ================
  85. ' basic
  86. sub 0 0 = 0
  87. sub 7 4 = 3
  88. sub 4 6 = -2
  89. sub 1 0 = 1
  90. ' negative operands
  91. sub -7 4 = -11
  92. sub 4 -6 = 10
  93. sub -1 -3 = 2
  94. sub 7 -4 = 11
  95. sub -4 6 = -10
  96. ' positive overflow
  97. ; (max-word = 32767)
  98. sub 1 - = +
  99. sub + + = 0
  100. sub + 0 = +
  101. sub + -1 = +
  102. sub + 1 = 32766
  103. sub 1 + = -32766
  104. sub 0 + = -32767
  105. ' underflow
  106. ; (min-word = 32768)
  107. sub - -1 = -32767
  108. sub - 1 = -
  109. sub - - = 0
  110. sub - + = -
  111. sub + - = +
  112. sub 1 - = +
  113. sub -1 - = +
  114. sub -32767 2 = -
  115. sub 0 - = +
  116. '
  117. 'L_sub ================
  118. ' basic
  119. L_sub 0 0 = 0
  120. L_sub 7 4 = 3
  121. L_sub 4 6 = -2
  122. L_sub 1 0 = 1
  123. ' negative operands
  124. L_sub -7 4 = -11
  125. L_sub 4 -6 = 10
  126. L_sub -1 -3 = 2
  127. L_sub 7 -4 = 11
  128. L_sub -4 6 = -10
  129. ' positive overflow
  130. L_sub 1 -- = ++
  131. L_sub ++ ++ = 0
  132. L_sub ++ 0 = ++
  133. L_sub ++ -1 = ++
  134. L_sub ++ 1 = 2147483646
  135. L_sub 1 ++ = -2147483646
  136. L_sub 0 ++ = -2147483647
  137. ' underflow
  138. L_sub -- -1 = -2147483647
  139. L_sub -- 1 = --
  140. L_sub -- -- = 0
  141. L_sub -- ++ = --
  142. L_sub + -- = ++
  143. L_sub 1 -- = ++
  144. L_sub -1 -- = ++
  145. L_sub -2147483647 2 = --
  146. L_sub 0 -- = ++
  147. '
  148. 'abs ================
  149. ' basic
  150. abs 0 = 0
  151. abs 2 = 2
  152. abs -459 = 459
  153. ' overflow
  154. abs + = +
  155. abs - = +
  156. abs -32767 = +
  157. abs 32766 = 32766
  158. abs -32766 = 32766
  159. '
  160. 'mult ================
  161. ; actually, a * b >> 15
  162. ' basic
  163. mult 0 0 = 0
  164. mult 0x100 0x100 = 2
  165. mult 4711 0x4000 = 2355
  166. ' negative operands
  167. mult -1 0 = 0
  168. mult -0x100 0x100 = -2
  169. mult 0x100 -0x100 = -2
  170. mult -0x100 -0x100 = 2
  171. mult -4711 0x4000 = -2356
  172. mult 4711 -0x4000 = -2356
  173. mult -4711 -0x4000 = 2355
  174. ' overflow
  175. mult + + = 32766
  176. mult + 0x4000 = 0x3fff
  177. mult 0x4000 + = 0x3fff
  178. mult + 1 = 0
  179. mult + 2 = 1
  180. mult + 3 = 2
  181. ' underflow
  182. mult - - = +
  183. mult - + = -32767
  184. mult + - = -32767
  185. mult - 1 = -1
  186. mult - 2 = -2
  187. mult - 3 = -3
  188. '
  189. 'mult_r ================
  190. ; actually, (a * b + 16384) >> 15
  191. ' basic
  192. mult_r 0 0 = 0
  193. mult_r 0x100 0x100 = 2
  194. mult_r 4711 0x4000 = 2356
  195. ' negative operands
  196. mult_r -1 0 = 0
  197. mult_r -0x100 0x100 = -2
  198. mult_r 0x100 -0x100 = -2
  199. mult_r -0x100 -0x100 = 2
  200. mult_r -4711 0x4000 = -2355
  201. mult_r 4711 -0x4000 = -2355
  202. mult_r -4711 -0x4000 = 2356
  203. ' overflow
  204. mult_r + + = 32766
  205. mult_r + 32766 = 32765
  206. mult_r 32766 + = 32765
  207. mult_r + 0x4000 = 0x4000
  208. mult_r 0x4000 + = 0x4000
  209. mult_r + 0x4001 = 0x4000
  210. mult_r 0x4001 + = 0x4000
  211. mult_r + 2 = 2
  212. mult_r + 1 = 1
  213. mult_r 1 + = 1
  214. mult_r + 0 = 0
  215. mult_r 0 + = 0
  216. ' underflow
  217. mult_r - - = +
  218. mult_r - + = -32767
  219. mult_r + - = -32767
  220. mult_r - 1 = -1
  221. mult_r - 2 = -2
  222. mult_r - 3 = -3
  223. '
  224. 'L_mult ================
  225. ; actually, (a * b) << 1
  226. ; assert (a != MIN_WORD && b != MIN_WORD)
  227. ' basic
  228. L_mult 0 0 = 0
  229. L_mult 2 3 = 12
  230. L_mult 4711 5 = 47110
  231. ' negative operands
  232. L_mult -2 3 = -12
  233. L_mult 2 -3 = -12
  234. L_mult -2 -3 = 12
  235. L_mult -4711 5 = -47110
  236. L_mult 4711 -5 = -47110
  237. L_mult -4711 -5 = 47110
  238. ' overflow
  239. L_mult + + = 2147352578
  240. L_mult + -32767 = -2147352578
  241. L_mult -32767 + = -2147352578
  242. L_mult + 2 = 131068
  243. L_mult + 1 = 65534
  244. L_mult 1 + = 65534
  245. L_mult + 0 = 0
  246. L_mult 0 + = 0
  247. '
  248. 'div ================
  249. ; actually, (32767 * a) / b
  250. ; assert (a > 0 && b >= a)
  251. ' basic
  252. div 1 1 = +
  253. div 4711 4711 = +
  254. div 5 10 = 0x4000
  255. div 5 20 = 0x2000
  256. div 5 40 = 0x1000
  257. ' overflow
  258. div + + = +
  259. div 0x4000 + = 0x4000
  260. div 1 + = 1
  261. div 1 2 = 0x4000
  262. '
  263. 'norm ================
  264. ' positive
  265. norm 1 = 30
  266. norm 2 = 29
  267. norm 3 = 29
  268. norm 4 = 28
  269. norm 5 = 28
  270. ; etc, etc...
  271. norm 0x08000000 = 3
  272. norm 0x10000000 = 2
  273. norm 0x20000000 = 1
  274. norm 0x20000001 = 1
  275. norm 0x3fffffff = 1
  276. norm 0x40000000 = 0
  277. norm 0x40000001 = 0
  278. norm 0x4ffffffe = 0
  279. norm ++ = 0
  280. ' negative
  281. norm -1 = 31
  282. norm -2 = 30
  283. norm -3 = 29
  284. norm -4 = 29
  285. norm -5 = 28
  286. ; etc, etc...
  287. norm 0x4fffffff = 0
  288. norm -- = 0
  289. '
  290. '>> ================
  291. ' basic
  292. >> 1 1 = 0
  293. >> 4 2 = 1
  294. >> 0x1100 5 = 0x88
  295. ' negative operand
  296. >> 1 -1 = 2
  297. >> 1 -2 = 4
  298. >> 0x88 -5 = 0x1100
  299. ' overflow
  300. >> -1 4711 = -1
  301. >> 1 4711 = 0
  302. >> -4711 4711 = -1
  303. >> 4711 4711 = 0
  304. >> + 1 = 16383
  305. >> - 1 = -16384
  306. '
  307. 'L_>> ================
  308. ' basic
  309. L_>> 1 1 = 0
  310. L_>> 4 2 = 1
  311. L_>> 0x1100 5 = 0x88
  312. ' negative operand
  313. L_>> 1 -1 = 2
  314. L_>> 1 -2 = 4
  315. L_>> 0x88 -5 = 0x1100
  316. ' overflow
  317. L_>> -1 4711 = -1
  318. L_>> 1 4711 = 0
  319. L_>> -4711 4711 = -1
  320. L_>> 4711 4711 = 0
  321. L_>> ++ 1 = 1073741823
  322. L_>> -- 1 = -1073741824
  323. '
  324. '<< ================
  325. ' basic
  326. << 1 1 = 2
  327. << 4 2 = 16
  328. << 0x0088 5 = 0x1100
  329. ' negative operand
  330. << 1 -1 = 0
  331. << 4 -2 = 1
  332. << 0x1100 -5 = 0x0088
  333. ' overflow
  334. << -1 4711 = 0
  335. << 1 4711 = 0
  336. << -4711 4711 = 0
  337. << 4711 4711 = 0
  338. << 4711 -4711 = 0
  339. << -4711 -4711 = -1
  340. << + 1 = 0xfffe
  341. << -1 1 = 0xfffe
  342. << - 1 = 0
  343. '
  344. 'L_<< ================
  345. ' basic
  346. L_<< 1 1 = 2
  347. L_<< 4 2 = 16
  348. L_<< 0x0088 5 = 0x1100
  349. ' negative operand
  350. L_<< 1 -1 = 0
  351. L_<< 4 -2 = 1
  352. L_<< 0x1100 -5 = 0x0088
  353. ' overflow
  354. L_<< -1 4711 = 0
  355. L_<< 1 4711 = 0
  356. L_<< -4711 4711 = 0
  357. L_<< 4711 4711 = 0
  358. L_<< 4711 -4711 = 0
  359. L_<< -4711 -4711 = -1
  360. L_<< ++ 1 = -2
  361. L_<< -1 1 = -2
  362. L_<< -- 1 = 0
  363. 'macros
  364. '
  365. 'add ================
  366. ' basic
  367. M_add 0 0 = 0
  368. M_add 7 4 = 11
  369. M_add 4 6 = 10
  370. M_add 1 1 = 2
  371. ' negative operands
  372. M_add -7 4 = -3
  373. M_add 4 -6 = -2
  374. M_add -1 -3 = -4
  375. M_add 7 -4 = 3
  376. M_add -4 6 = 2
  377. ' positive overflow
  378. ; (max-word = 32767)
  379. M_add + 1 = +
  380. M_add + + = +
  381. M_add -1 + = 32766
  382. M_add 32766 2 = +
  383. M_add 1 32766 = +
  384. ' underflow
  385. ; (min-word = 32768)
  386. M_add - -1 = -
  387. M_add - - = -
  388. M_add 1 - = -32767
  389. M_add -32767 -2 = -
  390. M_add -1 -32766 = -32767
  391. M_add -32767 -1 = -
  392. M_add - + = -1
  393. M_add + - = -1
  394. M_add 0 - = -
  395. M_add 0 + = +
  396. '
  397. 'L_add ================
  398. ' basic
  399. M_L_add 0 0 = 0
  400. M_L_add 7 4 = 11
  401. M_L_add 4 6 = 10
  402. M_L_add 1 1 = 2
  403. ' negative operands
  404. M_L_add -7 4 = -3
  405. M_L_add 4 -6 = -2
  406. M_L_add -1 -3 = -4
  407. M_L_add 7 -4 = 3
  408. M_L_add -4 6 = 2
  409. M_L_add 0 -1 = -1
  410. ' positive overflow
  411. ; (max-longword = 2147483647)
  412. M_L_add ++ 1 = ++
  413. M_L_add ++ ++ = ++
  414. M_L_add -1 ++ = 2147483646
  415. M_L_add 2147483646 2 = ++
  416. M_L_add 1 2147483645 = 2147483646
  417. ' underflow
  418. ; (min-longword = -2147483648)
  419. M_L_add -- -1 = --
  420. M_L_add -- -- = --
  421. M_L_add 1 -- = -2147483647
  422. M_L_add -2147483647 -2 = --
  423. M_L_add -1 -2147483646 = -2147483647
  424. M_L_add -2147483647 -1 = --
  425. M_L_add -- ++ = -1
  426. M_L_add ++ -- = -1
  427. M_L_add 0 -- = --
  428. M_L_add 0 ++ = ++
  429. '
  430. 'sub ================
  431. ' basic
  432. M_sub 0 0 = 0
  433. M_sub 7 4 = 3
  434. M_sub 4 6 = -2
  435. M_sub 1 0 = 1
  436. ' negative operands
  437. M_sub -7 4 = -11
  438. M_sub 4 -6 = 10
  439. M_sub -1 -3 = 2
  440. M_sub 7 -4 = 11
  441. M_sub -4 6 = -10
  442. ' positive overflow
  443. ; (max-word = 32767)
  444. M_sub 1 - = +
  445. M_sub + + = 0
  446. M_sub + 0 = +
  447. M_sub + -1 = +
  448. M_sub + 1 = 32766
  449. M_sub 1 + = -32766
  450. M_sub 0 + = -32767
  451. ' underflow
  452. ; (min-word = 32768)
  453. M_sub - -1 = -32767
  454. M_sub - 1 = -
  455. M_sub - - = 0
  456. M_sub - + = -
  457. M_sub + - = +
  458. M_sub 1 - = +
  459. M_sub -1 - = +
  460. M_sub -32767 2 = -
  461. M_sub 0 - = +
  462. '
  463. '
  464. 'abs ================
  465. ' basic
  466. M_abs 0 = 0
  467. M_abs 2 = 2
  468. M_abs -459 = 459
  469. ' overflow
  470. M_abs + = +
  471. M_abs - = +
  472. M_abs -32767 = +
  473. M_abs 32766 = 32766
  474. M_abs -32766 = 32766
  475. '
  476. 'mult ================
  477. ; actually, a * b >> 15
  478. ' basic
  479. M_mult 0 0 = 0
  480. M_mult 0x100 0x100 = 2
  481. M_mult 4711 0x4000 = 2355
  482. ' negative operands
  483. M_mult -1 0 = 0
  484. M_mult -0x100 0x100 = -2
  485. M_mult 0x100 -0x100 = -2
  486. M_mult -0x100 -0x100 = 2
  487. M_mult -4711 0x4000 = -2356
  488. M_mult 4711 -0x4000 = -2356
  489. M_mult -4711 -0x4000 = 2355
  490. ' overflow
  491. M_mult + + = 32766
  492. M_mult + 0x4000 = 0x3fff
  493. M_mult 0x4000 + = 0x3fff
  494. M_mult + 1 = 0
  495. M_mult + 2 = 1
  496. M_mult + 3 = 2
  497. ' underflow
  498. ; M_mult - - = + assert !(a == b && b == MIN_WORD)
  499. M_mult - -32767 = +
  500. M_mult -32767 - = +
  501. M_mult - + = -32767
  502. M_mult + - = -32767
  503. M_mult - 1 = -1
  504. M_mult - 2 = -2
  505. M_mult - 3 = -3
  506. '
  507. 'mult_r ================
  508. ; actually, (a * b + 16384) >> 15
  509. ' basic
  510. M_mult_r 0 0 = 0
  511. M_mult_r 0x100 0x100 = 2
  512. M_mult_r 4711 0x4000 = 2356
  513. ' negative operands
  514. M_mult_r -1 0 = 0
  515. M_mult_r -0x100 0x100 = -2
  516. M_mult_r 0x100 -0x100 = -2
  517. M_mult_r -0x100 -0x100 = 2
  518. M_mult_r -4711 0x4000 = -2355
  519. M_mult_r 4711 -0x4000 = -2355
  520. M_mult_r -4711 -0x4000 = 2356
  521. ' overflow
  522. M_mult_r + + = 32766
  523. M_mult_r + 32766 = 32765
  524. M_mult_r 32766 + = 32765
  525. M_mult_r + 0x4000 = 0x4000
  526. M_mult_r 0x4000 + = 0x4000
  527. M_mult_r + 0x4001 = 0x4000
  528. M_mult_r 0x4001 + = 0x4000
  529. M_mult_r + 2 = 2
  530. M_mult_r + 1 = 1
  531. M_mult_r 1 + = 1
  532. M_mult_r + 0 = 0
  533. M_mult_r 0 + = 0
  534. ' underflow
  535. ; M_mult_r - - = + assert !(a == b && b == MIN_WORD)
  536. M_mult_r - -32767 = +
  537. M_mult_r -32767 - = +
  538. M_mult_r - + = -32767
  539. M_mult_r + - = -32767
  540. M_mult_r - 1 = -1
  541. M_mult_r - 2 = -2
  542. M_mult_r - 3 = -3
  543. '
  544. 'L_mult ================
  545. ; actually, (a * b) << 1
  546. ; assert (a != MIN_WORD && b != MIN_WORD)
  547. ' basic
  548. M_L_mult 0 0 = 0
  549. M_L_mult 2 3 = 12
  550. M_L_mult 4711 5 = 47110
  551. ' negative operands
  552. M_L_mult -2 3 = -12
  553. M_L_mult 2 -3 = -12
  554. M_L_mult -2 -3 = 12
  555. M_L_mult -4711 5 = -47110
  556. M_L_mult 4711 -5 = -47110
  557. M_L_mult -4711 -5 = 47110
  558. ' overflow
  559. M_L_mult + + = 2147352578
  560. M_L_mult + -32767 = -2147352578
  561. M_L_mult -32767 + = -2147352578
  562. M_L_mult + 2 = 131068
  563. M_L_mult + 1 = 65534
  564. M_L_mult 1 + = 65534
  565. M_L_mult + 0 = 0
  566. M_L_mult 0 + = 0