ALU

Opcodes

OpcodeActionFlagsDescription
ADD Rx,#Rx <= Rx + ImmZ, CRx is added to an Immediate 16 or 32 bit value with the result written back to Rx.The C Flag is set on carry
(i.e. the register wraps from FFFFFFFF to 00000000).The Z flag is set if the result is zero
SUB Rx,#Rx <= Rx - ImmZ, CAn immediate 16 or 32 bit value is subtracted from Rx and the result is written back to Rx.The C Flag is set if there is a borrow (i.e. wraps from00000000 to FFFFFFFF).The Z flag is set if the result is zero
CMP Rx,#Z and C <= Rx = ImmZ, CAn immediate 16 or 32 bit value is subtracted from Rx, but only flags are updated. Rx is unmodified.The C Flag is set on borrow.The Z flag is set if the result is zero
ADD Rx,RyRx <= Rx + RyZ, CRx is added to Ry, and the result is written back into Rx.The C Flag is set on carry.The Z flag is set if the result is zero.
SUB Rx,RyRx <= Rx - RyZ, CRy is subtracted from Rx, and the result is written back to Rx.The C Flag is set on carry.The Z flag is set if the result is zero.
CMP Rx,RyZ and C <= Rx = RyZ, CRy is subtracted from Rx, but only the flags are updated. Rx is unmodified.The C Flag is set on borrow.The Z flag is set if the result is zero.
MUL Rx,RyRx ← Rx * RyZRx and Ry are multiplied together, with the result put into Rx.The Z flag is set if the result is zero.
DIV Rx,RyRx ← Rx / Ry
Ry ← Rx % Ry
Z, CThis instruction performs two functions at once. Rx is divided by Ry, and the quotient is placed into Rx, and the remainder is placed into Ry.The Z flag is set if the quotient (Rx) is zero.The C flag is set if the remainder (Ry) is zero.If dividing by 0 is attempted, will generate an error.
CLCC ← 0CClears the Carry Flag
SECC ← 1CSets the Carry Flag

Notes

  • Z Flag used for result is zero
  • C Flag used for overflow on ALU