srs_test.ds 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. incdir "tests"
  2. include "dsp_base.inc"
  3. test_main:
  4. ; Test registers used by LRS and SRS
  5. LRI $CR, #0x0000
  6. CALL clear_regs
  7. CALL store_mem_sr
  8. ; Write with SR, read with LR
  9. LRI $AR0, #0xA00A
  10. CALL create_pattern
  11. CALL store_mem_sr
  12. CALL send_back
  13. CALL clear_regs
  14. CALL read_mem_lr
  15. CALL send_back
  16. ; Write with SR, read with LRS
  17. LRI $AR0, #0xB00B
  18. CALL create_pattern
  19. CALL store_mem_sr
  20. CALL send_back
  21. CALL clear_regs
  22. CALL read_mem_lrs
  23. CALL send_back
  24. ; Write with SRS, read with LR
  25. LRI $AR0, #0xC00C
  26. CALL create_pattern
  27. CALL store_mem_srs
  28. CALL send_back
  29. CALL clear_regs
  30. CALL read_mem_lr
  31. CALL send_back
  32. ; Write with SR, read with LRS
  33. LRI $AR0, #0xD00D
  34. CALL create_pattern
  35. CALL store_mem_srs
  36. CALL send_back
  37. CALL clear_regs
  38. CALL read_mem_lrs
  39. CALL send_back
  40. ; We're done, DO NOT DELETE THIS LINE
  41. JMP end_of_test
  42. create_pattern:
  43. LRI $IX0, #0x0110
  44. MRR $AX0.L, $AR0
  45. ADDARN $AR0, $IX0
  46. MRR $AX1.L, $AR0
  47. ADDARN $AR0, $IX0
  48. MRR $AX0.H, $AR0
  49. ADDARN $AR0, $IX0
  50. MRR $AX1.H, $AR0
  51. ADDARN $AR0, $IX0
  52. MRR $AC0.L, $AR0
  53. ADDARN $AR0, $IX0
  54. MRR $AC1.L, $AR0
  55. ADDARN $AR0, $IX0
  56. MRR $AC0.M, $AR0
  57. ADDARN $AR0, $IX0
  58. MRR $AC1.M, $AR0
  59. ADDARN $AR0, $IX0
  60. ; AC0.H and AC1.H have odd results since they're 8-bit sign-extended, but that's fine.
  61. MRR $AC0.H, $AR0
  62. ADDARN $AR0, $IX0
  63. MRR $AC1.H, $AR0
  64. RET
  65. clear_regs:
  66. LRI $AX0.L, #0x0000
  67. LRI $AX1.L, #0x0000
  68. LRI $AX0.H, #0x0000
  69. LRI $AX1.H, #0x0000
  70. LRI $AC0.L, #0x0000
  71. LRI $AC1.L, #0x0000
  72. LRI $AC0.M, #0x0000
  73. LRI $AC1.M, #0x0000
  74. LRI $AC0.H, #0x0000
  75. LRI $AC1.H, #0x0000
  76. RET
  77. read_mem_lr:
  78. LR $AX0.L, @0x0000
  79. LR $AX1.L, @0x0001
  80. LR $AX0.H, @0x0002
  81. LR $AX1.H, @0x0003
  82. LR $AC0.L, @0x0004
  83. LR $AC1.L, @0x0005
  84. LR $AC0.M, @0x0006
  85. LR $AC1.M, @0x0007
  86. RET
  87. read_mem_lrs:
  88. LRS $AX0.L, @0x00
  89. LRS $AX1.L, @0x01
  90. LRS $AX0.H, @0x02
  91. LRS $AX1.H, @0x03
  92. LRS $AC0.L, @0x04
  93. LRS $AC1.L, @0x05
  94. LRS $AC0.M, @0x06
  95. LRS $AC1.M, @0x07
  96. RET
  97. store_mem_sr:
  98. SR @0x0000, $AX0.L
  99. SR @0x0001, $AX1.L
  100. SR @0x0002, $AX0.H
  101. SR @0x0003, $AX1.H
  102. SR @0x0004, $AC0.L
  103. SR @0x0005, $AC1.L
  104. SR @0x0006, $AC0.M
  105. SR @0x0007, $AC1.M
  106. RET
  107. store_mem_srs:
  108. ; For future compatibility these have been changed to cw.
  109. ; The way the instructions were originally encoded is commented,
  110. ; but this does not match their behavior.
  111. cw 0x2800 ; SRS @0x00, $AX0.L - actually SRSH @0x00, $AC0.H
  112. cw 0x2901 ; SRS @0x01, $AX1.L - actually SRSH @0x01, $AC1.H
  113. cw 0x2A02 ; SRS @0x02, $AX0.H - actually unknown, no store performed
  114. cw 0x2B03 ; SRS @0x03, $AX1.H - actually unknown, no store performed
  115. cw 0x2C04 ; SRS @0x04, $AC0.L
  116. cw 0x2D05 ; SRS @0x05, $AC1.L
  117. cw 0x2E06 ; SRS @0x06, $AC0.M
  118. cw 0x2F07 ; SRS @0x07, $AC1.M
  119. RET