LBP2: CPU Program Example

I’ve heard from a few people that they have no understanding on how to actually use the CPU, so let me try to give you an example.

Ok Example 1, Lets Add 2 Numbers together

  1. LW00000001  -Places 1 in the WREG
  2. WA00001000  -Moves the 1 that is stored in the WREG to the first ALU Register (00001000 or AREG)
  3. LW00010011    -Places 19 in the WREG
  4. WA00001001   -Moves the 19 that is stored in the WREG to the second ALU Register (00001001 or BREG)
  5. AA                          -Adds the number stored in the AREG to the number stored in the BREG and places them in the ALUOUT Register (00001010)
  6. MA00001010   -Move the 20 that is stored in the ALUOUT Register to the WREG
  7. RW                          -Displays the binary equivalent of the number 20 or 00010100

As you can see.. All inbound and outbound information MUST go through the WREG.  This will be the same once I finish version 2 of the CPU.  Also, please take note that commands #5 and #7 do not require arguments (the extra info behind it) and anything placed after in those commands will be dropped.

If you have any questions, feel free to ask! I’m continuing to work on version 2 to share with everyone to use in their own levels.  In addition, I am going to try to build an ability to create actual programs which the CPU will read from and perform line by line.  Lots of fun to come!

Leave a Reply