git @ Cat's Eye Technologies ZOWIE / a227adb
Merge branch 'master' into implement-in-haskell Chris Pressey 5 months ago
4 changed file(s) with 18 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
0 examplePrograms = [
1 {
2 "contents": "; Display the Roman alphabet in reverse, in ZOWIE\n; This example source is in the public domain.\n\nMOV R10, 90 ; initially it's \"Z\"\nMOV R1, R1 ; BEGIN TRANSACTION for \"REPEAT\"\nMOV R0, R10 ; output character\nMOV R8, R10 ; decrement character\nMOV R5, 1\nMOV R10, R8\nMOV R8, R10 ; test if character is above \"@\"\nMOV R5, 64\nMOV R3, R8 ; COMMIT AND REPEAT if non-zero\n",
3 "filename": "chars.zow"
4 },
5 {
6 "contents": "; Compute a factorial, in ZOWIE\n; This example source is in the public domain.\n\n; Expected output is LATIN SMALL LETTER X (Unicode character 120).\n; NOTE: this code is also able to properly compute 0! = 1.\n\nMOV R11, 5 ; let's find 5!\nMOV R10, 1 ; accumulator\n\nMOV R8, R11 ; increase multiplicand\nMOV R4, 1\nMOV R11, R8\n\nMOV R1, R1 ; BEGIN TRANSACTION for \"REPEAT\"\n\nMOV R8, R11 ; decrease multiplicand\nMOV R5, 1\nMOV R11, R8\n\nMOV R1, R1 ; BEGIN TRANSACTION for \"IF\"\n\nMOV R8, R10 ; accumulator\nMOV R6, R11 ; multiplied\nMOV R10, R8\n\nMOV R2, R11 ; COMMIT if multiplicand above zero, or ROLLBACK otherwise\nMOV R3, R11 ; COMMIT AND REPEAT if multiplicand above zero\n\nMOV R0, R10 ; output accumulator (as single Unicode character)\n",
7 "filename": "fact.zow"
8 },
9 {
10 "contents": "; Hello, world! in ZOWIE\n; This example source is in the public domain.\n\nMOV R0, 72\nMOV R0, 101\nMOV R0, 108\nMOV R0, 108\nMOV R0, 111\nMOV R0, 44\nMOV R0, 32\nMOV R0, 119\nMOV R0, 111\nMOV R0, 114\nMOV R0, 108\nMOV R0, 100\nMOV R0, 33\nMOV R0, 10\n",
11 "filename": "hello.zow"
12 }
13 ];
00 ; Compute a factorial, in ZOWIE
11 ; This example source is in the public domain.
22
3 ; Expected output is MODIFIER LETTER TRIANGULAR COLON (Unicode character 720).
3 ; Expected output is LATIN SMALL LETTER X (Unicode character 120).
44 ; NOTE: this code is also able to properly compute 0! = 1.
55
6 MOV R11, 6 ; let's find 6!
6 MOV R11, 5 ; let's find 5!
77 MOV R10, 1 ; accumulator
88
99 MOV R8, R11 ; increase multiplicand
+0
-14
eg/index.js less more
0 examplePrograms = [
1 [
2 "chars.zow",
3 "; Display the Roman alphabet in reverse, in ZOWIE\n; This example source is in the public domain.\n\nMOV R10, 90 ; initially it's \"Z\"\nMOV R1, R1 ; BEGIN TRANSACTION for \"REPEAT\"\nMOV R0, R10 ; output character\nMOV R8, R10 ; decrement character\nMOV R5, 1\nMOV R10, R8\nMOV R8, R10 ; test if character is above \"@\"\nMOV R5, 64\nMOV R3, R8 ; COMMIT AND REPEAT if non-zero\n"
4 ],
5 [
6 "fact.zow",
7 "; Compute a factorial, in ZOWIE\n; This example source is in the public domain.\n\n; Expected output is MODIFIER LETTER TRIANGULAR COLON (Unicode character 720).\n; NOTE: this code is also able to properly compute 0! = 1.\n\nMOV R11, 6 ; let's find 6!\nMOV R10, 1 ; accumulator\n\nMOV R8, R11 ; increase multiplicand\nMOV R4, 1\nMOV R11, R8\n\nMOV R1, R1 ; BEGIN TRANSACTION for \"REPEAT\"\n\nMOV R8, R11 ; decrease multiplicand\nMOV R5, 1\nMOV R11, R8\n\nMOV R1, R1 ; BEGIN TRANSACTION for \"IF\"\n\nMOV R8, R10 ; accumulator\nMOV R6, R11 ; multiplied\nMOV R10, R8\n\nMOV R2, R11 ; COMMIT if multiplicand above zero, or ROLLBACK otherwise\nMOV R3, R11 ; COMMIT AND REPEAT if multiplicand above zero\n\nMOV R0, R10 ; output accumulator (as single Unicode character)\n"
8 ],
9 [
10 "hello.zow",
11 "; Hello, world! in ZOWIE\n; This example source is in the public domain.\n\nMOV R0, 72\nMOV R0, 101\nMOV R0, 108\nMOV R0, 108\nMOV R0, 111\nMOV R0, 44\nMOV R0, 32\nMOV R0, 119\nMOV R0, 111\nMOV R0, 114\nMOV R0, 108\nMOV R0, 100\nMOV R0, 33\nMOV R0, 10\n"
12 ]
13 ];
9494 }
9595 }
9696 for (var i = 0; i < examplePrograms.length; i++) {
97 presetManager.add(examplePrograms[i][0], makeCallback(examplePrograms[i][1]));
97 presetManager.add(examplePrograms[i].filename, makeCallback(examplePrograms[i].contents));
9898 }
99 presetManager.select(examplePrograms[0][0]);
99 presetManager.select("chars.zow");
100100
101101 document.getElementById("run").style.enabled = false;
102102 var zowie_interpreter;