- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
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. | 
| allocn | Pushes nundefined values onto the stack. | 
| reseto,n | Replaces nvalues on the stack with the undefined value starting from frame pointer offseto. | 
| 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 #trueonto the stack. | 
| push_false | Pushes value #falseonto the stack. | 
| push_fixnumn | Pushes the fixnum n onto the stack. | 
| push_bignumbn | Pushes the bignum bn onto the stack. | 
| push_ratr | Pushes the rational number r onto the stack. | 
| push_bigratbr | Pushes the given bigrat number br onto the stack. | 
| push_flonumx | Pushes the flonum x onto the stack. | 
| push_complexcx | Pushes the complex number cx onto the stack. | 
| push_charch | Pushes the character ch onto the stack. | 
| push_constantc | Pushes the constant from the constant pool at index c onto the stack. | 
| Instruction | Explanation | 
|---|---|
| make_closuren,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. | 
| calln | Calls a procedure with n arguments. | 
| tail_calln | Calls a procedure with n arguments. This instruction is used for tail calls and does not require a new frame to be pushed. | 
| applyn | 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_countn | Checks that there are exactly n arguments on the stack. | 
| assert_min_arg_countn | Checks that there are at least n arguments on the stack. | 
| collect_restn | 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_promiseinstruction). | 
| 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_variableo | 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_argumento | 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_globalc | c is an index into the constant pool referring to a symbol. push_globalpushes the value to which this symbol is bound in the global environment onto the stack. | 
| set_globalc | c is an index into the constant pool referring to a symbol. set_globalbinds the symbol in the global environment to the value on top of the stack.set_globalfails if the symbol has not previously been bound in the global environment. | 
| define_globalc | c is an index into the constant pool referring to a symbol. define_globalbinds the symbol in the global environment to the value on top of the stack. As opposed toset_global, the symbol does not have to be bound previously. | 
| push_capturedd | d is an index into the capture list. push_capturedpushes the value d refers to onto the stack. | 
| push_captured_valued | d is an index into the capture list referring to a variable. push_captured_valuepushes the value of the variable to which d refers to onto the stack. | 
| set_captured_valued | d is an index into the capture list referring to a variable. set_captured_valuestores the value on top of the stack in the variable to which d refers to. | 
| push_localo | o is an offset relative to the frame pointer. push_localpushes the value in this location onto the stack. | 
| push_local_valueo | o is an offset relative to the frame pointer referring to a variable. push_local_valuepushes the value of this variable onto the stack. | 
| set_localo | o is an offset relative to the frame pointer. set_localstores the value on top of the stack in this stack location overwriting the previous value. | 
| set_local_valueo | o is an offset relative to the frame pointer referring to a variable. set_local_valuestores the value on top of the stack in this variable. | 
| Instruction | Explanation | 
|---|---|
| branchi | i is an offset relative to the current instruction pointer. branchjumps to the instruction to which i refers to. | 
| branch_ifi | i is an offset relative to the current instruction pointer. branch_ifjumps to the instruction to which i refers to if the value on the stack is not#false. | 
| branch_if_noti | i is an offset relative to the current instruction pointer. branch_ifjumps to the instruction to which i refers to if the value on the stack is#false. | 
| ori | i is an offset relative to the current instruction pointer. orjumps to the instruction to which i refers to if the value on the stack is not#false. As opposed tobranch_if, the value on top of the stack will remain there. Only if the value on top of the stack is#false,orwill pop this value off the stack. | 
| andi | i is an offset relative to the current instruction pointer. orjumps to the instruction to which i refers to if the value on the stack is#false. As opposed tobranch_if_not, the value on top of the stack will remain there. Only if the value on top of the stack is not#false,andwill 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 | 
|---|---|
| listn | 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. | 
| vectorn | 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_appendn | Pops the top n vectors off the stack and constructs a new vector by concatenating the individual vectors. | 
| is_vector | Pushes #falseonto 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. |