mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-22 23:18:01 +03:00
Add more stack/variables/pages instructions
+21
@@ -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
|
||||
+20
@@ -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
|
||||
+17
@@ -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
|
||||
+17
@@ -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
|
||||
+16
@@ -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
|
||||
+14
@@ -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
|
||||
+16
@@ -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
|
||||
+22
@@ -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
|
||||
+16
@@ -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: []
|
||||
+16
@@ -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]
|
||||
+16
@@ -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
|
||||
+20
@@ -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
|
||||
+20
@@ -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
|
||||
+14
@@ -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: []
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
`S_PUSH <sno>`
|
||||
|
||||
### 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]
|
||||
+16
@@ -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]
|
||||
Reference in New Issue
Block a user