ILOAD (0x15)


The ILOAD instruction copies the value of a local variable to the top of the stack. Its operand is a 1-byte unsigned offset. This offset is added to the value in the LV register to determine the address of the value that is to be copied.

If the ILOAD 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 ILOAD 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.

0x015  H=LV; goto 0x18
...
0x018  MAR=H+MBRU; rd; goto 0x19
0x019  SP=MAR=SP+1; goto 0x1a
0x01a  PC=PC+1; wr; fetch; goto 0x1b
0x01b  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