/
isa.txt
64 lines (50 loc) · 1.18 KB
/
isa.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
62
63
64
; r0: PC
; r1-r15: normal registers
li rd,imm
mv rd,r1
add rd,r1,r2
sub rd,r1,r2
mul rd,r1,r2
div rd,r1,r2
lt rd,r1,r2
lte rd,r1,r2
;gt rd,r1,r2 -> lt rd,r2,r1
;gte rd,r1,r2 -> lte rd,r2,r1
not rd,r1
and rd,r1,r2
or rd,r1,r2
xor rd,r1,r2
sll rd,r1,r2
slr rd,r1,r2
sar rd,r1,r2
call rd,dest
; j dest -> mv r0,dest
jnz r1,dest
jz r1,dest
jnzr r2,r1
jzr r2,r1
; load destreg, [address]
; store [address], value
l8 rd,r1
s8 r1,r2
l16 rd,r1
s16 r1,r2
l32 rd,r1
s32 r1,r2
l64 rd,r1
s64 r1,r2
Instruction encoding:
0 6 7 10 11 14 15 18 19 64
+--------+------+------+------+---------------------+
| opcode | rd | r1 | r2 | immediate[0:44] |
+--------+------+------+------+---------------------+
Calling convention:
Push arguments on the stack in reverse order, such that the first argument is
at the stack tip. Then push all closure items on the stack in reverse order,
such that now the first closure item is at the stack tip. Then execute a call
instruction.
Afterwards, the caller should clean up the pushed values from the stack.
The callee is responsible for backing up the link register on the stack.
Return register: r13
Link register: r14
Stack pointer: r15