Assigning Values To Registers - Jimmer1/Chip16 GitHub Wiki

Your most basic and flexible data storage comes in the form of the register. Registers are what the CPU uses to hold data that it needs fast access to, and for data that the programmer wishes to use for some form of computation as Chip16 doesn't support direct memory operands.

The most basic register operations are:

  • Copying a 16-bit value from one register to another
  • Setting a register to a 8-bit value.

These operations are encoded by the following two opcodes:

Mnemonic - Opcode - Description

  • AR - 8XY0 - Copies the value held by register Y into register X.
  • ACR - 6XNN - Sets register X to the 8-bit value NN.

I shall demonstrate their use as follows:

AR

code = [
    0x80, 0x50 # ar r0, r5 # r0 = r5
]

ACR

code = [
    0x6F, 0x2a # acr r15, 0x2A # r15 = 0x2A
]

While basic these operations are extremely important and it is essential you understand their function before continuing.

Next: Basic Arithmetic