-
Notifications
You must be signed in to change notification settings - Fork 14
Instructions
Matthias Zenger edited this page May 30, 2016
·
3 revisions
Instruction | Explanation |
---|---|
pop |
Drops the top element from stack. |
dup |
Duplicates the top element on the stack. |
swap |
Swaps the top two elements on the stack. |
alloc n
|
Pushes n undefined values onto the stack. |
reset o,n
|
Replaces n values on the stack with the undefined value starting from frame pointer offset o . |
Instruction | Explanation |
---|---|
push_undef |
Pushes the undefined value onto the stack. |
push_void |
Pushes the void value onto the stack. |
push_eof |
Pushes the EOF value onto the stack. |
push_null |
Pushes value null (empty list) onto the stack. |
push_true |
Pushes value #true onto the stack. |
push_false |
Pushes value #false onto the stack. |
push_fixnum n
|
Pushes the fixnum n onto the stack. |
push_bignum bn
|
Pushes the bignum bn onto the stack. |
push_rat r
|
Pushes the rational number r onto the stack. |
push_bigrat br
|
Pushes the given bigrat number br onto the stack. |
push_flonum x
|
Pushes the flonum x onto the stack. |
push_complex cx
|
Pushes the complex number cx onto the stack. |
push_char ch
|
Pushes the character ch onto the stack. |
push_constant c
|
Pushes the constant from the constant pool at index c onto the stack. |
Instruction | Explanation |
---|---|
make_closure n,f
|
Creates a new closure from a capture list and a code fragment. The capture list is created from the top n elements on the stack. f is an index into the list of code fragments of the currently executed code. |
make_frame |
Pushes a new stack frame onto the stack. |
call n
|
Calls a procedure with n arguments. |
tail_call n
|
Calls a procedure with n arguments. This instruction is used for tail calls and does not require a new frame to be pushed. |
apply n
|
This instruction expects on the stack a function, n - 1 individual arguments and an additional list of arguments. apply pushes the elements of the list onto the stack as well and then applies the function to all arguments on the stack. The instruction puts the result of the function application onto the stack. |
return |
Returns from the currently executed procedure. |
assert_arg_count n
|
Checks that there are exactly n arguments on the stack. |
assert_min_arg_count n
|
Checks that there are at least n arguments on the stack. |
collect_rest n
|
Collects the arguments exceeding n into a list. |
compile |
Compiles the expression on top of the stack creating a thunk (a procedure without arguments) which is left on top of the stack. |
Instruction | Explanation |
---|---|
make_syntax |
Pops a syntax transformer function off the stack, creates a special form from it and pushes it onto the stack. |
Instruction | Explanation |
---|---|
make_promise |
Creates a new promise on the stack whose value will be computed by executing the closure on top of the stack. |
force |
Forces the value of the promise on top of the stack. If the promise has been evaluated already, push the value onto the stack and skip the next instruction (which is typically a store_in_promise instruction). |
store_in_promise |
Stores the value on top of the stack in the promise to which the second top-most entry on the stack The promise gets removed from the stack. |
Instruction | Explanation |
---|---|
make_local_variable o
|
Creates a new variable, pops an expression from the stack and assignes the variable this expression as its initial value. The variable is then stored at the location specified by the frame pointer offset o. |
make_variable_argument o
|
Creates a new variable and assignes the variable the expression at the location specified by the frame pointer offset o. The variable is then stored at the location specified by the frame pointer offset o, i.e. this instruction swaps a value on the stack with a variable with the same value. |
Instruction | Explanation |
---|---|
push_global c
|
c is an index into the constant pool referring to a symbol. push_global pushes the value to which this symbol is bound in the global environment onto the stack. |
set_global c
|
c is an index into the constant pool referring to a symbol. set_global binds the symbol in the global environment to the value on top of the stack. set_global fails if the symbol has not previously been bound in the global environment. |
define_global c
|
c is an index into the constant pool referring to a symbol. define_global binds the symbol in the global environment to the value on top of the stack. As opposed to set_global , the symbol does not have to be bound previously. |
push_captured d
|
d is an index into the capture list. push_captured pushes the value d refers to onto the stack. |
push_captured_value d
|
d is an index into the capture list referring to a variable. push_captured_value pushes the value of the variable to which d refers to onto the stack. |
set_captured_value d
|
d is an index into the capture list referring to a variable. set_captured_value stores the value on top of the stack in the variable to which d refers to. |
push_local o
|
o is an offset relative to the frame pointer. push_local pushes the value in this location onto the stack. |
push_local_value o
|
o is an offset relative to the frame pointer referring to a variable. push_local_value pushes the value of this variable onto the stack. |
set_local o
|
o is an offset relative to the frame pointer. set_local stores the value on top of the stack in this stack location overwriting the previous value. |
set_local_value o
|
o is an offset relative to the frame pointer referring to a variable. set_local_value stores the value on top of the stack in this variable. |
Instruction | Explanation |
---|---|
branch i
|
i is an offset relative to the current instruction pointer. branch jumps to the instruction to which i refers to. |
branch_if i
|
i is an offset relative to the current instruction pointer. branch_if jumps to the instruction to which i refers to if the value on the stack is not #false . |
branch_if_not i
|
i is an offset relative to the current instruction pointer. branch_if jumps to the instruction to which i refers to if the value on the stack is #false . |
or i
|
i is an offset relative to the current instruction pointer. or jumps to the instruction to which i refers to if the value on the stack is not #false . As opposed to branch_if , the value on top of the stack will remain there. Only if the value on top of the stack is #false , or will pop this value off the stack. |
and i
|
i is an offset relative to the current instruction pointer. or jumps to the instruction to which i refers to if the value on the stack is #false . As opposed to branch_if_not , the value on top of the stack will remain there. Only if the value on top of the stack is not #false , and will pop this value off the stack. |
Instruction | Explanation |
---|---|
eq |
Compares the top two values on the stack via eq? and pushes the result onto the stack. |
eqv |
Compares the top two values on the stack via eqv? and pushes the result onto the stack. |
equal |
Compares the top two values on the stack via equal? and pushes the result onto the stack. |
Instruction | Explanation |
---|---|
list n
|
Pops the top n values off the stack and constructs a list out of them on top of the stack. |
cons |
Pops the head and the tail of a new pair off the stack and pushes a new pair with this head and tail onto the stack. |
car |
Pops a pair off the stack and pushes its head onto the stack. |
cdr |
Pops a pair off the stack and pushes its tail onto the stack. |
vector n
|
Pops the top n values off the stack and constructs a vector out of them on top of the stack. |
list_to_vector |
Converts a list to a vector. |
vector_append n
|
Pops the top n vectors off the stack and constructs a new vector by concatenating the individual vectors. |
is_vector |
Pushes #false onto the stack if the current value on top of the stack is not a vector. |
Instruction | Explanation |
---|---|
fx_plus |
Computes the sum of two fixnum values on the stack. |
fx_minus |
Computes the difference of two fixnum values on the stack. |
fx_mult |
Multiplies two fixnum values on the stack. |
fx_div |
Divides a fixnum value by another fixnum value on the stack. |
fl_plus |
Computes the sum of two flonum values on the stack. |
fl_minus |
Computes the difference of two flonum values on the stack. |
fl_mult |
Multiplies two flonum values on the stack. |
fl_div |
Divides a flonum value by another flonum value on the stack. |
Instruction | Explanation |
---|---|
push_current_time |
Pushes the current time as a flonum onto the stack. The time is expressed as seconds since January 1, 1970 at 00:00. |
display |
Displays the value on top of the stack on the console. |
newline |
Displays a newline character on the console. |
noop |
Empty instruction; proceeds to the next instruction. |