insn_Z.awl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ORGANIZATION_BLOCK OB 1
  2. BEGIN
  3. // Test C# immediate
  4. L C#123
  5. __ASSERT== __ACCU 1, 291
  6. // Test down counter (ZR)
  7. CLR
  8. FR Z 10
  9. SET
  10. R Z 10
  11. FR Z 10
  12. U Z 10
  13. __ASSERT== __STW VKE, 0
  14. L C#123
  15. SET
  16. S Z 10
  17. U Z 10
  18. __ASSERT== __STW VKE, 1
  19. CLR
  20. ZR Z 10
  21. U Z 10
  22. __ASSERT== __STW VKE, 1
  23. L Z 10
  24. __ASSERT== __ACCU 1, 123
  25. SET
  26. ZR Z 10
  27. U Z 10
  28. __ASSERT== __STW VKE, 1
  29. L Z 10
  30. __ASSERT== __ACCU 1, 122
  31. CLR
  32. ZR Z 10
  33. U Z 10
  34. __ASSERT== __STW VKE, 1
  35. L Z 10
  36. __ASSERT== __ACCU 1, 122
  37. LC Z 10
  38. __ASSERT== __ACCU 1, C#122
  39. L C#1
  40. CLR
  41. S Z 10
  42. SET
  43. S Z 10
  44. U Z 10
  45. __ASSERT== __STW VKE, 1
  46. L Z 10
  47. __ASSERT== __ACCU 1, 1
  48. CLR
  49. ZR Z 10
  50. U Z 10
  51. __ASSERT== __STW VKE, 1
  52. SET
  53. ZR Z 10
  54. U Z 10
  55. __ASSERT== __STW VKE, 0
  56. L Z 10
  57. __ASSERT== __ACCU 1, 0
  58. CLR
  59. ZR Z 10
  60. U Z 10
  61. __ASSERT== __STW VKE, 0
  62. SET
  63. ZR Z 10
  64. U Z 10
  65. __ASSERT== __STW VKE, 0
  66. L Z 10
  67. __ASSERT== __ACCU 1, 0
  68. // Test up counter (ZV)
  69. CLR
  70. FR Z 10
  71. SET
  72. R Z 10
  73. FR Z 10
  74. U Z 10
  75. __ASSERT== __STW VKE, 0
  76. L C#123
  77. SET
  78. S Z 10
  79. U Z 10
  80. __ASSERT== __STW VKE, 1
  81. CLR
  82. ZV Z 10
  83. U Z 10
  84. __ASSERT== __STW VKE, 1
  85. L Z 10
  86. __ASSERT== __ACCU 1, 123
  87. SET
  88. ZV Z 10
  89. U Z 10
  90. __ASSERT== __STW VKE, 1
  91. L Z 10
  92. __ASSERT== __ACCU 1, 124
  93. CLR
  94. ZV Z 10
  95. U Z 10
  96. __ASSERT== __STW VKE, 1
  97. L Z 10
  98. __ASSERT== __ACCU 1, 124
  99. LC Z 10
  100. __ASSERT== __ACCU 1, C#124
  101. L C#998
  102. CLR
  103. S Z 10
  104. SET
  105. S Z 10
  106. U Z 10
  107. __ASSERT== __STW VKE, 1
  108. L Z 10
  109. __ASSERT== __ACCU 1, 998
  110. CLR
  111. ZV Z 10
  112. U Z 10
  113. __ASSERT== __STW VKE, 1
  114. SET
  115. ZV Z 10
  116. U Z 10
  117. __ASSERT== __STW VKE, 1
  118. L Z 10
  119. __ASSERT== __ACCU 1, 999
  120. CLR
  121. ZV Z 10
  122. U Z 10
  123. __ASSERT== __STW VKE, 1
  124. SET
  125. ZV Z 10
  126. U Z 10
  127. __ASSERT== __STW VKE, 1
  128. L Z 10
  129. __ASSERT== __ACCU 1, 999
  130. // Test FR
  131. CLR
  132. FR Z 10
  133. SET
  134. R Z 10
  135. FR Z 10
  136. U Z 10
  137. __ASSERT== __STW VKE, 0
  138. SET
  139. ZV Z 10
  140. L Z 10
  141. __ASSERT== __ACCU 1, 1
  142. CLR
  143. FR Z 10
  144. SET
  145. FR Z 10
  146. ZV Z 10
  147. L Z 10
  148. __ASSERT== __ACCU 1, 2
  149. ZR Z 10
  150. L Z 10
  151. __ASSERT== __ACCU 1, 1
  152. CLR
  153. FR Z 10
  154. SET
  155. FR Z 10
  156. ZR Z 10
  157. L Z 10
  158. __ASSERT== __ACCU 1, 0
  159. SET
  160. L C#321
  161. S Z 10
  162. L Z 10
  163. __ASSERT== __ACCU 1, 321
  164. CLR
  165. FR Z 10
  166. SET
  167. FR Z 10
  168. L C#123
  169. S Z 10
  170. L Z 10
  171. __ASSERT== __ACCU 1, 123
  172. SET
  173. FR Z 10
  174. L C#888
  175. S Z 10
  176. L Z 10
  177. __ASSERT== __ACCU 1, 123
  178. // Test counter parameter
  179. AUF DB 1
  180. L DBW 0
  181. __ASSERT== __ACCU 1, 24
  182. CALL FB 1, DB 1 (
  183. COUNTER_VAR := Z 42
  184. )
  185. CALL SFC 46 // STOP CPU
  186. END_ORGANIZATION_BLOCK
  187. FUNCTION_BLOCK FB 1
  188. VAR_INPUT
  189. COUNTER_VAR : COUNTER;
  190. END_VAR
  191. BEGIN
  192. L DIW 0
  193. __ASSERT== __ACCU 1, 42
  194. L #COUNTER_VAR
  195. __ASSERT== __ACCU 1, 0
  196. U #COUNTER_VAR
  197. __ASSERT== __STW VKE, 0
  198. SET
  199. ZV Z 42
  200. CLR
  201. ZV Z 42
  202. U #COUNTER_VAR
  203. __ASSERT== __STW VKE, 1
  204. L #COUNTER_VAR
  205. __ASSERT== __ACCU 1, 1
  206. ZV #COUNTER_VAR
  207. ZR #COUNTER_VAR
  208. FR #COUNTER_VAR
  209. END_FUNCTION_BLOCK
  210. DATA_BLOCK DB 1
  211. FB 1
  212. BEGIN
  213. COUNTER_VAR := Z 24;
  214. END_DATA_BLOCK