|
A miniature computer! The LC-2 features a grand total of two 4-bit registers and a lean but powerful instruction set.
The top register is register 0 and the bottom register is register 1.
The LC-2 is programmable via 7 logic sources at the left of the screen.
The first two inputs are opcodes corresponding to different operations. Here is each operation:
00: AND both registers, store result in selected register
01: Set selected register to input bits (LOAD)
10: Increment selected register by 1
11: Decrement selected register by 1
The third input bit determines which register is selected to store the value of the computation. 0 stores in R0, 1 stores in R1.
The four bits below are input bits for the load instruction. If you're not using the LOAD instruction, you don't have to worry about these.
The button below the logic sources is the clock. Press the button to trigger each programmed computation.
Enjoy!
Examples (input bits from top to bottom):
01 1 0101: LOAD 0101 (5) into R1
00 0 XXXX: AND R0 and R1, store into R0 (X's denote that the last 4 bits can be anything, they don't affect the output)
11 0 XXXX: Subtract 1 from R0
10 1 XXXX: Add 1 to R1
You can also execute a series of instructions to accomplish a task. For instance, to copy the value in R0 to R1:
01 1 1111: LOAD 1111 (F) into R1
00 1 XXXX: AND R0 with R1, store into R1
|