diff --git a/doc/Nga.md b/doc/Nga.md index 1b98749..130ced6 100644 --- a/doc/Nga.md +++ b/doc/Nga.md @@ -29,7 +29,7 @@ executed. Instruction processing: the **IP** is incremented and the opcode at the current address is invoked. This process then repeats. Execution ends -if the **END** instruction is run or end of memory is reached. +if the **HALT** instruction is run or end of memory is reached. Endian: the image files are stored in little endian format. @@ -104,7 +104,7 @@ corresponding values (in decimal): 2 dup 9 ccall 16 store 23 xor 3 drop 10 return 17 add 24 shift 4 swap 11 eq 18 sub 25 zret - 5 push 12 neq 19 mul 26 end + 5 push 12 neq 19 mul 26 halt 6 pop 13 lt 20 divmod 27 io enumerate ~~~ @@ -112,7 +112,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IO_ENUM, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IO_ENUM, VM_IO_QUERY, VM_IO_INTERACT }; #define NUM_OPS VM_IO_INTERACT + 1 @@ -333,7 +333,7 @@ Example: ccall li f call - end + halt ~~~ void inst_ccall() { @@ -622,10 +622,10 @@ void inst_zret() { } ~~~ -**END** tells Nga that execution should end. +**HALT** tells Nga that execution should end. ~~~ -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } ~~~ @@ -677,7 +677,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; ~~~ diff --git a/doc/book/Programming-Techniques-Working-With-Assembly b/doc/book/Programming-Techniques-Working-With-Assembly index ffc531d..9ae1342 100644 --- a/doc/book/Programming-Techniques-Working-With-Assembly +++ b/doc/book/Programming-Techniques-Working-With-Assembly @@ -47,7 +47,7 @@ gets a two character identifier. From the list of instructions: 0 nop 5 push 10 ret 15 fetch 20 div 25 zret - 1 lit 6 pop 11 eq 16 store 21 and 26 end + 1 lit 6 pop 11 eq 16 store 21 and 26 halt 2 dup 7 jump 12 neq 17 add 22 or 27 ienum 3 drop 8 call 13 lt 18 sub 23 xor 28 iquery 4 swap 9 ccall 14 gt 19 mul 24 shift 29 iinvoke @@ -55,7 +55,7 @@ From the list of instructions: This reduces to: 0 .. 5 pu 10 re 15 fe 20 di 25 zr - 1 li 6 po 11 eq 16 st 21 an 26 en + 1 li 6 po 11 eq 16 st 21 an 26 ha 2 du 7 ju 12 ne 17 ad 22 or 27 ie 3 dr 8 ca 13 lt 18 su 23 xo 28 iq 4 sw 9 cc 14 gt 19 mu 24 sh 29 ii diff --git a/example/retro-muri.retro b/example/retro-muri.retro index f6ec5df..1776684 100755 --- a/example/retro-muri.retro +++ b/example/retro-muri.retro @@ -25,7 +25,7 @@ instruction name. For a non operation, use '..' instead of 'no'. 0 nop 5 push 10 ret 15 fetch 20 div 25 zret - 1 lit 6 pop 11 eq 16 store 21 and 26 end + 1 lit 6 pop 11 eq 16 store 21 and 26 halt 2 dup 7 jump 12 neq 17 add 22 or 27 ienum 3 drop 8 call 13 lt 18 sub 23 xor 28 iquery 4 swap 9 ccall 14 gt 19 mul 24 shift 29 iinvoke @@ -44,7 +44,7 @@ An example of a small program: i lilica.. d 12 r square - i en...... + i ha...... As mentioned earlier this requires knowledge of Nga architecture. While you can pack up to four instructions per location, you diff --git a/image/rx.muri b/image/rx.muri index f88c0ec..38b6b84 100644 --- a/image/rx.muri +++ b/image/rx.muri @@ -27,7 +27,7 @@ architecture. There are 30 instructions, with up to four packed into each memory location (*cell*). The instructions are: 0 nop 5 push 10 ret 15 fetch 20 div 25 zret - 1 lit 6 pop 11 eq 16 store 21 and 26 end + 1 lit 6 pop 11 eq 16 store 21 and 26 halt 2 dup 7 jump 12 neq 17 add 22 or 27 ienum 3 drop 8 call 13 lt 18 sub 23 xor 28 iquery 4 swap 9 ccall 14 gt 19 mul 24 shift 29 iinvoke @@ -1257,7 +1257,7 @@ for references to named functions. ~~~ : Instructions -d 2116 +d 2116 d 11340 d 11700 d 11400 @@ -1283,7 +1283,7 @@ d 12654 d 13320 d 11960 d 13908 -d 11110 +d 10088 d 10605 d 11865 d 11025 diff --git a/ngaImage b/ngaImage index dbdf1af..3adbc7e 100644 Binary files a/ngaImage and b/ngaImage differ diff --git a/tools/muri.c b/tools/muri.c index c6b35a6..42be7a6 100644 --- a/tools/muri.c +++ b/tools/muri.c @@ -73,7 +73,7 @@ void read_line(FILE *file, char *line_buffer) { } CELL opcode_for(char *s) { - char* opcodeList = "..lidudrswpupojucaccreeqneltgtfestadsumudianorxoshzrenieiqii"; + char* opcodeList = "..lidudrswpupojucaccreeqneltgtfestadsumudianorxoshzrhaieiqii"; int16_t* s16 = (int16_t *)s; int16_t* op16 = (int16_t *)opcodeList; int i = 0; diff --git a/vm/nga-c-native-x86/retro.c b/vm/nga-c-native-x86/retro.c index e4cf337..d5f7b21 100644 --- a/vm/nga-c-native-x86/retro.c +++ b/vm/nga-c-native-x86/retro.c @@ -284,7 +284,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IE, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II }; #define NUM_OPS VM_II + 1 @@ -476,7 +476,7 @@ void inst_zret() { } } -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } @@ -501,7 +501,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; diff --git a/vm/nga-c-no-libc/retro.c b/vm/nga-c-no-libc/retro.c index cc5f44d..849afd8 100644 --- a/vm/nga-c-no-libc/retro.c +++ b/vm/nga-c-no-libc/retro.c @@ -408,7 +408,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IE, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II }; #define NUM_OPS VM_II + 1 @@ -600,7 +600,7 @@ void inst_zret() { } } -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } @@ -625,7 +625,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; diff --git a/vm/nga-c/barebones.c b/vm/nga-c/barebones.c index 5d91771..864018d 100644 --- a/vm/nga-c/barebones.c +++ b/vm/nga-c/barebones.c @@ -121,7 +121,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IE, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II }; #define NUM_OPS VM_II + 1 @@ -330,7 +330,7 @@ void inst_zret() { } } -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } @@ -355,7 +355,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; diff --git a/vm/nga-c/repl.c b/vm/nga-c/repl.c index 568956b..f629158 100644 --- a/vm/nga-c/repl.c +++ b/vm/nga-c/repl.c @@ -417,7 +417,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IE, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II }; #define NUM_OPS VM_II + 1 @@ -634,7 +634,7 @@ void inst_zret() { } } -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } @@ -659,7 +659,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; diff --git a/vm/nga-c/retro-compiler.c b/vm/nga-c/retro-compiler.c index 3bf3ebc..3ef812e 100644 --- a/vm/nga-c/retro-compiler.c +++ b/vm/nga-c/retro-compiler.c @@ -361,7 +361,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IE, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II }; #define NUM_OPS VM_II + 1 @@ -565,7 +565,7 @@ void inst_zret() { } } -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } @@ -590,7 +590,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; diff --git a/vm/nga-c/retro-image.c b/vm/nga-c/retro-image.c index f94e401..164fee3 100644 --- a/vm/nga-c/retro-image.c +++ b/vm/nga-c/retro-image.c @@ -22,7 +22,7 @@ CELL ngaImage[] = { 1793,14517,15061,15103,202001,0,10,1,10,2,10,3,10,4,10,5,10, 7,110,2049,105,459009,19,110,459009,54,110,459009,15,110,459009,17,110,1793,5,10,524546, 158,134284303,160,1807,1025,1642241,227,285282049,343,1,459012,338,117509889,177,338,134287105,343,197,16845825,0, 351,335,1793,64,17826050,343,247,8,117506305,344,354,64,2116,11340,11700,11400,13685,13104,12432,12402, - 9603,9801,11514,11413,11110,12528,11948,10302,13340,9700,13455,12753,10500,10670,12654,13320,11960,13908,11110,10605, + 9603,9801,11514,11413,11110,12528,11948,10302,13340,9700,13455,12753,10500,10670,12654,13320,11960,13908,10088,10605, 11865,11025,0,2049,197,987393,1,1793,105,524546,439,2049,437,2049,437,17891588,2,439,8,17045505, -24,-16,17043736,-8,1118488,1793,105,17043202,1,169021201,2049,56,25,33883396,101450758,6404,459011,429,34668804,2, 2049,426,524545,371,429,302056196,371,659969,1,0,9,150,100,117,112,0,448,11,150,100, diff --git a/vm/nga-c/retro-runtime.c b/vm/nga-c/retro-runtime.c index 90de58c..fbbabf0 100644 --- a/vm/nga-c/retro-runtime.c +++ b/vm/nga-c/retro-runtime.c @@ -1467,7 +1467,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IE, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II }; #define NUM_OPS VM_II + 1 @@ -1677,7 +1677,7 @@ void inst_zret() { } } -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } @@ -1702,7 +1702,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; diff --git a/vm/nga-c/retro-unix.c b/vm/nga-c/retro-unix.c index 1c9e732..5e45756 100644 --- a/vm/nga-c/retro-unix.c +++ b/vm/nga-c/retro-unix.c @@ -1748,7 +1748,7 @@ enum vm_opcode { VM_NOP, VM_LIT, VM_DUP, VM_DROP, VM_SWAP, VM_PUSH, VM_POP, VM_JUMP, VM_CALL, VM_CCALL, VM_RETURN, VM_EQ, VM_NEQ, VM_LT, VM_GT, VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, - VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_END, VM_IE, + VM_AND, VM_OR, VM_XOR, VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II }; #define NUM_OPS VM_II + 1 @@ -1980,7 +1980,7 @@ void inst_zret() { } } -void inst_end() { +void inst_halt() { ip = IMAGE_SIZE; } @@ -2005,7 +2005,7 @@ Handler instructions[NUM_OPS] = { inst_nop, inst_lit, inst_dup, inst_drop, inst_swap, inst_push, inst_pop, inst_jump, inst_call, inst_ccall, inst_return, inst_eq, inst_neq, inst_lt, inst_gt, inst_fetch, inst_store, inst_add, inst_sub, inst_mul, inst_divmod, - inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_end, inst_ie, + inst_and, inst_or, inst_xor, inst_shift, inst_zret, inst_halt, inst_ie, inst_iq, inst_ii }; diff --git a/vm/nga-csharp/retro.cs b/vm/nga-csharp/retro.cs index 15ee50a..4c701a3 100644 --- a/vm/nga-csharp/retro.cs +++ b/vm/nga-csharp/retro.cs @@ -31,7 +31,7 @@ namespace Nga VM_FETCH, VM_STORE, VM_ADD, VM_SUB, VM_MUL, VM_DIVMOD, VM_AND, VM_OR, VM_XOR, - VM_SHIFT, VM_ZRET, VM_END, + VM_SHIFT, VM_ZRET, VM_HALT, VM_IE, VM_IQ, VM_II } @@ -275,7 +275,7 @@ namespace Nga ip = address[rsp]; rsp--; } break; - case OpCodes.VM_END: + case OpCodes.VM_HALT: ip = 524288 * 16; break; case OpCodes.VM_IE: diff --git a/vm/nga-js/nga.js b/vm/nga-js/nga.js index fab2b80..b137587 100644 --- a/vm/nga-js/nga.js +++ b/vm/nga-js/nga.js @@ -80,7 +80,7 @@ function Opcodes() { this.XOR = 23; this.SHIFT = 24; this.ZERO_EXIT = 25; - this.END = 26; + this.HALT = 26; this.IE = 27; this.IQ = 28; this.II = 29; @@ -264,7 +264,7 @@ instructions[vm.ZERO_EXIT] = function() { ip = address.pop(); } } -instructions[vm.END] = function() { +instructions[vm.HALT] = function() { ip = IMAGE_SIZE; } instructions[vm.IE] = function() { diff --git a/vm/nga-pascal/nga.pas b/vm/nga-pascal/nga.pas index e0055ec..50ba395 100644 --- a/vm/nga-pascal/nga.pas +++ b/vm/nga-pascal/nga.pas @@ -283,7 +283,7 @@ begin end; end; -procedure inst_end(); +procedure inst_halt(); begin ip := IMAGE_SIZE - 1; end; @@ -338,7 +338,7 @@ begin 23 : inst_xor(); 24 : inst_shift(); 25 : inst_zret(); - 26 : inst_end(); + 26 : inst_halt(); 27 : inst_in(); 28 : inst_iq(); 29 : inst_ii(); diff --git a/vm/nga-python/retro.py b/vm/nga-python/retro.py index 6f503ff..b210a1f 100755 --- a/vm/nga-python/retro.py +++ b/vm/nga-python/retro.py @@ -208,7 +208,7 @@ def i_zr(): stack.pop() ip = address.pop() -def i_en(): +def i_ha(): global ip, memory, stack, address ip = 9000000 @@ -224,7 +224,7 @@ def i_ii(): stack.pop() rxDisplayCharacter() -instructions = [i_no, i_li, i_du, i_dr, i_sw, i_pu, i_po, i_ju, i_ca, i_cc, i_re, i_eq, i_ne, i_lt, i_gt, i_fe, i_st, i_ad, i_su, i_mu, i_di, i_an, i_or, i_xo, i_sh, i_zr, i_en, i_ie, i_iq, i_ii] +instructions = [i_no, i_li, i_du, i_dr, i_sw, i_pu, i_po, i_ju, i_ca, i_cc, i_re, i_eq, i_ne, i_lt, i_gt, i_fe, i_st, i_ad, i_su, i_mu, i_di, i_an, i_or, i_xo, i_sh, i_zr, i_ha, i_ie, i_iq, i_ii] def validateOpcode(opcode): I0 = opcode & 0xFF