-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFISH_NXP_M0_MACROS.h
157 lines (126 loc) · 2.76 KB
/
FISH_NXP_M0_MACROS.h
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//ss SET 1 // "single-step" switch for debug/shakedown testing
//#define ss
//------------------------------------------------------------------------------
// Inner Interpreter Macros
// Beauty is you can put any ISA in a macro and no prob till referenced!
// IF ss
#ifdef ss
NEXT1 MACRO
LDR x, =ssNEXT1 // meta-single-step for debugging
BX x
ENDM
// LTORG
// ELSE
#else
NEXT1 MACRO
LDM w!, {x} // contents of cfa, (pfa), -> x, bump w to cfa+4
BLX x // w preserves cfa+4 (pfa) for DOCOL's benefit
ENDM
#endif
// ENDIF
NEXT MACRO
LDM i!, {w} // get cfa addr to w, incr i after
NEXT1
ENDM
TPUSH MACRO
PUSHt // push t to p, pre decrement p
NEXT
ENDM
DPUSH MACRO
PUSHw // push w to p, pre decrement p
TPUSH
ENDM
//------------------------------------------------------------------------------
// FISH STACK MACRO's
// Beauty is you can put any ISA in a macro and no prob till referenced!
// Cortex M0 THUMB only does STMia and LDMia
// I (rstack value to pstack) expects POP to be post increment
// Meaning that TOS is = to current p or r
// Therefore PUSH is pre decrement
PUSHt MACRO
SUBS p, p, #4 // push t to p, pre decrement p
STR t, [p]
ENDM
POP2t MACRO
#ifndef TOSCT
LDR t, [p] // pop tos to t, post increment p
#endif
ADDS p, p, #4
ENDM
NDPOP2t MACRO // macro = copy tos to t, leave it on the stack
LDR t, [p]
ENDM
PUSHn MACRO
SUBS p, p, #4 // push n to p, pre decrement p
STR n, [p]
ENDM
POP2n MACRO
LDR n, [p]
ADDS p, p, #4
ENDM
PUSHw MACRO
SUBS p, p, #4 // push w to p, pre decrement p
STR w, [p]
ENDM
POP2w MACRO
LDR w, [p]
ADDS p, p, #4
ENDM
NDPOP2w MACRO // macro = copy tos to w, leave it on the stack
LDR w, [p]
ENDM
PUSHx MACRO
SUBS p, p, #4 // push x to p, pre decrement p
STR x, [p]
ENDM
POP2x MACRO
LDR x, [p]
ADDS p, p, #4
ENDM
NDPOP2x MACRO // macro = copy tos to w, leave it on the stack
LDR x, [p]
ENDM
PUSHi MACRO
SUBS p, p, #4 // push i to p, pore increment p
STR i, [p]
ENDM
POP2i MACRO
LDR i, [p]
ADDS p, p, #4
ENDM
PUSHt2r MACRO
SUBS r, r, #4 // push t to r, pre decrement r
STR t, [r]
ENDM
PUSHi2r MACRO
SUBS r, r, #4 // push i to r, pre decrement r
STR i, [r]
ENDM
POPr2i MACRO
LDR i, [r] // pop r to i, post increment r
ADDS r, r, #4
ENDM
//POP2p MACRO
// ENDM
//POP2PC MACRO
// ENDM
POPr2t MACRO
LDR t, [r]
ADDS r, r, #4
ENDM
PUSHn2r MACRO
SUBS r, r, #4 // push t to r, pre decrement r
STR n, [r]
ENDM
PUSHw2r MACRO
SUBS r, r, #4 // push w to r, pre decrement r
STR w, [r]
ENDM
LIT2t MACRO
// as in xeq token at ToS setup for lit
LDM i!, {t} // fetch memory p points to into {t}, inc i
ENDM
POPp2w MACRO
// as in xeq token at ToS setup for exec
LDM p!, {w} // fetch memory p points to into {w}, inc p
ENDM