-
Notifications
You must be signed in to change notification settings - Fork 0
/
reference_sheet.txt
61 lines (54 loc) · 2.93 KB
/
reference_sheet.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
r = register
d = data
m = memory (Special Symbols: msize, mtop)
lbl = label
Registers $0-$9 can hold 64 bit values.
Registers $f0-$f4 can hold 64 bit floating point values.
--- li | instructions
0 - print num no newline
1 - print char no newline
2 - print string
3 - input num (non float)
4 - input num (float)
5 - input char
6 - input string (non format)
7 - input string (format)
8 - generate random number - c rand() func
9 - reset (clear registers and memory)
10 - print num newline
11 - print char newline
-- CORE --
li (int) - Loads an instruction into the flag ($B)
la (r) - Sets pointer ($A) to a register.
mov (r1, r2) | (d, r) - Moves data to register.
syscall - Calls instruction in flag ($B)
copy (r1, r2) - Copies data from r1 to r2.
jmp (lbl) - Jumps to label (unconditional).
return - Terminates program.
-- MEMMANIP --
mmov (r, m) | (d, m) - Moves data to memory.
mret (m, r) - Retreives data from memory into $A, or r if defined..
mcpy (m1, m2) - Copies memory from m1 to m2.
minx (m, d, r) - Gets value at index at memory address, stores result in $A, or in r if defined.
mdel (m) - Deletes memory from stack.
-- MATH --
add (r1, r2) | (d, r) | (r, d) | (d, d) & (r) - Performs addition on two data. Stores result in $A. Optional register in 3rd argument which will store the result there instead of $A.
sub (r1, r2) | (d, r) | (r, d) | (d, d) & (r) - Performs subtraction on two data. Stores result in $A. Optional register in 3rd argument which will store the result there instead of $A.
mul (r1, r2) | (d, r) | (r, d) | (d, d) & (r) - Performs multiplication on two data. Stores result in $A. Optional register in 3rd argument which will store the result there instead of $A.
div (r1, r2) | (d, r) | (r, d) | (d, d) & (r) - Performs division on two data. Stores result in $A. Optional register in 3rd argument which will store the result there instead of $A.
mod (r1, r2) | (d, r) | (r, d) | (d, d) & (r) - Performs modulo on two data. Stores result in $A. Optional register in 3rd argument which will store the result there instead of $A.
-- LOGIC --
cmp (r1, r2) | (d, r) | (r, d) | (d1, d2) - Compares 2 data. 1 if arg1 > arg2, 0 if arg1 = arg2, -1 if arg1 < arg2.
jeq (lbl) - Jumps to label if $A == 0
jne (lbl) - Jumps to label if $A != 0
jae (lbl) - Jumps to label if $A >= 0
jue (lbl) - Jumps to label if $A <= 0
ja (lbl) - Jumps to label if $A > 0
ju (lbl) - Jumps to label if $A < 0
-- BITWISE --
band (r1, r2) | (d, r) | (r, d) | (d, d) - Performs bitwise AND (&) operation and stores result in $A.
bor (r1, r2) | (d, r) | (r, d) | (d, d) - Performs bitwise OR (|) operation and stores result in $A.
bxor (r1, r2) | (d, r) | (r, d) | (d, d) - Performs bitwise XOR (^) operation and stores result in $A.
bnot (r1, r2) | (d, r) | (r, d) | (d, d) - Performs bitwise NOT (!) operation and stores result in $A.
bsl (r) | (d) - Performs bitshift left (<<) operation and stores result in $A.
bsr (r) | (d) - Performs bitshift right (>>) operation and stores result in $A.