Two Address Machine

Instruction format     =     OPCODE OPERAND,#OP2/RES
e.g     ADD     2,#30;      //add 2 to the address 30, store result in address 30

Special cases:

INC OPERAND;
DEC OPERAND;
JMP #OPERAND;

Valid instructions:

OPCODE(hex) OPCODE OPERANDS Explanation
a0 add value,#address; add the value to this address
A0 ADD #address1,#address2; add contents of address1 to address2 and store in address2
a2 SUB value,#address; subtract the contents of address1 from address2, store in address2
A2 SUB #address1,#address2; subtract the contents of address1 from address2, store in address2
a3 MUL #address1,#address2; multiply the contents of address1 by address2, store in address2
A3 MUL value,#address; multiply the contents of the address by this value, store back in address
a4 DIV #address1,#address2; divide the contents of address2 by contents of address1, store result in address2
A4 DIV value,#address; divide the contents of the address by value, store result in address
A5 INC #address; increment the contents of this address
A6 DEC #address; decrement the contents of this address
D0 MOV #address1,#address2; Move the contents of address1 to address2
C0 JMP #address; Jump to this address
C1 JMPZ #address1,#address2; Jump to address1 if the contents of address2 is equal to zero
C2 JMPN #address1,#address2; Jump to address1 if the contents of address2 is negative
a0 add value,#address; add the value to this address
FF HALT; None Stop the machine. Input this as your final instruction. Not required if program loops indefinitely.

Return to readme files.

Return to homepage.