ISTORE (0x36)


The ISTORE instruction pops a value from the top of the stack and copies it to a local variable. Its operand is a 1-byte unsigned offset. This offset is added to the value in the LV register to determine the address to which the top of stack value is copied.

If the ISTORE instruction is preceded by the WIDE instruction, the operand is a 2-byte offset. This larger offset makes it possible to address more than 256 variables.

When writing assembly code, the operand must be a variable or parameter identifier defined within the method containing the ISTORE instruction.

Interpreter Microcode

The microinstructions are listed in the order in which they are executed; not the order in which they are stored in the control store.

0x036  H=LV; goto 0x1c
...
0x01c  MAR=H+MBRU; goto 0x1d
0x01d  MDR=TOS; wr; goto 0x1e
0x01e  SP=MAR=SP-1; rd; goto 0x1f
0x01f  PC=PC+1; fetch; goto 0x20
0x020  TOS=MDR; goto 0x2

Example Program

//---------------------------------------------
// Demonstrate the ISTORE & ILOAD instructions.
//
// 1. Clear Memory
// 2. Assemble this program.
// 3. Reset the computer.
// 4. Click the "Display Words" radio button
//    below the memory display.
// 5. Click the "Run" button.
//
// After running this program the variable
// 'value' is pointed to by the LV register
// and is 7. This value is also stored at
// address 4097, the top of the stack.
//---------------------------------------------
.main
    .var
        value
    .end-var

    bipush  6       // Push 6 onto the stack
    istore  value   // Pop top of stack and copy to value
    iinc    value 1 // Add one to value
    iload   value   // Push value onto the stack
    halt
.end-main