WRAP

Web Register Assembly Programming

A web version of Daniel Dennett's RAP machine.

The RAP language has three instructions:

  • INC: increment a register then go to another instruction. The syntax is
    INC [register] [instruction]
  • DEB: decrement a register and go to another instruction, or if the register is zero and you can't decrement then go to a different instruction.
    DEB [register] [instruction] [branch instruction if zero]
  • END: halt the program

Execution begins at instruction 1. Play executes the program until it reaches an END (watch out for infinite loops!)

Step executes one instruction at a time. The highlighted instruction is the next one about to be executed. Restart sets the machine to it's initial state, your instructions will still be there, it just gets rid of the existing register values and sets the program to run at instruction 1 again. You can only have one instruction per line.


Code

Write the program here.

Restart to start over again

play
step
stop
restart


DEB 0 1 2 DEB 1 3 4 INC 0 2 END

Registers

The register values are here.

Add Register +

Examples

Addition

This makes a loop to decrement a register, increment a register. If we can't decrement because zero, we've taken all from that register and added to the other, so branch to end.

Registers

Register 0 with your value, register 1 with the other value. The result will be in register 1.

Code

DEB 0 2 3
INC 1 1
END

Move

Like addition, but zeroes out a register, then adds a another register to this one.

Registers

Register 0 will get zeroed out then the contents of register 1 will be moved to it.

Code

DEB 0 1 2
DEB 1 3 4
INC 0 2
END