DUP (0x59)


The DUP instruction duplicates the value at the top of the stack by placing a copy of that value onto the stack.

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.

0x059  SP=MAR=SP+1; goto 0xb
...
0x00b  MDR=TOS; wr; goto 0x2

Example Program

//---------------------------------------------
// Demonstrate the DUP 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.
//
// After running this program
//     10 is stored at address 4097
//     10 is stored at address 4098
// and the top of the stack is at 4098.
//---------------------------------------------
.main
    bipush 10  // push 10 onto the stack
    dup        // duplicate it
    halt
.end-main