immediates.awl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ORGANIZATION_BLOCK OB 1
  2. BEGIN
  3. // Test DB1.DT1 initial values
  4. AUF DB 1
  5. LAR1 P#DBX 0.0
  6. L B [AR1, P#0.0]
  7. __ASSERT== __ACCU 1, B#16#91
  8. L B [AR1, P#1.0]
  9. __ASSERT== __ACCU 1, B#16#02
  10. L B [AR1, P#2.0]
  11. __ASSERT== __ACCU 1, B#16#03
  12. L B [AR1, P#3.0]
  13. __ASSERT== __ACCU 1, B#16#04
  14. L B [AR1, P#4.0]
  15. __ASSERT== __ACCU 1, B#16#05
  16. L B [AR1, P#5.0]
  17. __ASSERT== __ACCU 1, B#16#06
  18. L B [AR1, P#6.0]
  19. __ASSERT== __ACCU 1, B#16#78
  20. L B [AR1, P#7.0]
  21. __ASSERT== __ACCU 1, B#16#91
  22. // Test DB1.DT2 initial values
  23. AUF DB 1
  24. LAR1 P#DBX 8.0
  25. L B [AR1, P#0.0]
  26. __ASSERT== __ACCU 1, B#16#10
  27. L B [AR1, P#1.0]
  28. __ASSERT== __ACCU 1, B#16#11
  29. L B [AR1, P#2.0]
  30. __ASSERT== __ACCU 1, B#16#12
  31. L B [AR1, P#3.0]
  32. __ASSERT== __ACCU 1, B#16#13
  33. L B [AR1, P#4.0]
  34. __ASSERT== __ACCU 1, B#16#14
  35. L B [AR1, P#5.0]
  36. __ASSERT== __ACCU 1, B#16#15
  37. L B [AR1, P#6.0]
  38. __ASSERT== __ACCU 1, B#16#16
  39. L B [AR1, P#7.0]
  40. __ASSERT== __ACCU 1, B#16#06
  41. // Test DATE immediates
  42. L D#1990-1-1
  43. __ASSERT== __ACCU 1, 0
  44. L DATE#1990-1-1
  45. __ASSERT== __ACCU 1, 0
  46. L D#2000-12-31
  47. __ASSERT== __ACCU 1, 4017
  48. L DATE#2000-12-31
  49. __ASSERT== __ACCU 1, 4017
  50. L D#2100-12-31
  51. __ASSERT== __ACCU 1, L#40541
  52. L DATE#2100-12-31
  53. __ASSERT== __ACCU 1, L#40541
  54. L D#2168-12-31
  55. __ASSERT== __ACCU 1, L#65378
  56. L DATE#2168-12-31
  57. __ASSERT== __ACCU 1, L#65378
  58. // Test DB1.DATEx initial values
  59. L DB1.DBW 16
  60. __ASSERT== __ACCU 1, 4017
  61. L DB1.DBW 18
  62. __ASSERT== __ACCU 1, L#40541
  63. // Test TIME_OF_DAY immediates
  64. L TOD#0:0:0.0
  65. __ASSERT== __ACCU 1, 0
  66. L TIME_OF_DAY#0:0:0.0
  67. __ASSERT== __ACCU 1, 0
  68. L TOD#13:37:13.37
  69. __ASSERT== __ACCU 1, L#49033370
  70. L TIME_OF_DAY#13:37:13.37
  71. __ASSERT== __ACCU 1, L#49033370
  72. L TOD#23:59:59.999
  73. __ASSERT== __ACCU 1, L#86399999
  74. L TIME_OF_DAY#23:59:59.999
  75. __ASSERT== __ACCU 1, L#86399999
  76. // Test DB1.TODx initial values
  77. L DB1.DBD 20
  78. __ASSERT== __ACCU 1, L#86399999
  79. L DB1.DBD 24
  80. __ASSERT== __ACCU 1, L#49033370
  81. // Test TIME immediates
  82. L T#2d
  83. __ASSERT== __ACCU 1, L#172800000
  84. L T#1s100ms
  85. __ASSERT== __ACCU 1, 1100
  86. L TIME#1s100ms
  87. __ASSERT== __ACCU 1, 1100
  88. L T#-1s100ms
  89. __ASSERT== __ACCU 1, L#-1100
  90. L TIME#2s_400ms // Underscore separators
  91. __ASSERT== __ACCU 1, 2400
  92. L TIME#__2_s__400__ms__ // Awlsim extension: arbitrary underscores
  93. __ASSERT== __ACCU 1, 2400
  94. // Test S5T immediates
  95. L S5T#1H
  96. __ASSERT== __ACCU 1, W#16#3360
  97. L S5T#2h
  98. __ASSERT== __ACCU 1, W#16#3720
  99. L S5T#2M
  100. __ASSERT== __ACCU 1, W#16#2120
  101. L S5T#3S
  102. __ASSERT== __ACCU 1, W#16#0300
  103. L S5T#400MS
  104. __ASSERT== __ACCU 1, W#16#0040
  105. L S5T#1H2M3S400MS
  106. __ASSERT== __ACCU 1, W#16#3372
  107. L S5T#2M_3S_400MS // Underscore separators
  108. __ASSERT== __ACCU 1, W#16#2123
  109. L S5T#__1_M__2_S__100__MS__ // Awlsim extension: arbitrary underscores
  110. __ASSERT== __ACCU 1, W#16#1621
  111. CALL SFC 46 // STOP CPU
  112. END_ORGANIZATION_BLOCK
  113. DATA_BLOCK DB 1
  114. STRUCT
  115. DT1 : DATE_AND_TIME := DT#1990-1-1-0:0:0.0;
  116. DT2 : DATE_AND_TIME := DT#2010-11-12-13:14:15.16;
  117. DATE1 : DATE := D#2100-12-31;
  118. DATE2 : DATE := D#2100-12-31;
  119. TOD1 : TIME_OF_DAY := TOD#13:37:13.37;
  120. TOD2 : TIME_OF_DAY := TOD#13:37:13.37;
  121. END_STRUCT;
  122. BEGIN
  123. DT1 := DATE_AND_TIME#1991-2-3-4:5:6.789;
  124. DATE1 := D#2000-12-31;
  125. TOD1 := TOD#23:59:59.999;
  126. END_DATA_BLOCK