POP (0x57)


The POP instruction pops the top value from the stack by decrementing the stack pointer.

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.

0x057  SP=MAR=SP-1; rd; goto 0xc
...
0x00c  ALU=0; goto 0xd
0x00d  TOS=MDR; goto 0x2  // Copy the new top of stack
                          // value to TOS

Example Program

//---------------------------------------------
// Demonstrate the POP instruction.
//
// 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.
//
// When the program terminates, SP will point
// to address 4096 as it did before the program
// was executed.
//---------------------------------------------
.main
    bipush 4  // Push 4 onto the stack
    pop       // Pop it off
    halt
.end-main