-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathassembler.asi
92 lines (80 loc) · 1.93 KB
/
assembler.asi
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
@ Copyright (c) 2009, Gerard Lledo Vives <[email protected]>
@ This program is open source. For license terms, see the LICENSE file.
@ All these macros assume r0 to be the compilation pointer, unless a
@ dest parameter is given.
@
@ Note the difference of giving a register by name (r3) or by number
@ (#3). The first will use r3's value at compilation time as an
@ immediate at execution time. The second will use r3 as it is in
@ the execution context.
@ Registers bitmaps are separated in 2 parameters to make them of an
@ immediate size.
.macro GPUSH regs_hi, regs_lo
mov r1, \regs_hi
lsl r1, #8
orr r1, \regs_lo
orr r1, #0xE9000000
orr r1, #0x002D0000
str r1, [r0], #4
.endm
.macro GPOP regs_hi, regs_lo
mov r1, \regs_hi
lsl r1, #8
orr r1, \regs_lo
orr r1, #0xE8000000
orr r1, #0x00BD0000
str r1, [r0], #4
.endm
@ 'orig' is where the instruction will be written
.macro GB cond, orig, dest
sub r1, \dest, \orig
sub r1, #8
asr r1, #2
bic r1, #0xFF000000
.ifc \cond, EQ
orr r1, #0x0A000000
.endif
.ifc \cond, NE
orr r1, #0x1A000000
.endif
.ifc \cond, AL
orr r1, #0xEA000000
.endif
str r1, [\orig], #4
.endm
.macro GBX reg
mov r1, #0xE1000000
orr r1, #0x002F0000
orr r1, #0x0000FF00
orr r1, #0x00000010
orr r1, \reg
str r1, [r0], #4
.endm
@ 'type' is there to mark whether is a register or a immediate in
@ param. Note that when source is immediate it should fit on 8 bits.
.macro GMOV type, dest, source
mov r1, \dest
lsl r1, #12
orr r1, #0xE0000000
.ifc \type, R
orr r1, #0x01A00000
.endif
.ifc \type, I
orr r1, #0x03A00000
.endif
orr r1, \source
str r1, [r0], #4
.endm
@ For our purpouses we just orr immediates with immediate shifts
.macro GORR dest, reg, imm, shift=0
mov r1, \reg
lsl r1, #4
orr r1, \dest
lsl r1, #4
orr r1, \shift
lsl r1, #8
orr r1, \imm
orr r1, #0xE3000000
orr r1, #0x00800000
str r1, [r0], #4
.endm