diff --git a/ASSERT.md b/ASSERT.md new file mode 100644 index 0000000..fd90e0d --- /dev/null +++ b/ASSERT.md @@ -0,0 +1,21 @@ +`ASSIGN` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 val` - The value of the expression +`int32 expr` - The expression as a string +`int32 file` - The name of the source file containing the assertion +`int32 line` - The line number of the assertion + +### Description +Halt execution if the value is zero. + +### Example + ; assert(0); + PUSH 0 + S_PUSH "0" + S_PUSH "test.jaf" + PUSH 0x123 + ASSERT diff --git a/FT_ASSIGNS.md b/FT_ASSIGNS.md new file mode 100644 index 0000000..6aed066 --- /dev/null +++ b/FT_ASSIGNS.md @@ -0,0 +1,20 @@ +`FT_ASSIGNS` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 pageno` - The heap index of the page containing functype variable to assign to +`int32 varno` - The index of the variable to assign to +`int32 fname` - The name of the function to assign (heap index of a string) +`int32 type` - The type of the functype variable to assign to + +### Description +Assign a function to a functype variable by name. + +### Example + PUSHLOCALPAGE ; stack: [pagno] + PUSH 0x0 ; stack: [pageno, 0] + S_PUSH 0x4 ; stack: [pageno, 0, s] where s is the heap index of a string which names a function + PUSH 0x5 ; stack: [pageno, 0, s, 5] where 5 is the type of the functype variable at localpage[0] + FT_ASSIGNS ; stack: [s] and localpage[0] now contains the function named by s diff --git a/IFNZ.md b/IFNZ.md new file mode 100644 index 0000000..761622a --- /dev/null +++ b/IFNZ.md @@ -0,0 +1,17 @@ +`IFNZ` + +### Instruction Arguments +`int32 addr` - The address to jump to + +### Stack Arguments +`int32 test` - The test value + +### Description +Jump to an address if the test value is non-zero. + +### Example + PUSH 0x1 ; test value + IFZ label ; jump to 'label' (if test value is non-zero) + PUSH 0x0 ; not executed + label: + PUSH 0x1 ; executed diff --git a/IFZ.md b/IFZ.md new file mode 100644 index 0000000..0188339 --- /dev/null +++ b/IFZ.md @@ -0,0 +1,17 @@ +`IFZ` + +### Instruction Arguments +`int32 addr` - The address to jump to + +### Stack Arguments +`int32 test` - The test value + +### Description +Jump to an address if the test value is zero. + +### Example + PUSH 0x0 ; test value + IFZ label ; jump to 'label' (if test value is zero) + PUSH 0x0 ; not executed + label: + PUSH 0x1 ; executed diff --git a/JUMP.md b/JUMP.md new file mode 100644 index 0000000..b45df34 --- /dev/null +++ b/JUMP.md @@ -0,0 +1,16 @@ +`JUMP` + +### Instruction Arguments +`int32 addr` - The address to jump to + +### Stack Arguments +None. + +### Description +Jump to an address. + +### Example + JUMP label ; jump to 'label' + PUSH 0x0 ; not executed + label: + PUSH 0x1 ; executed diff --git a/NEW.md b/NEW.md new file mode 100644 index 0000000..24f2126 --- /dev/null +++ b/NEW.md @@ -0,0 +1,14 @@ +`NEW` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 type` - The type of the structure to create + +### Description +Create and initialize a structure object. + +### Example + PUSH 0x3 ; stack: [3] where 3 is the type of the structure object to create + NEW ; stack: [pageno] where pageno is the heap index of a newly created object of type 3 diff --git a/RETURN.md b/RETURN.md new file mode 100644 index 0000000..620b3c5 --- /dev/null +++ b/RETURN.md @@ -0,0 +1,16 @@ +`RETURN` + +### Instruction Arguments +None. + +### Stack Arguments +The value to return from the function, or none if the function returns void. + +### Description +Return from a function. + +### Example + FUNC 0x1 ; start of function + PUSH 0x123 ; stack: [0x123] + RETURN ; return 0x123 + ENDFUNC 0x1 ; end of function diff --git a/SR_ASSIGN.md b/SR_ASSIGN.md new file mode 100644 index 0000000..84569c1 --- /dev/null +++ b/SR_ASSIGN.md @@ -0,0 +1,22 @@ +`SR_ASSIGN` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 lhs` - The left hand side of the assignment (heap index of structure page) +`int32 rhs` - The right hand side of the assignment (heap index of structure page) +`int32 type` - The structure type + +### Description +Copy a structure page into an existing structure page of the same type. + +### Example + PUSHLOCALPAGE ; stack: [pagno] + PUSH 0x0 ; stack: [pageno, 0] + REF ; stack: [struct1] where struct1 is the structure page at localpage[0] + PUSHLOCALPAGE ; stack: [struct1, pageno] + PUSH 0x1 ; stack: [struct1, pageno, 1] + REF ; stack: [struct1, struct2] where struct2 is the structure page at localpage[1] + PUSH 0x4 ; stack: [struct1, struct2, 4] where 4 is the structure type of both struct1 and struct2 + SR_ASSGIN ; stack: [struct2] and struct1 is now a copy of struct2 diff --git a/SR_POP.md b/SR_POP.md new file mode 100644 index 0000000..59efc52 --- /dev/null +++ b/SR_POP.md @@ -0,0 +1,16 @@ +`SR_POP` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 structno` - The heap index of a structure + +### Description +Decrement the stack pointer and decrease the reference count of the structure object at the top of the stack. + +### Example + PUSHLOCALPAGE ; stack: [pageno] + PUSH 0x0 ; stack: [pageno, 0] + SR_REF ; stack: [v] where v = a copy of the structure at localpage[0] + SR_POP ; stack: [] diff --git a/SR_REF.md b/SR_REF.md new file mode 100644 index 0000000..8a47f3f --- /dev/null +++ b/SR_REF.md @@ -0,0 +1,16 @@ +`SR_REF` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 pageno` - The heap index of the page containing the variable +`int32 varno` - The index of the structure variable within the page + +### Description +Push a copy of a structure object from a page onto the stack. + +### Example + PUSHLOCALPAGE ; stack: [pageno] + PUSH 0x0 ; stack: [pageno, 0] + SR_REF ; stack: [v], where v = a copy of the structure at localpage[0] diff --git a/SR_REF2.md b/SR_REF2.md new file mode 100644 index 0000000..9f36ae3 --- /dev/null +++ b/SR_REF2.md @@ -0,0 +1,16 @@ +`SR_REF2` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 pageno` - The heap index of the structure page + +### Description +Copy a structure object on the stack. + +### Example + PUSHLOCALPAGE ; stack: [pageno] + PUSH 0x0 ; stack: [pageno, 0] + REF ; stack: [v1] where v1 = the structure at localpage[0] + SR_REF2 ; stack: [v2] where v2 = a copy of v1 diff --git a/STRSWITCH.md b/STRSWITCH.md new file mode 100644 index 0000000..5b767fd --- /dev/null +++ b/STRSWITCH.md @@ -0,0 +1,20 @@ +`STRSWITCH` + +### Instruction Arguments +`int32 switchno` - The index of the string jump table + +### Stack Arguments +`int32 test` - The (string) test value + +### Description +Jump to an address in a jump table based on a (string) test value. + +### Example + PUSH 0x1 ; test value "two" + SWITCH 0x1 ; jump to address for value of 2 in jump table 1 + .STRCASE 0:1 "zero" + ... ; not executed + .STRCASE 1:1 "one" + ... ; not executed + .STRCASE 2:1 "two" + PUSH 0x1 ; executed diff --git a/SWITCH.md b/SWITCH.md new file mode 100644 index 0000000..0a0b47c --- /dev/null +++ b/SWITCH.md @@ -0,0 +1,20 @@ +`SWITCH` + +### Instruction Arguments +`int32 switchno` - The index of the jump table + +### Stack Arguments +`int32 test` - The test value + +### Description +Jump to an address in a jump table based on a test value. + +### Example + PUSH 0x2 ; test value + SWITCH 0x1 ; jump to address for value of 2 in jump table 1 + .CASE 0:1 0 + ... ; not executed + .CASE 1:1 1 + ... ; not executed + .CASE 2:1 2 + PUSH 0x1 ; executed diff --git a/S_POP.md b/S_POP.md new file mode 100644 index 0000000..f982afc --- /dev/null +++ b/S_POP.md @@ -0,0 +1,14 @@ +`S_POP` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 stringno` - The heap index of a string + +### Description +Decrement the stack pointer and decrease the reference count of the string object at the top of the stack. + +### Example + S_PUSH 0x1 ; stack: [heap index of string 1] + S_POP ; stack: [] diff --git a/S_PUSH.md b/S_PUSH.md new file mode 100644 index 0000000..8b98dbf --- /dev/null +++ b/S_PUSH.md @@ -0,0 +1,13 @@ +`S_PUSH ` + +### Instruction Arguments +`int32 sno` - Index of the string to push onto the stack + +### Stack Arguments +None. + +### Description +Push a string contant onto the stack. + +### Example + S_PUSH 0x1 ; stack: [heap index of string 1] diff --git a/S_REF.md b/S_REF.md new file mode 100644 index 0000000..752b077 --- /dev/null +++ b/S_REF.md @@ -0,0 +1,16 @@ +`S_REF` + +### Instruction Arguments +None. + +### Stack Arguments +`int32 pageno` - The heap index of the page containing the variable +`int32 varno` - The index of the string variable within the page + +### Description +Push a string variable from a page onto the stack. + +### Example + PUSHLOCALPAGE ; stack: [pageno] + PUSH 0x0 ; stack: [pageno, 0] + S_REF ; stack: [v], where v = localpage[0]