fc4_delete.awl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. FUNCTION FC 1 : VOID
  2. BEGIN
  3. // Check negative #L.
  4. CALL "_STR_PRESET" (
  5. STARTVAL := 0,
  6. COUNT := 10,
  7. STR := DB1.STR0,
  8. )
  9. CALL "_STR_PRESET" (
  10. STARTVAL := 1,
  11. COUNT := 10,
  12. STR := DB1.STR1,
  13. )
  14. CALL "DELETE" (
  15. IN := DB1.STR0,
  16. L := -1,
  17. P := 1,
  18. RET_VAL := DB1.STR1,
  19. )
  20. __ASSERT== __STW BIE, 0
  21. LAR1 P#DB1.STR1
  22. AUF DB 1
  23. L B [AR1, P#0.0]
  24. __ASSERT== __ACCU 1, 10 // max-len
  25. L B [AR1, P#1.0]
  26. __ASSERT== __ACCU 1, 0 // act-len
  27. CALL "_CHK_MAGIC" (
  28. RET_VAL := M 0.0
  29. )
  30. __ASSERT== M 0.0, 1
  31. // Check negative #P.
  32. CALL "_STR_PRESET" (
  33. STARTVAL := 2,
  34. COUNT := 10,
  35. STR := DB1.STR0,
  36. )
  37. CALL "_STR_PRESET" (
  38. STARTVAL := 3,
  39. COUNT := 10,
  40. STR := DB1.STR1,
  41. )
  42. CALL "DELETE" (
  43. IN := DB1.STR0,
  44. L := 1,
  45. P := -1,
  46. RET_VAL := DB1.STR1,
  47. )
  48. __ASSERT== __STW BIE, 0
  49. LAR1 P#DB1.STR1
  50. AUF DB 1
  51. L B [AR1, P#0.0]
  52. __ASSERT== __ACCU 1, 10 // max-len
  53. L B [AR1, P#1.0]
  54. __ASSERT== __ACCU 1, 0 // act-len
  55. CALL "_CHK_MAGIC" (
  56. RET_VAL := M 0.0
  57. )
  58. __ASSERT== M 0.0, 1
  59. // Check zero #L.
  60. // (This copies the whole string)
  61. CALL "_STR_PRESET" (
  62. STARTVAL := 42,
  63. COUNT := 10,
  64. STR := DB1.STR0,
  65. )
  66. CALL "_STR_PRESET" (
  67. STARTVAL := 142,
  68. COUNT := 10,
  69. STR := DB1.STR1,
  70. )
  71. CALL "DELETE" (
  72. IN := DB1.STR0,
  73. L := 0,
  74. P := 1,
  75. RET_VAL := DB1.STR1,
  76. )
  77. __ASSERT== __STW BIE, 1
  78. LAR1 P#DB1.STR1
  79. AUF DB 1
  80. L B [AR1, P#0.0]
  81. __ASSERT== __ACCU 1, 10 // max-len
  82. L B [AR1, P#1.0]
  83. __ASSERT== __ACCU 1, 10 // act-len
  84. CALL "_STR_CHECK" (
  85. STR := DB1.STR1,
  86. STARTVAL := 42,
  87. OFFSET := 0,
  88. COUNT := 10,
  89. RET_VAL := M 0.0,
  90. )
  91. __ASSERT== M 0.0, 1
  92. CALL "_CHK_MAGIC" (
  93. RET_VAL := M 0.0
  94. )
  95. __ASSERT== M 0.0, 1
  96. // Check zero #P.
  97. // (This copies the whole string)
  98. CALL "_STR_PRESET" (
  99. STARTVAL := 42,
  100. COUNT := 10,
  101. STR := DB1.STR0,
  102. )
  103. CALL "_STR_PRESET" (
  104. STARTVAL := 142,
  105. COUNT := 10,
  106. STR := DB1.STR1,
  107. )
  108. CALL "DELETE" (
  109. IN := DB1.STR0,
  110. L := 1,
  111. P := 0,
  112. RET_VAL := DB1.STR1,
  113. )
  114. __ASSERT== __STW BIE, 1
  115. LAR1 P#DB1.STR1
  116. AUF DB 1
  117. L B [AR1, P#0.0]
  118. __ASSERT== __ACCU 1, 10 // max-len
  119. L B [AR1, P#1.0]
  120. __ASSERT== __ACCU 1, 10 // act-len
  121. CALL "_STR_CHECK" (
  122. STR := DB1.STR1,
  123. STARTVAL := 42,
  124. OFFSET := 0,
  125. COUNT := 10,
  126. RET_VAL := M 0.0,
  127. )
  128. __ASSERT== M 0.0, 1
  129. CALL "_CHK_MAGIC" (
  130. RET_VAL := M 0.0
  131. )
  132. __ASSERT== M 0.0, 1
  133. // Check #P bigger than act-len of #IN.
  134. // (This copies the whole string)
  135. CALL "_STR_PRESET" (
  136. STARTVAL := 42,
  137. COUNT := 10,
  138. STR := DB1.STR0,
  139. )
  140. CALL "_STR_PRESET" (
  141. STARTVAL := 142,
  142. COUNT := 10,
  143. STR := DB1.STR1,
  144. )
  145. CALL "DELETE" (
  146. IN := DB1.STR0,
  147. L := 1,
  148. P := 11,
  149. RET_VAL := DB1.STR1,
  150. )
  151. __ASSERT== __STW BIE, 1
  152. LAR1 P#DB1.STR1
  153. AUF DB 1
  154. L B [AR1, P#0.0]
  155. __ASSERT== __ACCU 1, 10 // max-len
  156. L B [AR1, P#1.0]
  157. __ASSERT== __ACCU 1, 10 // act-len
  158. CALL "_STR_CHECK" (
  159. STR := DB1.STR1,
  160. STARTVAL := 42,
  161. OFFSET := 0,
  162. COUNT := 10,
  163. RET_VAL := M 0.0,
  164. )
  165. __ASSERT== M 0.0, 1
  166. CALL "_CHK_MAGIC" (
  167. RET_VAL := M 0.0
  168. )
  169. __ASSERT== M 0.0, 1
  170. // Delete characters from the start of #IN.
  171. CALL "_STR_PRESET" (
  172. STARTVAL := 42,
  173. COUNT := 10,
  174. STR := DB1.STR0,
  175. )
  176. CALL "_STR_PRESET" (
  177. STARTVAL := 142,
  178. COUNT := 10,
  179. STR := DB1.STR1,
  180. )
  181. CALL "DELETE" (
  182. IN := DB1.STR0,
  183. L := 5,
  184. P := 1,
  185. RET_VAL := DB1.STR1,
  186. )
  187. __ASSERT== __STW BIE, 1
  188. LAR1 P#DB1.STR1
  189. AUF DB 1
  190. L B [AR1, P#0.0]
  191. __ASSERT== __ACCU 1, 10 // max-len
  192. L B [AR1, P#1.0]
  193. __ASSERT== __ACCU 1, 5 // act-len
  194. CALL "_STR_CHECK" (
  195. STR := DB1.STR1,
  196. STARTVAL := 47,
  197. OFFSET := 0,
  198. COUNT := 5,
  199. RET_VAL := M 0.0,
  200. )
  201. __ASSERT== M 0.0, 1
  202. CALL "_STR_CHECK" (
  203. STR := DB1.STR1,
  204. STARTVAL := 147,
  205. OFFSET := 5,
  206. COUNT := 5,
  207. RET_VAL := M 0.0,
  208. )
  209. __ASSERT== M 0.0, 1
  210. CALL "_CHK_MAGIC" (
  211. RET_VAL := M 0.0
  212. )
  213. __ASSERT== M 0.0, 1
  214. // Delete characters in the middle of #IN.
  215. CALL "_STR_PRESET" (
  216. STARTVAL := 42,
  217. COUNT := 10,
  218. STR := DB1.STR0,
  219. )
  220. CALL "_STR_PRESET" (
  221. STARTVAL := 142,
  222. COUNT := 10,
  223. STR := DB1.STR1,
  224. )
  225. CALL "DELETE" (
  226. IN := DB1.STR0,
  227. L := 5,
  228. P := 3,
  229. RET_VAL := DB1.STR1,
  230. )
  231. __ASSERT== __STW BIE, 1
  232. LAR1 P#DB1.STR1
  233. AUF DB 1
  234. L B [AR1, P#0.0]
  235. __ASSERT== __ACCU 1, 10 // max-len
  236. L B [AR1, P#1.0]
  237. __ASSERT== __ACCU 1, 5 // act-len
  238. CALL "_STR_CHECK" (
  239. STR := DB1.STR1,
  240. STARTVAL := 42,
  241. OFFSET := 0,
  242. COUNT := 2,
  243. RET_VAL := M 0.0,
  244. )
  245. __ASSERT== M 0.0, 1
  246. CALL "_STR_CHECK" (
  247. STR := DB1.STR1,
  248. STARTVAL := 49,
  249. OFFSET := 2,
  250. COUNT := 3,
  251. RET_VAL := M 0.0,
  252. )
  253. __ASSERT== M 0.0, 1
  254. CALL "_STR_CHECK" (
  255. STR := DB1.STR1,
  256. STARTVAL := 147,
  257. OFFSET := 5,
  258. COUNT := 5,
  259. RET_VAL := M 0.0,
  260. )
  261. __ASSERT== M 0.0, 1
  262. CALL "_CHK_MAGIC" (
  263. RET_VAL := M 0.0
  264. )
  265. __ASSERT== M 0.0, 1
  266. // Check #L bigger than actual length of #IN.
  267. // (This deletes up to the end of the string)
  268. CALL "_STR_PRESET" (
  269. STARTVAL := 42,
  270. COUNT := 10,
  271. STR := DB1.STR0,
  272. )
  273. CALL "_STR_PRESET" (
  274. STARTVAL := 142,
  275. COUNT := 10,
  276. STR := DB1.STR1,
  277. )
  278. CALL "DELETE" (
  279. IN := DB1.STR0,
  280. L := 11,
  281. P := 1,
  282. RET_VAL := DB1.STR1,
  283. )
  284. __ASSERT== __STW BIE, 1
  285. LAR1 P#DB1.STR1
  286. AUF DB 1
  287. L B [AR1, P#0.0]
  288. __ASSERT== __ACCU 1, 10 // max-len
  289. L B [AR1, P#1.0]
  290. __ASSERT== __ACCU 1, 0 // act-len
  291. CALL "_STR_CHECK" (
  292. STR := DB1.STR1,
  293. STARTVAL := 142,
  294. OFFSET := 0,
  295. COUNT := 10,
  296. RET_VAL := M 0.0,
  297. )
  298. __ASSERT== M 0.0, 1
  299. CALL "_CHK_MAGIC" (
  300. RET_VAL := M 0.0
  301. )
  302. __ASSERT== M 0.0, 1
  303. // Check a too big act-len #IN (bigger than #RET_VAL max-len).
  304. // Delete at start of string.
  305. // (Output get truncated to #RET_VAL max-len)
  306. CALL "_STR_PRESET" (
  307. STARTVAL := 42,
  308. COUNT := 254,
  309. STR := DB1.STR2,
  310. )
  311. CALL "_STR_PRESET" (
  312. STARTVAL := 142,
  313. COUNT := 10,
  314. STR := DB1.STR1,
  315. )
  316. CALL "DELETE" (
  317. IN := DB1.STR2,
  318. L := 3,
  319. P := 1,
  320. RET_VAL := DB1.STR1,
  321. )
  322. __ASSERT== __STW BIE, 1
  323. LAR1 P#DB1.STR1
  324. AUF DB 1
  325. L B [AR1, P#0.0]
  326. __ASSERT== __ACCU 1, 10 // max-len
  327. L B [AR1, P#1.0]
  328. __ASSERT== __ACCU 1, 10 // act-len
  329. CALL "_STR_CHECK" (
  330. STR := DB1.STR1,
  331. STARTVAL := 45,
  332. OFFSET := 0,
  333. COUNT := 10,
  334. RET_VAL := M 0.0,
  335. )
  336. __ASSERT== M 0.0, 1
  337. CALL "_CHK_MAGIC" (
  338. RET_VAL := M 0.0
  339. )
  340. __ASSERT== M 0.0, 1
  341. // Check a too big act-len #IN (bigger than #RET_VAL max-len).
  342. // Delete in center of string.
  343. // (Output get truncated to #RET_VAL max-len)
  344. CALL "_STR_PRESET" (
  345. STARTVAL := 42,
  346. COUNT := 254,
  347. STR := DB1.STR2,
  348. )
  349. CALL "_STR_PRESET" (
  350. STARTVAL := 142,
  351. COUNT := 10,
  352. STR := DB1.STR1,
  353. )
  354. CALL "DELETE" (
  355. IN := DB1.STR2,
  356. L := 3,
  357. P := 3,
  358. RET_VAL := DB1.STR1,
  359. )
  360. __ASSERT== __STW BIE, 1
  361. LAR1 P#DB1.STR1
  362. AUF DB 1
  363. L B [AR1, P#0.0]
  364. __ASSERT== __ACCU 1, 10 // max-len
  365. L B [AR1, P#1.0]
  366. __ASSERT== __ACCU 1, 10 // act-len
  367. CALL "_STR_CHECK" (
  368. STR := DB1.STR1,
  369. STARTVAL := 42,
  370. OFFSET := 0,
  371. COUNT := 2,
  372. RET_VAL := M 0.0,
  373. )
  374. __ASSERT== M 0.0, 1
  375. CALL "_STR_CHECK" (
  376. STR := DB1.STR1,
  377. STARTVAL := 47,
  378. OFFSET := 2,
  379. COUNT := 8,
  380. RET_VAL := M 0.0,
  381. )
  382. __ASSERT== M 0.0, 1
  383. CALL "_CHK_MAGIC" (
  384. RET_VAL := M 0.0
  385. )
  386. __ASSERT== M 0.0, 1
  387. // Check a too big act-len #IN (bigger than #RET_VAL max-len).
  388. // Delete up to the end of the copy range.
  389. // (Output get truncated to #RET_VAL max-len)
  390. CALL "_STR_PRESET" (
  391. STARTVAL := 42,
  392. COUNT := 254,
  393. STR := DB1.STR2,
  394. )
  395. CALL "_STR_PRESET" (
  396. STARTVAL := 142,
  397. COUNT := 10,
  398. STR := DB1.STR1,
  399. )
  400. CALL "DELETE" (
  401. IN := DB1.STR2,
  402. L := 3,
  403. P := 8,
  404. RET_VAL := DB1.STR1,
  405. )
  406. __ASSERT== __STW BIE, 1
  407. LAR1 P#DB1.STR1
  408. AUF DB 1
  409. L B [AR1, P#0.0]
  410. __ASSERT== __ACCU 1, 10 // max-len
  411. L B [AR1, P#1.0]
  412. __ASSERT== __ACCU 1, 10 // act-len
  413. CALL "_STR_CHECK" (
  414. STR := DB1.STR1,
  415. STARTVAL := 42,
  416. OFFSET := 0,
  417. COUNT := 7,
  418. RET_VAL := M 0.0,
  419. )
  420. __ASSERT== M 0.0, 1
  421. CALL "_STR_CHECK" (
  422. STR := DB1.STR1,
  423. STARTVAL := 52,
  424. OFFSET := 7,
  425. COUNT := 3,
  426. RET_VAL := M 0.0,
  427. )
  428. __ASSERT== M 0.0, 1
  429. CALL "_CHK_MAGIC" (
  430. RET_VAL := M 0.0
  431. )
  432. __ASSERT== M 0.0, 1
  433. // Check a too big act-len #IN (bigger than #RET_VAL max-len).
  434. // With bigger del range (beyond #RET_VAL size).
  435. // (Output get truncated to #RET_VAL max-len)
  436. CALL "_STR_PRESET" (
  437. STARTVAL := 42,
  438. COUNT := 254,
  439. STR := DB1.STR2,
  440. )
  441. CALL "_STR_PRESET" (
  442. STARTVAL := 142,
  443. COUNT := 10,
  444. STR := DB1.STR1,
  445. )
  446. CALL "DELETE" (
  447. IN := DB1.STR2,
  448. L := 6,
  449. P := 8,
  450. RET_VAL := DB1.STR1,
  451. )
  452. __ASSERT== __STW BIE, 1
  453. LAR1 P#DB1.STR1
  454. AUF DB 1
  455. L B [AR1, P#0.0]
  456. __ASSERT== __ACCU 1, 10 // max-len
  457. L B [AR1, P#1.0]
  458. __ASSERT== __ACCU 1, 10 // act-len
  459. CALL "_STR_CHECK" (
  460. STR := DB1.STR1,
  461. STARTVAL := 42,
  462. OFFSET := 0,
  463. COUNT := 7,
  464. RET_VAL := M 0.0,
  465. )
  466. __ASSERT== M 0.0, 1
  467. CALL "_STR_CHECK" (
  468. STR := DB1.STR1,
  469. STARTVAL := 55,
  470. OFFSET := 7,
  471. COUNT := 3,
  472. RET_VAL := M 0.0,
  473. )
  474. __ASSERT== M 0.0, 1
  475. CALL "_CHK_MAGIC" (
  476. RET_VAL := M 0.0
  477. )
  478. __ASSERT== M 0.0, 1
  479. // Check a too big act-len #IN (bigger than #RET_VAL max-len).
  480. // L/P=0 -> copy full string.
  481. // (Output get truncated to #RET_VAL max-len)
  482. CALL "_STR_PRESET" (
  483. STARTVAL := 42,
  484. COUNT := 11,
  485. STR := DB1.STR4,
  486. )
  487. CALL "_STR_PRESET" (
  488. STARTVAL := 142,
  489. COUNT := 10,
  490. STR := DB1.STR1,
  491. )
  492. CALL "DELETE" (
  493. IN := DB1.STR4,
  494. L := 0,
  495. P := 0,
  496. RET_VAL := DB1.STR1,
  497. )
  498. __ASSERT== __STW BIE, 1
  499. LAR1 P#DB1.STR1
  500. AUF DB 1
  501. L B [AR1, P#0.0]
  502. __ASSERT== __ACCU 1, 10 // max-len
  503. L B [AR1, P#1.0]
  504. __ASSERT== __ACCU 1, 10 // act-len
  505. CALL "_STR_CHECK" (
  506. STR := DB1.STR1,
  507. STARTVAL := 42,
  508. OFFSET := 0,
  509. COUNT := 10,
  510. RET_VAL := M 0.0,
  511. )
  512. __ASSERT== M 0.0, 1
  513. CALL "_CHK_MAGIC" (
  514. RET_VAL := M 0.0
  515. )
  516. __ASSERT== M 0.0, 1
  517. // Check: #IN and #RET_VAL are the same string.
  518. CALL "_STR_PRESET" (
  519. STARTVAL := 42,
  520. COUNT := 10,
  521. STR := DB1.STR0,
  522. )
  523. CALL "DELETE" (
  524. IN := DB1.STR0,
  525. L := 5,
  526. P := 3,
  527. RET_VAL := DB1.STR0,
  528. )
  529. __ASSERT== __STW BIE, 1
  530. LAR1 P#DB1.STR0
  531. AUF DB 1
  532. L B [AR1, P#0.0]
  533. __ASSERT== __ACCU 1, 10 // max-len
  534. L B [AR1, P#1.0]
  535. __ASSERT== __ACCU 1, 5 // act-len
  536. CALL "_STR_CHECK" (
  537. STR := DB1.STR0,
  538. STARTVAL := 42,
  539. OFFSET := 0,
  540. COUNT := 2,
  541. RET_VAL := M 0.0,
  542. )
  543. __ASSERT== M 0.0, 1
  544. CALL "_STR_CHECK" (
  545. STR := DB1.STR0,
  546. STARTVAL := 49,
  547. OFFSET := 2,
  548. COUNT := 3,
  549. RET_VAL := M 0.0,
  550. )
  551. __ASSERT== M 0.0, 1
  552. CALL "_STR_CHECK" (
  553. STR := DB1.STR0,
  554. STARTVAL := 47,
  555. OFFSET := 5,
  556. COUNT := 5,
  557. RET_VAL := M 0.0,
  558. )
  559. __ASSERT== M 0.0, 1
  560. CALL "_CHK_MAGIC" (
  561. RET_VAL := M 0.0
  562. )
  563. __ASSERT== M 0.0, 1
  564. END_FUNCTION
  565. FUNCTION "_STR_PRESET" : VOID
  566. VAR_INPUT
  567. STARTVAL : INT; // The start character value (0-255)
  568. COUNT : INT; // The number of characters to write
  569. END_VAR
  570. VAR_OUTPUT
  571. STR : STRING; // The string to write to
  572. END_VAR
  573. VAR_TEMP
  574. DBNR : INT;
  575. I : INT;
  576. VAL : CHAR;
  577. END_VAR
  578. BEGIN
  579. L P##STR
  580. LAR1
  581. L W [AR1, P#0.0]
  582. T #DBNR
  583. AUF DB [#DBNR]
  584. L D [AR1, P#2.0]
  585. LAR1
  586. L #COUNT
  587. T B [AR1, P#1.0] // Write #STR act-len
  588. +AR1 P#2.0 // Skip max-len/act-len bytes
  589. L #STARTVAL
  590. T #VAL // Init the sequence number
  591. // Generate the sequence and put it into #STR
  592. L 0
  593. T #I
  594. LOP: L #I
  595. L #COUNT
  596. >=I
  597. SPB END
  598. L #VAL
  599. T B [AR1, P#0.0]
  600. + 1
  601. T #VAL
  602. +AR1 P#1.0
  603. L #I
  604. + 1
  605. T #I
  606. SPA LOP
  607. END: NOP 0
  608. END_FUNCTION
  609. FUNCTION "_STR_CHECK" : BOOL
  610. VAR_INPUT
  611. STR : STRING; // The string to check
  612. STARTVAL : INT; // The start character value (0-255)
  613. OFFSET : INT; // The character offset
  614. COUNT : INT; // The number of characters to check.
  615. END_VAR
  616. VAR_TEMP
  617. DBNR : INT;
  618. I : INT;
  619. VAL : CHAR;
  620. END_VAR
  621. BEGIN
  622. L P##STR
  623. LAR1
  624. L W [AR1, P#0.0]
  625. T #DBNR
  626. AUF DB [#DBNR]
  627. L D [AR1, P#2.0]
  628. LAR1
  629. +AR1 P#2.0 // Skip max-len/act-len bytes
  630. L #OFFSET // Skip offset
  631. SLD 3
  632. +AR1
  633. L #STARTVAL
  634. T #VAL // Init the sequence number
  635. // Generate the sequence and check it against #STR
  636. L 0
  637. T #I
  638. LOP: L #I
  639. L #COUNT
  640. >=I
  641. SPB END
  642. L B [AR1, P#0.0]
  643. L #VAL
  644. <>I
  645. SPB ERR
  646. + 1
  647. T #VAL
  648. +AR1 P#1.0
  649. L #I
  650. + 1
  651. T #I
  652. SPA LOP
  653. // Everything is OK
  654. END: SET
  655. = #RET_VAL
  656. BEA
  657. // Sequence mismatch
  658. ERR: CLR
  659. = #RET_VAL
  660. END_FUNCTION
  661. FUNCTION "_CHK_MAGIC" : BOOL
  662. BEGIN
  663. U(
  664. L W#16#1111
  665. L DB1.MAGIC0
  666. ==I
  667. )
  668. U(
  669. L W#16#2222
  670. L DB1.MAGIC1
  671. ==I
  672. )
  673. U(
  674. L W#16#3333
  675. L DB1.MAGIC2
  676. ==I
  677. )
  678. U(
  679. L W#16#4444
  680. L DB1.MAGIC3
  681. ==I
  682. )
  683. U(
  684. L W#16#5555
  685. L DB1.MAGIC4
  686. ==I
  687. )
  688. U(
  689. L W#16#6666
  690. L DB1.MAGIC5
  691. ==I
  692. )
  693. = #RET_VAL
  694. END_FUNCTION
  695. ORGANIZATION_BLOCK OB 1
  696. BEGIN
  697. // Set DB magic values
  698. CALL "_CHK_MAGIC" (
  699. RET_VAL := M 0.0
  700. )
  701. __ASSERT== M 0.0, 0
  702. L W#16#1111
  703. T DB1.MAGIC0
  704. L W#16#2222
  705. T DB1.MAGIC1
  706. L W#16#3333
  707. T DB1.MAGIC2
  708. L W#16#4444
  709. T DB1.MAGIC3
  710. L W#16#5555
  711. T DB1.MAGIC4
  712. L W#16#6666
  713. T DB1.MAGIC5
  714. CALL "_CHK_MAGIC" (
  715. RET_VAL := M 0.0
  716. )
  717. __ASSERT== M 0.0, 1
  718. // Check whether the helpers work correctly.
  719. CALL "_STR_PRESET" (
  720. STARTVAL := 0,
  721. COUNT := 250,
  722. STR := DB1.STR2,
  723. )
  724. CALL "_STR_CHECK" (
  725. STR := DB1.STR2,
  726. STARTVAL := 0,
  727. OFFSET := 0,
  728. COUNT := 254,
  729. RET_VAL := M 0.0,
  730. )
  731. __ASSERT== M 0.0, 0
  732. CALL "_STR_PRESET" (
  733. STARTVAL := 1,
  734. COUNT := 254,
  735. STR := DB1.STR2,
  736. )
  737. CALL "_STR_CHECK" (
  738. STR := DB1.STR2,
  739. STARTVAL := 0,
  740. OFFSET := 0,
  741. COUNT := 254,
  742. RET_VAL := M 0.0,
  743. )
  744. __ASSERT== M 0.0, 0
  745. CALL "_STR_PRESET" (
  746. STARTVAL := 0,
  747. COUNT := 254,
  748. STR := DB1.STR2,
  749. )
  750. CALL "_STR_CHECK" (
  751. STR := DB1.STR2,
  752. STARTVAL := 0,
  753. OFFSET := 0,
  754. COUNT := 254,
  755. RET_VAL := M 0.0,
  756. )
  757. __ASSERT== M 0.0, 1
  758. CALL "_STR_CHECK" (
  759. STR := DB1.STR2,
  760. STARTVAL := 11,
  761. OFFSET := 11,
  762. COUNT := 243,
  763. RET_VAL := M 0.0,
  764. )
  765. __ASSERT== M 0.0, 1
  766. CALL "_CHK_MAGIC" (
  767. RET_VAL := M 0.0
  768. )
  769. __ASSERT== M 0.0, 1
  770. // Run the actual tests
  771. CALL FC 1
  772. CALL SFC 46 // Stop CPU
  773. END_ORGANIZATION_BLOCK
  774. DATA_BLOCK DB 1
  775. STRUCT
  776. MAGIC0 : WORD;
  777. STR0 : STRING[10];
  778. MAGIC1 : WORD;
  779. STR1 : STRING[10];
  780. MAGIC2 : WORD;
  781. STR2 : STRING[254];
  782. MAGIC3 : WORD;
  783. STR3 : STRING[254];
  784. MAGIC4 : WORD;
  785. STR4 : STRING[11];
  786. MAGIC5 : WORD;
  787. END_STRUCT;
  788. BEGIN
  789. END_DATA_BLOCK