test_big.cmn 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. # big program test, should test if many symbols fit into the symbol table, if
  2. # big addresses in bytecode are handled well etc.
  3. 1
  4. ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ --
  5. ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ --
  6. ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ --
  7. ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ --
  8. ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ --
  9. ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ --
  10. ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ -- ++ --
  11. ^
  12. # push many constants and pop them
  13. 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4
  14. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
  15. 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4
  16. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
  17. # create a few pointers:
  18. ~testVarA ~testVarB ~testVarC ~testVarD ~testVarE ~testVarF ~testVarG
  19. ~testVarH ~testVarI ~testVarJ ~testVarK ~testVarL ~testVarM ~testVarN
  20. ~testVarO ~testVarP ~testVarQ ~testVarR ~testVarS ~testVarT ~testVarU
  21. ~testVarV ~testVarW ~testVarX ~testVarY ~testVarZ
  22. ~bigVar:1000
  23. 999 @'
  24. $>bigVar
  25. 300 $:bigVar
  26. --
  27. .
  28. ^
  29. # create a few functions:
  30. testFuncA: $testVarA + .
  31. testFuncB: $testVarB + .
  32. testFuncC: $testVarC + .
  33. testFuncD: $testVarD + .
  34. testFuncE: $testVarE + .
  35. testFuncF: $testVarF + .
  36. testFuncG: $testVarG + .
  37. testFuncH: $testVarH + .
  38. testFuncI: $testVarI + .
  39. testFuncJ: $testVarJ + .
  40. testFuncK: $testVarK + .
  41. testFuncL: $testVarL + .
  42. testFuncM: $testVarM + .
  43. testFuncN: $testVarN + .
  44. testFuncO: $testVarO + .
  45. testFuncP: $testVarP + .
  46. testFuncQ: $testVarQ + .
  47. testFuncR: $testVarR + .
  48. testFuncS: $testVarS + .
  49. testFuncT: $testVarT + .
  50. testFuncU: $testVarU + .
  51. testFuncV: $testVarV + .
  52. testFuncW: $testVarW + .
  53. testFuncX: $testVarX + .
  54. testFuncY: $testVarY + .
  55. testFuncZ: $testVarZ + .
  56. # random comment random comment random comment random comment random comment #
  57. # random comment random comment random comment random comment random comment #
  58. # random comment random comment random comment random comment random comment #
  59. # random comment random comment random comment random comment random comment #
  60. # random comment random comment random comment random comment random comment #
  61. # random comment random comment random comment random comment random comment #
  62. # random comment random comment random comment random comment random comment #
  63. # random comment random comment random comment random comment random comment #
  64. # random comment random comment random comment random comment random comment #
  65. # random comment random comment random comment random comment random comment #
  66. # random comment random comment random comment random comment random comment #
  67. # random comment random comment random comment random comment random comment #
  68. # random comment random comment random comment random comment random comment #
  69. testChainFunc:
  70. 10
  71. testFuncA testFuncB testFuncC testFuncD testFuncE testFuncF testFuncG
  72. testFuncH testFuncI testFuncJ testFuncK testFuncL testFuncM testFuncN
  73. testFuncO testFuncP testFuncQ testFuncR testFuncS testFuncT testFuncU
  74. testFuncV testFuncW testFuncX testFuncY testFuncZ
  75. .
  76. ~:randomLabel
  77. ~:randomLabel2
  78. ~:randomLabel3
  79. ~:randomLabel4
  80. ~:randomLabel5
  81. testChainFunc # do we survive this?
  82. 0 10 "big program" -->
  83. printNum:
  84. ?'
  85. $0
  86. 0
  87. ><
  88. @' # reverse push the chars
  89. $0
  90. 10
  91. %
  92. "0"
  93. +
  94. ><
  95. 10
  96. /
  97. .
  98. ^
  99. @' # print
  100. ->
  101. .
  102. ^
  103. ; # zero
  104. "0" ->
  105. .
  106. ^
  107. .
  108. PI: 3216 .
  109. sin:
  110. 1 # stack: x sign
  111. $1 0 << ?
  112. ^
  113. -1 * # x *= -1
  114. -1 # sign = -1
  115. .
  116. >< # stack: sign x
  117. 2 PI * % # x %= 2 * PI
  118. $0 PI > ? # x > PI ?
  119. PI - # x -= PI
  120. >< -1 * >< # sign *= -1
  121. .
  122. ~:randomLabelX
  123. PI $1 - * # x *= PI - x
  124. $0 16 * # 16 * x
  125. $1 4 * # 4 * x
  126. 5 PI * PI * # 5 * PI * PI
  127. >< - # 5 * PI * PI - 4 * x
  128. 1024 / # (5 * PI * PI - 4 * x) / 1024
  129. / >< ^ * # (16 * x) / ((5 * PI * PI - 4 * x) / 1024)
  130. .
  131. factorial:
  132. ?'
  133. $0 -- factorial *
  134. ;
  135. ^ 1
  136. .
  137. .
  138. min:
  139. $1 $1 > ?
  140. ><
  141. .
  142. ^
  143. .
  144. average:
  145. + 2 /
  146. .
  147. myFunc: # takes 2 nums, just computes some arbitrary expression
  148. min 10 % factorial 100 average
  149. .
  150. 0 "random expression (should be 53): " -->
  151. 123 654 myFunc printNum 10 ->
  152. # print "ab"s in a weird way:
  153. 100 @'
  154. $0 2 % ?
  155. "a" ->
  156. ;
  157. "b" ->
  158. .
  159. --
  160. .
  161. ^
  162. 10 ->
  163. ~myVar
  164. 300 $:myVar
  165. 1000 @' # apply sine 1000 times
  166. $myVar sin $:myVar
  167. --
  168. .
  169. ^
  170. $myVar
  171. 0 "sine (should be 222): " --> printNum 10 ->
  172. 0 10 "now print 200 in different type envs:" -->
  173. # -------------- ENV 8 ----------------
  174. ~8
  175. ~ptr8_a ~ptr8_b ~ptr8_c ~ptr8_d ~ptr8_e ~ptr8_f ~ptr8_g ~ptr8_h
  176. juggleNumber8:
  177. $:ptr8_a
  178. $ptr8_a $:ptr8_b
  179. $ptr8_b $:ptr8_c
  180. $ptr8_c $:ptr8_d
  181. $ptr8_d $:ptr8_e
  182. $ptr8_e $:ptr8_f
  183. $ptr8_f $:ptr8_g
  184. $ptr8_g $:ptr8_h
  185. $ptr8_h
  186. .
  187. 200 juggleNumber8 >0 printNum 10 ->
  188. 3 @'
  189. $ptr8_a=ptr8_b
  190. ?'
  191. ?'
  192. ?'
  193. ?'
  194. ?'
  195. ?'
  196. 0 10 "good" -->
  197. .
  198. .
  199. .
  200. .
  201. .
  202. .
  203. ^
  204. --
  205. .
  206. ^
  207. @'
  208. !@ # don't execute the following
  209. + + + + + + + + + + + + + + + +
  210. - - - - - - - - - - - - - - - -
  211. * * * * * * * * * * * * * * * *
  212. / / / / / / / / / / / / / / / /
  213. .
  214. # ------------- ENV 16 ----------------
  215. ~16
  216. ~ptr16_a ~ptr16_b ~ptr16_c ~ptr16_d ~ptr16_e ~ptr16_f ~ptr16_g ~ptr16_h
  217. juggleNumber16:
  218. $:ptr16_a
  219. $ptr16_a $:ptr16_b
  220. $ptr16_b $:ptr16_c
  221. $ptr16_c $:ptr16_d
  222. $ptr16_d $:ptr16_e
  223. $ptr16_e $:ptr16_f
  224. $ptr16_f $:ptr16_g
  225. $ptr16_g $:ptr16_h
  226. $ptr16_h
  227. .
  228. 200 juggleNumber16 >0 printNum 10 ->
  229. 3 @'
  230. $ptr16_a=ptr16_b
  231. ?'
  232. ?'
  233. ?'
  234. ?'
  235. ?'
  236. ?'
  237. 0 10 "good" -->
  238. .
  239. .
  240. .
  241. .
  242. .
  243. .
  244. ^
  245. --
  246. .
  247. ^
  248. @'
  249. !@ # don't execute the following
  250. + + + + + + + + + + + + + + + +
  251. - - - - - - - - - - - - - - - -
  252. * * * * * * * * * * * * * * * *
  253. / / / / / / / / / / / / / / / /
  254. .
  255. # ------------- ENV 32 ----------------
  256. ~32
  257. ~ptr32_a ~ptr32_b ~ptr32_c ~ptr32_d ~ptr32_e ~ptr32_f ~ptr32_g ~ptr32_h
  258. juggleNumber32:
  259. $:ptr32_a
  260. $ptr32_a $:ptr32_b
  261. $ptr32_b $:ptr32_c
  262. $ptr32_c $:ptr32_d
  263. $ptr32_d $:ptr32_e
  264. $ptr32_e $:ptr32_f
  265. $ptr32_f $:ptr32_g
  266. $ptr32_g $:ptr32_h
  267. $ptr32_h
  268. .
  269. 200 juggleNumber32 >0 printNum 10 ->
  270. 3 @'
  271. $ptr32_a=ptr32_b
  272. ?'
  273. ?'
  274. ?'
  275. ?'
  276. ?'
  277. ?'
  278. 0 10 "good" -->
  279. .
  280. .
  281. .
  282. .
  283. .
  284. .
  285. ^
  286. --
  287. .
  288. ^
  289. @'
  290. !@ # don't execute the following
  291. + + + + + + + + + + + + + + + +
  292. - - - - - - - - - - - - - - - -
  293. * * * * * * * * * * * * * * * *
  294. / / / / / / / / / / / / / / / /
  295. ??
  296. ? ? ? ? ? ? . . . . . .
  297. .
  298. # -------------- ENV 0 ----------------
  299. ~0
  300. >myEndLabel # skip the following
  301. 0 10 "THIS SHOULDN'T BE PRINTED" -->
  302. @
  303. ?
  304. 1 2 =
  305. ?
  306. @
  307. @
  308. 0 "abcdefghijklmnop" -->
  309. !.
  310. .
  311. !@
  312. .
  313. ++
  314. ;
  315. 7
  316. @@
  317. ?'
  318. ;
  319. @'
  320. !@
  321. .
  322. !@
  323. .
  324. --
  325. .
  326. 0 = ?'
  327. 3 +
  328. .
  329. .
  330. ;
  331. ++
  332. @
  333. ?
  334. ++
  335. ?
  336. ?
  337. ++
  338. .
  339. .
  340. .
  341. @
  342. <-
  343. ++
  344. .
  345. .
  346. .
  347. .
  348. ~:myEndLabel
  349. 0 "another random expression (should be 1280): " -->
  350. 1 2 + 20 * 30 min ++ ++ ++ ++ -- 11 // 20 + 16 *
  351. 3 4 + 12 * 10 min ++ ++ -- ++ -- 12 // 30 + 15 * +
  352. 5 6 + 13 * 20 min -- ++ ++ ++ -- 10 // 31 + 14 * +
  353. printNum 10 ->
  354. testChainFunc # try this again
  355. testChainFunc
  356. testChainFunc
  357. testChainFunc
  358. testChainFunc
  359. testChainFunc
  360. functionWeWontCall:
  361. 123456789
  362. "abcdefghijk"
  363. // || *
  364. ?
  365. @
  366. ?
  367. @@
  368. ?
  369. factorial
  370. # >myEndLabel #
  371. .
  372. .
  373. .
  374. .
  375. .
  376. min
  377. min
  378. testChainFunc
  379. factorial
  380. testFuncA
  381. testFuncB
  382. testFuncC
  383. testFuncD
  384. testFuncE
  385. testFuncF
  386. testFuncG
  387. testFuncH
  388. testFuncI
  389. testFuncJ
  390. testFuncK
  391. average
  392. .
  393. 0 10 "print some letters:" -->
  394. #------------- ENV 8 --------------
  395. ~8
  396. 64 # print 64 "a"s
  397. @@
  398. "a"
  399. ><
  400. --
  401. ?'
  402. ;
  403. !@
  404. .
  405. .
  406. ^
  407. 64 # pop them
  408. @@
  409. ><
  410. ->
  411. --
  412. ?'
  413. ;
  414. !@
  415. .
  416. .
  417. ^
  418. 10 ->
  419. #------------- ENV 16 -------------
  420. ~16
  421. 64 # print 64 "a"s
  422. @@
  423. "a"
  424. ><
  425. --
  426. ?'
  427. ;
  428. !@
  429. .
  430. .
  431. ^
  432. 64 # pop them
  433. @@
  434. ><
  435. ->
  436. --
  437. ?'
  438. ;
  439. !@
  440. .
  441. .
  442. ^
  443. 10 ->
  444. #------------- ENV 32 -------------
  445. ~32
  446. 1 ^ 2 ^ 3 ^ # just push and pop
  447. 4 ^ 5 ^ 6 ^
  448. 7 ^ 8 ^ 9 ^
  449. 64 # print 64 "a"s
  450. @@
  451. "a"
  452. ><
  453. --
  454. ?'
  455. ;
  456. !@
  457. .
  458. .
  459. ^
  460. 64 # pop them
  461. @@
  462. ><
  463. ->
  464. --
  465. ?'
  466. ;
  467. !@
  468. .
  469. .
  470. ^
  471. 10 ->
  472. #------------- ENV 0 --------------
  473. ~0
  474. # some weird expression
  475. +xf +b011 - * 11 / -d02 // 50 + -10 4 %% + 1000 >< / -b100 +x3 != + $0 -1 << +
  476. +b111 |! 1 + 0 1 2 ?? +
  477. isPrime:
  478. $0 1 <=
  479. ?
  480. ^ 0
  481. ;
  482. $0 2 /
  483. @@
  484. $0 1 <=
  485. ?
  486. ^ ^ 1 !@
  487. .
  488. $1 $1 % 0 =
  489. ?
  490. ^ ^ 0 !@
  491. .
  492. --
  493. .
  494. .
  495. .
  496. # push many constants and pop them
  497. 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4
  498. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
  499. 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 1 2 3 4
  500. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
  501. 0 10 "primes from 1000: " -->
  502. 1000 @'
  503. $0 isPrime ?
  504. $0 printNum " " ->
  505. .
  506. --
  507. .
  508. 10 ->
  509. 0 10 "END" -->
  510. !. # now skip everything else
  511. 1 ++ -- * / = + - ?? && || // %% * * * * + + + +
  512. 2 ++ -- * / = + - ?? && || // %% * * * * + + + +
  513. 3 ++ -- * / = + - ?? && || // %% * * * * + + + +
  514. 4 ++ -- * / = + - ?? && || // %% * * * * + + + +
  515. 5 ++ -- * / = + - ?? && || // %% * * * * + + + +
  516. 6 ++ -- * / = + - ?? && || // %% * * * * + + + +
  517. 7 ++ -- * / = + - ?? && || // %% * * * * + + + +
  518. 8 ++ -- * / = + - ?? && || // %% * * * * + + + +
  519. 9 ++ -- * / = + - ?? && || // %% * * * * + + + +
  520. 10 ++ -- * / = + - ?? && || // %% * * * * + + + +
  521. 11 ++ -- * / = + - ?? && || // %% * * * * + + + +
  522. 12 ++ -- * / = + - ?? && || // %% * * * * + + + +
  523. 13 ++ -- * / = + - ?? && || // %% * * * * + + + +
  524. 14 ++ -- * / = + - ?? && || // %% * * * * + + + +
  525. 15 ++ -- * / = + - ?? && || // %% * * * * + + + +
  526. 16 ++ -- * / = + - ?? && || // %% * * * * + + + +
  527. 17 ++ -- * / = + - ?? && || // %% * * * * + + + +
  528. 18 ++ -- * / = + - ?? && || // %% * * * * + + + +
  529. 19 ++ -- * / = + - ?? && || // %% * * * * + + + +
  530. 20 ++ -- * / = + - ?? && || // %% * * * * + + + +
  531. +xbeeface
  532. -b10101
  533. 9999223
  534. "test"
  535. -101010
  536. "test2"
  537. @
  538. ?
  539. ++ --
  540. !@
  541. !.
  542. .
  543. ?'
  544. ?
  545. ++
  546. .
  547. .
  548. .
  549. 0 10 "THIS SHOULDN'T BE PRINTED" -->