stw_operators.awl 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. FUNCTION FC 1 : VOID
  2. BEGIN
  3. // Store the status word in MW 0.
  4. L STW
  5. T MW 0
  6. // Compare U BIE to the actual STW bit.
  7. U BIE
  8. = M 10.0
  9. __ASSERT== M 10.0, M 0.0 // BIE
  10. __ASSERT== M 10.0, __STW BIE
  11. // Compare U OV to the actual STW bit.
  12. U OV
  13. = M 10.0
  14. __ASSERT== M 10.0, M 1.5 // OV
  15. __ASSERT== M 10.0, __STW OV
  16. // Compare U OS to the actual STW bit.
  17. U OS
  18. = M 10.0
  19. __ASSERT== M 10.0, M 1.4 // OS
  20. __ASSERT== M 10.0, __STW OS
  21. // Compare U ==0 to the actual STW bits.
  22. U ==0
  23. = M 10.0
  24. UN M 1.6 // A0
  25. UN M 1.7 // A1
  26. = M 10.1
  27. UN __STW A0
  28. UN __STW A1
  29. = M 10.2
  30. __ASSERT== M 10.0, M 10.1
  31. __ASSERT== M 10.0, M 10.2
  32. // Compare U <>0 to the actual STW bits.
  33. U <>0
  34. = M 10.0
  35. O M 1.6 // A0
  36. O M 1.7 // A1
  37. = M 10.1
  38. O __STW A0
  39. O __STW A1
  40. = M 10.2
  41. __ASSERT== M 10.0, M 10.1
  42. __ASSERT== M 10.0, M 10.2
  43. // Compare U >0 to the actual STW bits.
  44. U >0
  45. = M 10.0
  46. UN M 1.6 // A0
  47. U M 1.7 // A1
  48. = M 10.1
  49. UN __STW A0
  50. U __STW A1
  51. = M 10.2
  52. __ASSERT== M 10.0, M 10.1
  53. __ASSERT== M 10.0, M 10.2
  54. // Compare U <0 to the actual STW bits.
  55. U <0
  56. = M 10.0
  57. U M 1.6 // A0
  58. UN M 1.7 // A1
  59. = M 10.1
  60. U __STW A0
  61. UN __STW A1
  62. = M 10.2
  63. __ASSERT== M 10.0, M 10.1
  64. __ASSERT== M 10.0, M 10.2
  65. // Compare U >=0 to the actual STW bits.
  66. U >=0
  67. = M 10.0
  68. UN M 1.6 // A0
  69. = M 10.1
  70. UN __STW A0
  71. = M 10.2
  72. __ASSERT== M 10.0, M 10.1
  73. __ASSERT== M 10.0, M 10.2
  74. // Compare U <=0 to the actual STW bits.
  75. U <=0
  76. = M 10.0
  77. UN M 1.7 // A1
  78. = M 10.1
  79. UN __STW A1
  80. = M 10.2
  81. __ASSERT== M 10.0, M 10.1
  82. __ASSERT== M 10.0, M 10.2
  83. // Compare U UO to the actual STW bits.
  84. U UO
  85. = M 10.0
  86. U M 1.6 // A0
  87. U M 1.7 // A1
  88. = M 10.1
  89. U __STW A0
  90. U __STW A1
  91. = M 10.2
  92. __ASSERT== M 10.0, M 10.1
  93. __ASSERT== M 10.0, M 10.2
  94. END_FUNCTION
  95. ORGANIZATION_BLOCK OB 1
  96. BEGIN
  97. // Test STW=0
  98. __STWRST
  99. __ASSERT== BIE, 0
  100. __ASSERT== OV, 0
  101. __ASSERT== OS, 0
  102. __ASSERT== ==0, 1
  103. __ASSERT== <>0, 0
  104. __ASSERT== >0, 0
  105. __ASSERT== <0, 0
  106. __ASSERT== >=0, 1
  107. __ASSERT== <=0, 1
  108. __ASSERT== UO, 0
  109. CALL FC 1
  110. // Test zero
  111. __STWRST
  112. L 0
  113. L 0
  114. +I
  115. __ASSERT== BIE, 0
  116. __ASSERT== OV, 0
  117. __ASSERT== OS, 0
  118. __ASSERT== ==0, 1
  119. __ASSERT== <>0, 0
  120. __ASSERT== >0, 0
  121. __ASSERT== <0, 0
  122. __ASSERT== >=0, 1
  123. __ASSERT== <=0, 1
  124. __ASSERT== UO, 0
  125. CALL FC 1
  126. // Test positive
  127. __STWRST
  128. L 0
  129. L 1
  130. +I
  131. __ASSERT== BIE, 0
  132. __ASSERT== OV, 0
  133. __ASSERT== OS, 0
  134. __ASSERT== ==0, 0
  135. __ASSERT== <>0, 1
  136. __ASSERT== >0, 1
  137. __ASSERT== <0, 0
  138. __ASSERT== >=0, 1
  139. __ASSERT== <=0, 0
  140. __ASSERT== UO, 0
  141. CALL FC 1
  142. // Test negative
  143. __STWRST
  144. L 0
  145. L 1
  146. -I
  147. __ASSERT== BIE, 0
  148. __ASSERT== OV, 0
  149. __ASSERT== OS, 0
  150. __ASSERT== ==0, 0
  151. __ASSERT== <>0, 1
  152. __ASSERT== >0, 0
  153. __ASSERT== <0, 1
  154. __ASSERT== >=0, 0
  155. __ASSERT== <=0, 1
  156. __ASSERT== UO, 0
  157. CALL FC 1
  158. // Test overflow (OV)
  159. __STWRST
  160. L 32767
  161. L 1
  162. +I
  163. __ASSERT== BIE, 0
  164. __ASSERT== OV, 1
  165. __ASSERT== OS, 1
  166. __ASSERT== ==0, 0
  167. __ASSERT== <>0, 1
  168. __ASSERT== >0, 0
  169. __ASSERT== <0, 1
  170. __ASSERT== >=0, 0
  171. __ASSERT== <=0, 1
  172. __ASSERT== UO, 0
  173. CALL FC 1
  174. // Test overflow (OS)
  175. __STWRST
  176. L 32767
  177. L 1
  178. +I
  179. L 1
  180. L 2
  181. +I
  182. __ASSERT== BIE, 0
  183. __ASSERT== OV, 0
  184. __ASSERT== OS, 1
  185. __ASSERT== ==0, 0
  186. __ASSERT== <>0, 1
  187. __ASSERT== >0, 1
  188. __ASSERT== <0, 0
  189. __ASSERT== >=0, 1
  190. __ASSERT== <=0, 0
  191. __ASSERT== UO, 0
  192. CALL FC 1
  193. // Test BIE
  194. __STWRST
  195. SET
  196. SAVE
  197. __ASSERT== BIE, 1
  198. __ASSERT== OV, 0
  199. __ASSERT== OS, 0
  200. __ASSERT== ==0, 1
  201. __ASSERT== <>0, 0
  202. __ASSERT== >0, 0
  203. __ASSERT== <0, 0
  204. __ASSERT== >=0, 1
  205. __ASSERT== <=0, 1
  206. __ASSERT== UO, 0
  207. CALL FC 1
  208. // Test division by zero (UO)
  209. __STWRST
  210. L 1
  211. L 0
  212. /I
  213. __ASSERT== BIE, 0
  214. __ASSERT== OV, 1
  215. __ASSERT== OS, 1
  216. __ASSERT== ==0, 0
  217. __ASSERT== <>0, 1
  218. __ASSERT== >0, 0
  219. __ASSERT== <0, 0
  220. __ASSERT== >=0, 0
  221. __ASSERT== <=0, 0
  222. __ASSERT== UO, 1
  223. CALL FC 1
  224. CALL SFC 46 // STOP CPU
  225. END_ORGANIZATION_BLOCK