Add Instruction

Adds 2 values together and stores in a destination register.

Can also Add a register and a constant number if desired.

Subtraction can be done by adding a number and a negative number

Can also copy values by adding a number + 0 and giving it a different destination register

Add (Register)

0001 DDD SR1 F 00 SR2

  • 0001: Indicates we want to use the ADD Opcode
  • D: Destination Register, we want to output the sum to this register(3 bit length, R0-R7, 000 to 111, 0 to 8)
  • SR1: 1st register number's value we want to add
  • SR2: 2nd register number's value we want to add
  • F: Flag
    • Flag == 0, means we are adding 2 registers together
    • Flag == 1, means are in Immediate mode and are adding a register and a constant number.
  • 00: Unused bits for Add (Register)

Example of Adding R3 + 35 and storing it in R1

0001 001 011 0 00 101

Add (Immediate)

0001 DDD SR1 F CCCCC

  • 0001: Indicates we want to use the ADD Opcode
  • D: Destination Register, we want to output the sum to this register(3 bit length, R0-R7, 000 to 111, 0 to 8)
  • SR1: 1st register number's value we want to add
  • F: Flag
    • Flag == 0, means we are adding 2 registers together(Add Register)
    • Flag == 1, means are in Immediate mode and are adding a register and a constant number.(Add Immediate)
  • C: Constant number of 5 bits to add to SR1
  • 00: Unused bits for Add (Register)

Example of Adding R3 + Constant Number 6 and storing it in R3

0001 011 011 1 00110

results matching ""

    No results matching ""