40bit_ins_test.ds 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. ; This test covers the behavior of 40-bit mode with various instructions.
  2. incdir "tests"
  3. include "dsp_base.inc"
  4. positive_value: EQU #0x1234
  5. negative_value: EQU #0x9876
  6. negative_imem_value_addr:
  7. CW negative_value
  8. ; DSPSpy doesn't pre-populating DMEM currently, so instead use these addresses to store values.
  9. positive_dmem_value_addr: EQU #0x100
  10. negative_dmem_value_addr: EQU #0x101
  11. readback_dmem_addr: EQU #0x102
  12. test_main:
  13. LRI $ar0, #positive_dmem_value_addr
  14. LRI $ar1, #negative_dmem_value_addr
  15. LRI $ar2, #negative_imem_value_addr
  16. LRI $ar3, #readback_dmem_addr
  17. LRI $ix0, #0
  18. LRI $ix1, #0
  19. LRI $ix2, #0
  20. LRI $ix3, #0
  21. LRI $ax0.h, #positive_value
  22. LRI $ax1.h, #negative_value
  23. SR @positive_dmem_value_addr, $ax0.h
  24. SR @negative_dmem_value_addr, $ax1.h
  25. LRI $cr, #(positive_dmem_value_addr / 256)
  26. SET40
  27. ; Instructions that perform sign-extension
  28. ; $acc0 should alternate between being positive and negative here
  29. ; (though none of these instructions update $sr)
  30. ; [1] ILRR (also ILRRD/ILRRI/ILRRN, not covered)
  31. ILRR $ac0.m, @$ar2 ; -
  32. CALL send_back
  33. ; [2] LR
  34. LR $ac0.m, @positive_dmem_value_addr ; +
  35. CALL send_back
  36. ; [3] LRI
  37. LRI $ac0.m, #negative_value ; -
  38. CALL send_back
  39. ; [4] LRIS
  40. LRIS $ac0.m, #42 ; +
  41. CALL send_back
  42. ; [5] LRR (also LRRD/LRRI/LRRN)
  43. LRR $ac0.m, @$ar1 ; -
  44. CALL send_back
  45. ; [6] LRS
  46. LRS $ac0.m, @(positive_dmem_value_addr & 0xff) ; +
  47. CALL send_back
  48. ; [7] MRR
  49. MRR $ac0.m, $ax1.h ; -
  50. CALL send_back
  51. ; [8] 'LN (and 'L, but 'LN lets us set $ix0 to not increment $ar0)
  52. NX'LN : $ac0.m, @$ar0 ; +
  53. CALL send_back
  54. ; Instructions that experience saturation
  55. ; $ax1.l should alternate between 0x8000 and 0x7fff.
  56. LRI $ac0.m, #0x4231
  57. LRI $ac0.h, #0x12 ; positive
  58. LRI $ac1.m, #0x2816
  59. LRI $ac1.h, #0x99 ; negative
  60. ; [9] MRR (again)
  61. MRR $ax1.l, $ac1.m ; -
  62. CALL send_back
  63. ; [10] SR
  64. SR @readback_dmem_addr, $ac0.m
  65. LR $ax1.l, @readback_dmem_addr ; +
  66. CALL send_back
  67. ; [11] SRRN (also SRR/SRRD/SRRI)
  68. SRRN @$ar3, $ac1.m
  69. LR $ax1.l, @readback_dmem_addr ; -
  70. CALL send_back
  71. ; [12] SRS
  72. SRS @(readback_dmem_addr & 0xff), $ac0.m
  73. LR $ax1.l, @readback_dmem_addr ; +
  74. CALL send_back
  75. ; [13] 'LSNM (also 'LS/'LSM/'LSN) - the $ax0.l read is not relevant
  76. NX'LSNM : $ax0.l, $ac1.m
  77. LR $ax1.l, @readback_dmem_addr ; -
  78. CALL send_back
  79. ; [14] 'MV
  80. NX'MV : $ax1.l, $ac0.m ; +
  81. CALL send_back
  82. ; [15] 'SLNM (also 'SL/'SLM/'SLN) - the $ax0.l read is not relevant
  83. ; Note that 'SL stores to @$ar0, while 'LS stores to @$ar3
  84. LRI $ar0, #readback_dmem_addr
  85. NX'SLNM : $ac1.m, $ax0.l
  86. LR $ax1.l, @readback_dmem_addr ; -
  87. CALL send_back
  88. LRI $ar0, #positive_dmem_value_addr
  89. ; [16] 'SN (also 'S)
  90. NX'SN : @$ar3, $ac0.m
  91. LR $ax1.l, @readback_dmem_addr ; +
  92. CALL send_back
  93. ; Instructions that are not affected
  94. ; [17] ADDI
  95. ADDI $ac0.m, #8
  96. CALL send_back
  97. ; [18] ADDIS
  98. ADDIS $ac0.m, #-8
  99. CALL send_back
  100. ; [19] ANDC
  101. ANDC $ac1.m, $ac0.m
  102. CALL send_back
  103. ; [20] ANDI
  104. ANDI $ac0.m, #0x6666
  105. CALL send_back
  106. ; [21] ANDR
  107. ANDR $ac0.m, $ax0.h
  108. CALL send_back
  109. ; [22] ORC
  110. ORC $ac0.m, $ac1.m
  111. CALL send_back
  112. ; [23] ORI
  113. ORI $ac0.m, #0xfeed
  114. CALL send_back
  115. ; [24] ORR
  116. ORR $ac1.m, $ax0.h
  117. CALL send_back
  118. ; [25] NOT
  119. NOT $ac1.m
  120. CALL send_back
  121. ; [26] XORC
  122. XORC $ac0.m, $ac1.m
  123. CALL send_back
  124. ; [27] XORI
  125. XORI $ac0.m, #0x5555
  126. CALL send_back
  127. ; [28] XORR
  128. XORR $ac1.m, $ax1.h
  129. CALL send_back
  130. ; [29] MOVR always sign extends...
  131. MOVR $acc1, $ax0.h
  132. CALL send_back
  133. ; [30] ... even in SET16 mode
  134. SET16
  135. MOVR $acc1, $ax1.h
  136. CALL send_back
  137. SET40
  138. ; Shift instructions - do these see saturated $ac1.m?
  139. LRI $ac0.m, #positive_value
  140. LRI $ac1.m, #2
  141. LRI $ac1.h, #1
  142. ; [31] - for diffs only
  143. CALL send_back
  144. ; [32]
  145. LSRNR $acc0, $ac1.m
  146. CALL send_back
  147. ; [33] Shifts $acc0 by $ac1.m (in the other direction)
  148. LSRN
  149. CALL send_back
  150. ; Does LOOP experience saturation?
  151. CLR $acc0
  152. LRI $ac1.m, #0x1234
  153. LRI $ac1.h, #1
  154. ; [34] - for diffs only
  155. CALL send_back
  156. ; [35] LOOP
  157. LOOP $ac1.m
  158. INC $acc0
  159. CALL send_back
  160. LRI $ac1.h, #0x99
  161. ; [36] BLOOP
  162. BLOOP $ac1.m, bloop_last_ins
  163. INCM $ac0.m
  164. bloop_last_ins:
  165. NOP
  166. CALL send_back
  167. ; For the sake of clarity, the same LOOP/BLOOP calls in SET16 mode don't have saturation:
  168. SET16
  169. CLR $acc0
  170. LRI $ac1.m, #0x1234
  171. LRI $ac1.h, #1
  172. ; [37] - for diffs only
  173. CALL send_back
  174. ; [38] LOOP
  175. LOOP $ac1.m
  176. INC $acc0
  177. CALL send_back
  178. LRI $ac1.h, #0x99
  179. ; [39] BLOOP
  180. BLOOP $ac1.m, bloop2_last_ins
  181. INCM $ac0.m
  182. bloop2_last_ins:
  183. NOP
  184. CALL send_back
  185. ; We're done, DO NOT DELETE THIS LINE
  186. JMP end_of_test