Skip to main content

Instruction List

Below is a list of all functions defined by default for the ICMC processor assembly language. For each instruction, there is:

  • an explanation of its functionality or an explanatory pseudo-code, the latter in notation similar to that found in the C programming language.

  • the specification of the instruction format in binary code. The following conventions are assumed:

    • x: bit whose value for the instruction in question is not significant;
    • |: separation between instruction fields;
    • c: "carry"
    • > end: a 16-bit memory address, described on the line following the instruction;
    • > num: a 16-bit positive integer value, described on the line following the instruction.

Data Manipulation Instructions

Memory Access

Instructions for writing (store) to and reading (load) from memory.

MnemonicPseudo-codeInstruction format
store label, rx*label = rx110001 | rx | xxxxxxx | > end
storei rx, ry**rx = ry111101 | rx | ry | xxxx
load rx, labelrx = *label110000 | rx | xxxxxxx | > end
loadi rx, ryrx = **ry111100 | rx | ry | xxxx
loadn rx, #numrx = num111000 | rx | xxxxxxx | > num

Movement between Registers

Copies the value of one register to another.

MnemonicPseudo-codeInstruction Format
mov rx, ryrx = ry110011 | rx | ry | xxx0
mov rx, sprx = sp110011 | rx | xxxxx01
mov sp, rxsp = rx110011 | rx | xxxxx11

Arithmetic Operations

MnemonicPseudo-codeInstruction Format
add rx, ry, rzrx = ry + rz100000 | rx | ry | rz | 0
addc rx, ry, rzrx = ry + rz + carry100000 | rx | ry | rz | 1
sub rx, ry, rzrx = ry - rz100001 | rx | ry | rz | 0
subc rx, ry, rzrx = ry - rz + carry100001 | rx | ry | rz | 1
mul rx, ry, rzrx = ry × ry100010 | rx | ry | rz | 0
mulc rx, ry, rzrx = ry × ry + carry100010 | rx | ry | rz | 1
div rx, ry, rzrx = ry ÷ ry100011 | rx | ry | rz | 0
divc rx, ry, rzrx = ry ÷ ry + carry100011 | rx | ry | rz | 1
mod rx, ry, rzrx = ry % ry100101 | rx | ry | rz | 0
modc rx, ry, rzrx = ry % ry + carry100101 | rx | ry | rz | 1
inc rxrx + 1100100 | rx | 0 | xxxxxx
dec rxrx - 1100100 | rx | 1 | xxxxxx
info

When an arithmetic operation results in zero or a negative number, the fr register assumes a value corresponding to these results.

Logical Operations

MnemonicPseudo-codeInstruction Format
and rx, ry, rzrx = ry & rz010010 | rx | ry | rz | x
or rx, ry, rzrx = ry | rz010011 | rx | ry | rz | x
xor rx, ry, rzrx = ry ^ rz010100 | rx | ry | rz | x
not rx, ryrx = ~ry010101 | rx | ry | xxxx

Bit Movement

Commands that manipulate the values stored in registers in their binary form.

rotl

MnemonicInstruction Format
rotl rx, #num010000 | rx | 10x | num

Moves all bits num digits to the left, and the num most significant digits are "rotated" to become the num least significant digits.

rotr

MnemonicInstruction Format
rotr rx, #num010000 | rx | 11x | num

Moves all bits num digits to the right, and the num least significant digits become the num most significant digits.

shiftl0

MnemonicInstruction Format
shiftl0 rx, #num010000 | rx | 000 | num

Move all bits num digits to the left, and fills the num least significant bits with 0.

shiftl1

MnemonicInstruction Format
shiftl1 rx, #num010000 | rx | 001 | num

Move all bits num digits to the left, and fills the num least significant bits with 1.

shiftr0

MnemonicInstruction Format
shiftr0 rx, #num010000 | rx | 010 | num

Move all bits num digits to the right, and fills the num most significant bits with 0.

shiftr1

MnemonicInstruction Format
shiftr1 rx, #num010000 | rx | 011 | num

Move all bits num digits to the right, and fills the num most significant bits with 1.

info

In all bit movement instructions, num is a 4-bit positive integer.

Input/Output

Input

MnemonicInstruction Format
inchar rx110101 | rx | xxxxxxx

Stores in rx a value corresponding to a key pressed at the moment the instruction is read.

info

The value stored when no key is pressed is 255.

Output

MnemonicInstruction Format
outchar rx, ry110010 | rx | xxxx

Prints on the screen at index ry the character at index rx.

Stack

Stores (push) or removes (pop) data from the stack.

MnemonicInstruction Format
push rx000101 | rx | 0 | xxxxxx
push fr000101 | xxx | 1 | xxxxxx
pop rx000110 | rx | 0 | xxxxxx
push fr000110 | xxx | 1 | xxxxxx

Comparison

MnemonicInstruction Format
cmp rx, ry010110 | rx | ry | xxxx

Depending on the result of the comparison between the values stored in rx and ry, the fr register assumes a value to indicate if rx is equal, greater, or less than ry.

Jump

If the condition is met in fr, then pc = *label

MnemonicConditionInstruction Format
jmp labelUnconditional000010 | 0000 | xxxxxx
jeq labelEQual000010 | 0001 | xxxxxx
jne labelNot Equal000010 | 0010 | xxxxxx
jz labelZero000010 | 0011 | xxxxxx
jnz labelNot Zero000010 | 0100 | xxxxxx
jc labelCarry000010 | 0101 | xxxxxx
jnc labelNo Carry000010 | 0110 | xxxxxx
jgr labelGReater than000010 | 0110 | xxxxxx
jle labelLEsser than000010 | 1000 | xxxxxx
jeg labelEqual or Greater000010 | 1001 | xxxxxx
jel labelEqual or Lesser000010 | 1010 | xxxxxx
jov labelOVerflow000010 | 1011 | xxxxxx
jnov labelNo OVerflow000010 | 1100 | xxxxxx
jn labelNegative000010 | 1101 | xxxxxx
jdz labelDivision by Zero000010 | 1110 | xxxxxx

Call

If the condition is met in fr, then execute the following instructions:

push pc
jmp label
MnemonicConditionInstruction Format
call labelUnconditional000011 | 0000 | xxxxxx
ceq labelEQual000011 | 0001 | xxxxxx
cne labelNot Equal000011 | 0010 | xxxxxx
cz labelZero000011 | 0011 | xxxxxx
cnz labelNot Zero000011 | 0100 | xxxxxx
cc labelCarry000011 | 0101 | xxxxxx
cnc labelNo Carry000011 | 0110 | xxxxxx
cgr labelGReater than000011 | 0110 | xxxxxx
cle labelLEsser than000011 | 1000 | xxxxxx
ceg labelEqual or Greater000011 | 1001 | xxxxxx
cel labelEqual or Lesser000011 | 1010 | xxxxxx
cov labelOVerflow000011 | 1011 | xxxxxx
cnov labelNo OVerflow000011 | 1100 | xxxxxx
cn labelNegative000011 | 1101 | xxxxxx
cdz labelDivision by Zero000011 | 1110 | xxxxxx

Return

Complementing the call instruction, this performs:

loadi pc, sp
inc sp
inc pc
MnemonicInstruction Format
rts000100 | xxxx | x | xxxxx

Control

MnemonicActionInstruction Format
clearcc = 0001000 | 0 | xxxxxxxxx
setcc = 1001000 | 1 | xxxxxxxxx
haltStop program execution001111 | xxxxxxxxxx
nopNo operation000000 | xxxxxxxxxx
breakpInsert breakpoint001110 | xxxxxxxxxx