insn_MISC.awl 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. ORGANIZATION_BLOCK OB 1
  2. BEGIN
  3. // Test: NOPs
  4. BLD 123
  5. NOP 1
  6. NOP 0
  7. // Test: "A" load/store
  8. L DW#16#12345678
  9. T AB 0
  10. T AW 2
  11. T AD 4
  12. L AB 0
  13. __ASSERT== __ACCU 1, DW#16#00000078
  14. L AW 2
  15. __ASSERT== __ACCU 1, DW#16#00005678
  16. L AD 4
  17. __ASSERT== __ACCU 1, DW#16#12345678
  18. // Test: "E" load/store
  19. L DW#16#12345678
  20. T EB 0
  21. T EW 2
  22. T ED 4
  23. L EB 0
  24. __ASSERT== __ACCU 1, DW#16#00000078
  25. L EW 2
  26. __ASSERT== __ACCU 1, DW#16#00005678
  27. L ED 4
  28. __ASSERT== __ACCU 1, DW#16#12345678
  29. // Test: Direct peripheral read
  30. // Note: This test only succeeds on dummy hardware.
  31. L DW#16#87654321
  32. T ED 10
  33. L PEB 10
  34. __ASSERT== __ACCU 1, DW#16#00000087
  35. L PEW 10
  36. __ASSERT== __ACCU 1, DW#16#00008765
  37. L PED 10
  38. __ASSERT== __ACCU 1, DW#16#87654321
  39. // Test; Direct peripheral write
  40. // Note: This test only succeeds on dummy hardware.
  41. L 0
  42. T AD 10
  43. L DW#16#87654321
  44. T PAB 10
  45. L AD 10
  46. __ASSERT== __ACCU 1, DW#16#21000000
  47. L 0
  48. T AD 10
  49. L DW#16#87654321
  50. T PAW 10
  51. L AD 10
  52. __ASSERT== __ACCU 1, DW#16#43210000
  53. L 0
  54. T AD 10
  55. L DW#16#87654321
  56. T PAD 10
  57. L AD 10
  58. __ASSERT== __ACCU 1, DW#16#87654321
  59. // Test: LAR1/LAR2 with immediate pointer
  60. LAR1 P#L 8.7
  61. LAR2 P#L 7.1
  62. __ASSERT== __AR 1, DW#16#86000047
  63. __ASSERT== __AR 2, DW#16#86000039
  64. // Test: LAR1/LAR2 with accu
  65. L P#DBX 8.6
  66. LAR1
  67. L P#DBX 7.0
  68. LAR2
  69. __ASSERT== __AR 1, DW#16#84000046
  70. __ASSERT== __AR 2, DW#16#84000038
  71. // Test: +AR1/+AR2 with immediate pointer
  72. LAR1 P#E 55.6
  73. LAR2 P#A 99.7
  74. __ASSERT== __AR 1, DW#16#810001BE
  75. __ASSERT== __AR 2, DW#16#8200031F
  76. +AR1 P#E 1.0
  77. +AR2 P#A 0.1
  78. __ASSERT== __AR 1, DW#16#810001C6
  79. __ASSERT== __AR 2, DW#16#82000320
  80. // Test: +AR1/+AR2 with accu
  81. LAR1 P#E 55.1
  82. LAR2 P#A 99.2
  83. __ASSERT== __AR 1, DW#16#810001B9
  84. __ASSERT== __AR 2, DW#16#8200031A
  85. L P#M 1.1
  86. +AR1
  87. L P#M 0.2
  88. +AR2
  89. __ASSERT== __AR 1, DW#16#810001C2
  90. __ASSERT== __AR 2, DW#16#8200031C
  91. // Test: TAK
  92. L DW#16#01234567
  93. L DW#16#89ABCDEF
  94. __ASSERT== __ACCU 1, DW#16#89ABCDEF
  95. __ASSERT== __ACCU 2, DW#16#01234567
  96. TAK
  97. __ASSERT== __ACCU 1, DW#16#01234567
  98. __ASSERT== __ACCU 2, DW#16#89ABCDEF
  99. // Test: TAR
  100. L P#M 12.3
  101. LAR1
  102. L P#M 32.1
  103. LAR2
  104. __ASSERT== __AR 1, DW#16#83000063
  105. __ASSERT== __AR 2, DW#16#83000101
  106. TAR
  107. __ASSERT== __AR 1, DW#16#83000101
  108. __ASSERT== __AR 2, DW#16#83000063
  109. // Test: TDB
  110. AUF DB 2
  111. AUF DI 1
  112. __ASSERT== __DBR 1, 2
  113. __ASSERT== __DBR 2, 1
  114. TDB
  115. __ASSERT== __DBR 1, 1
  116. __ASSERT== __DBR 2, 2
  117. // Test: PUSH
  118. L DW#16#01234567
  119. L DW#16#89ABCDEF
  120. __ASSERT== __ACCU 1, DW#16#89ABCDEF
  121. __ASSERT== __ACCU 2, DW#16#01234567
  122. PUSH
  123. __ASSERT== __ACCU 1, DW#16#89ABCDEF
  124. __ASSERT== __ACCU 2, DW#16#89ABCDEF
  125. // Test: POP
  126. L DW#16#01234567
  127. L DW#16#89ABCDEF
  128. __ASSERT== __ACCU 1, DW#16#89ABCDEF
  129. __ASSERT== __ACCU 2, DW#16#01234567
  130. POP
  131. __ASSERT== __ACCU 1, DW#16#01234567
  132. __ASSERT== __ACCU 2, DW#16#01234567
  133. // Test: STW write
  134. __STWRST
  135. L W#16#FFFF
  136. T STW
  137. __ASSERT== __STW 0, 1
  138. __ASSERT== __STW 1, 1
  139. __ASSERT== __STW 2, 1
  140. __ASSERT== __STW 3, 1
  141. __ASSERT== __STW 4, 1
  142. __ASSERT== __STW 5, 1
  143. __ASSERT== __STW 6, 1
  144. __ASSERT== __STW 7, 1
  145. __ASSERT== __STW 8, 1
  146. L 0
  147. T STW
  148. __ASSERT== __STW 0, 0
  149. __ASSERT== __STW 1, 0
  150. __ASSERT== __STW 2, 0
  151. __ASSERT== __STW 3, 0
  152. __ASSERT== __STW 4, 0
  153. __ASSERT== __STW 5, 0
  154. __ASSERT== __STW 6, 0
  155. __ASSERT== __STW 7, 0
  156. __ASSERT== __STW 8, 0
  157. L W#16#AAAA
  158. T STW
  159. __ASSERT== __STW 0, 0
  160. __ASSERT== __STW 1, 1
  161. __ASSERT== __STW 2, 0
  162. __ASSERT== __STW 3, 1
  163. __ASSERT== __STW 4, 0
  164. __ASSERT== __STW 5, 1
  165. __ASSERT== __STW 6, 0
  166. __ASSERT== __STW 7, 1
  167. __ASSERT== __STW 8, 0
  168. L W#16#5555
  169. T STW
  170. __ASSERT== __STW 0, 1
  171. __ASSERT== __STW 1, 0
  172. __ASSERT== __STW 2, 1
  173. __ASSERT== __STW 3, 0
  174. __ASSERT== __STW 4, 1
  175. __ASSERT== __STW 5, 0
  176. __ASSERT== __STW 6, 1
  177. __ASSERT== __STW 7, 0
  178. __ASSERT== __STW 8, 1
  179. // Test B#(...) immediate
  180. L B#(66, 99)
  181. __ASSERT== __ACCU 1, DW#16#00004263
  182. L B#(66, 99, 88, 55)
  183. __ASSERT== __ACCU 1, DW#16#42635837
  184. CALL FB 1, DB 1 (
  185. IN_CHAR := 'x',
  186. OUT_CHAR := MB 0,
  187. )
  188. L MB 0
  189. __ASSERT== __ACCU 1, DW#16#00000044
  190. CALL SFC 46 // STOP CPU
  191. END_ORGANIZATION_BLOCK
  192. FUNCTION_BLOCK FB 1 : VOID
  193. VAR_INPUT
  194. IN_CHAR : CHAR;
  195. END_VAR
  196. VAR_OUTPUT
  197. OUT_CHAR : CHAR;
  198. END_VAR
  199. BEGIN
  200. // Check parameters
  201. L #IN_CHAR
  202. __ASSERT== __ACCU 1, DW#16#00000078
  203. // Test CHAR immediate
  204. L 'ABCD'
  205. __ASSERT== __ACCU 1, DW#16#41424344
  206. L 'ABC'
  207. __ASSERT== __ACCU 1, DW#16#00414243
  208. L 'AB'
  209. __ASSERT== __ACCU 1, DW#16#00004142
  210. L 'A'
  211. __ASSERT== __ACCU 1, DW#16#00000041
  212. L ''
  213. __ASSERT== __ACCU 1, DW#16#00000000
  214. // Output parameter
  215. L 'ABCD'
  216. T #OUT_CHAR
  217. END_FUNCTION_BLOCK
  218. DATA_BLOCK DB 1
  219. FB 1
  220. BEGIN
  221. IN_CHAR := ' ';
  222. OUT_CHAR := ' ';
  223. END_DATA_BLOCK
  224. DATA_BLOCK DB 2
  225. STRUCT
  226. XYZ : INT;
  227. END_STRUCT
  228. BEGIN
  229. END_DATA_BLOCK