ARITHMETIC OPERATIONS


Back to:
index table

ADD instruction

Coding:
bin: MOD0010 OP1OP2
hex: MOD 2 OP1OP2
(MOD - modifier: affects on operands type - word/byte, or maybe specifies "short constant"; OP1 and OP2 - operands)

Description:
OP2 + OP1 ==> OP2
This instruction adds OP1 to OP2 and writes the sum to OP2. Flags N and Z are set according to the result.

Examples:
0212 R2 + R1 ==> R2 the sum of values from R2 and R1 will be stored to R2
0205 R0 + (R1) ==> R0 the value from R0 adds to the memory cell, which address is taken from R1
02D3
0100
R3 + 100 ==> R3 add the constant 100 from the second word of this instruction to R3
2210 R0 + 1 ==> R0 increment R0 (add the "short constant" 1)

Back to:
index table top


SUBTRACT instruction

Coding:
bin: MOD0011 OP1OP2
hex: MOD 3 OP1OP2
(MOD - modifier: affects on operands type - word/byte, or maybe specifies "short constant"; OP1 and OP2 - operands)

Description:
OP2 - OP1 ==> OP2
This instruction subtracts OP1 from OP2 and writes the result to the place of OP2. Flags N and Z are set accoring to the result.

Examples:
0312 R2 - R1 ==> R2
a difference between values from R2 and R1 will be stored to R2
0305 (R1) - R0 ==> (R1) subtract R0 register's value from the number, extracted from address (R1); the result will be placed back to the same memory address
03D3
0100
R3 -100 ==> R3 subtract the constant 100 (the second word of the instruction) from R3
2310 R0 - 1 ==> R0 decrement R0 (subtract the "short constant" 1)

Back to:
index table top


COMPARE instruction

Coding:
bin: MOD0100 OP1OP2
hex: MOD 4 OP1OP2
(MOD - modifier: affects on operands type - word/byte, or maybe specifies "short constant"; OP1 and OP2 - operands)

Description:
OP2 - OP1, set flags
This instruction subtracts OP1 from OP2 and sets flags N and Z according to the result. Both operands don't change - the only output of the operation are flags.

Examples:
0412 R2 - R1 set flags according to the difference
04D3
FFFF
R3 - FFFF compare R3 with the constant FFFF (the second word of instruction)
2401 R1 - 0 analyse the value in R1 (compare with "short constant" 0)

Back to:
index table top


MULTIPLY instruction

Coding:
bin: MOD0101 OP1OP2
hex: MOD 5 OP1OP2
(MOD - modifier: affects on operands type - word/byte, or maybe specifies "short constant"; OP1 and OP2 - operands)

Description:
OP2 * OP1 ==> OP2
This instruction multiplies OP2 and OP1, and then writes the result into OP2. Flags N and Z are set accoring to the product.

Examples:
0512 R2 * R1 ==> R2 values from R2 and R1 will be multiplied
3510 R0 * (-1) ==> R0 this example shows, how to change the sign of R0 value, using "short constant" -1

Back to:
index table top


DIVIDE instuction

Coding:
bin: MOD0110 OP1OP2
hex: MOD 6 OP1OP2
(MOD - modifier: affects on operands type - word/byte, or maybe specifies "short constant"; OP1 and OP2 - operands)

Description:
OP2/OP1 ==> OP2
This instruction divides OP2 by OP1, takes an integer part of the result, and then writes it into OP2. Flags N and Z are set accoring to the result.

Examples:
0612 R2 / R1 ==> R2 R2 divided R1 will be stored to R2
06D1
0140
R0 / 140 ==> R0 instruction will divide R1 value by 140 (this word of instruction) and stoped the result to R1

Back to:
index table top