Skip to content

Commit 0858d31

Browse files
author
Alex Cole
committed
Switch to using register names in all assembly.
1 parent ce80fe5 commit 0858d31

14 files changed

+117
-116
lines changed

amx_base.inc

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
#endif
4444

4545
#if __pawn_build >= 10
46-
#define HasSysreqD() (bool:(__emit(zero.pri, lctrl 9, eq.c.pri 0)))
47-
#define HasReloc() (bool:(__emit(zero.pri, lctrl 9, const.alt 512, and, eq.c.pri 0)))
46+
#define HasSysreqD() (bool:(__emit(zero.pri, lctrl __flg, eq.c.pri 0)))
47+
#define HasReloc() (bool:(__emit(zero.pri, lctrl __flg, const.alt 512, and, eq.c.pri 0)))
4848
#else
4949
forward bool:HasSysreqD();
5050
forward bool:HasReloc();
@@ -68,9 +68,9 @@ stock GetAmxBaseAddressNow() {
6868
assert(HasReloc());
6969

7070
new cod = 0, dat = 0;
71-
#emit lctrl 0
71+
#emit lctrl __cod
7272
#emit stor.s.pri cod
73-
#emit lctrl 1
73+
#emit lctrl __dat
7474
#emit stor.s.pri dat
7575

7676
// Get code section start address relative to data.
@@ -84,7 +84,7 @@ stock GetAmxBaseAddressNow() {
8484
// Get absolute address from the CALL instruction.
8585
new fn_addr_reloc = 0, call_addr = 0;
8686
GetAmxBaseAddress_helper();
87-
#emit lctrl 6
87+
#emit lctrl __cip
8888
#emit stor.s.pri call_addr
8989
#if cellbits == 32
9090
call_addr = call_addr - 12 + code_start;
@@ -117,7 +117,7 @@ stock bool:HasSysreqD() {
117117
// SA:MP doesn't have the AMX flags in register 9, open.mp does. Thus if
118118
// `pri` is 0 it wasn't set by the control register.
119119
#emit zero.pri
120-
#emit lctrl 9 // flags
120+
#emit lctrl __flg // flags
121121
#emit eq.c.pri 0
122122
#emit retn
123123

@@ -129,7 +129,7 @@ stock bool:HasReloc() {
129129
// SA:MP doesn't have the AMX flags in register 9, open.mp does. Thus if
130130
// `pri` is 0 it wasn't set by the control register.
131131
#emit zero.pri
132-
#emit lctrl 9 // flags
132+
#emit lctrl __flg // flags
133133
#emit const.alt 512
134134
#emit and
135135
#emit eq.c.pri 0

amx_header.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ forward PrintAmxHeader();
198198
/// <library>amx_assembly amx_header</library>
199199
stock GetRawAmxHeader(plain_amxhdr[AMX_HDR_CELLS]) {
200200
new address = 0;
201-
#emit lctrl 1 // DAT
201+
#emit lctrl __dat // DAT
202202
#emit neg // -DAT
203203
#emit stor.s.pri address
204204

amx_jit.inc

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
/// <library>amx_assembly amx_jit</library>
4040
stock GetJITGeneratorVersion() {
4141
#emit zero.pri
42-
#emit lctrl 7
42+
#emit lctrl __jit
4343
#emit retn
4444
return 0;
4545
}
@@ -50,7 +50,7 @@ stock GetAmxJITBaseAddress() {
5050
// so short, checking if it had been done before would have been longer than
5151
// just repeating the calculation.
5252
#emit zero.pri
53-
#emit lctrl 8
53+
#emit lctrl __jmp
5454
#emit retn
5555
return 0;
5656
}
@@ -61,7 +61,7 @@ stock ResolveJITAddress(addr) {
6161
// nothing. Could make it try detect if this is already JIT resolved, i.e.
6262
// is a return address.
6363
#emit load.s.pri addr
64-
#emit lctrl 8
64+
#emit lctrl __jmp
6565
#emit retn
6666
return 0;
6767
}

amx_memory.inc

+17-18
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ stock GetAmxHeapBase() {
157157
const cells2 = 1 * cellbytes;
158158
// Initial heap pointer. Not stored in an accessible register so read it
159159
// straight from the original header.
160-
#emit lctrl 1 // DAT
161-
#emit neg // -DAT
160+
#emit lctrl __dat // DAT
161+
#emit neg // -DAT
162162
#emit add.c cells0 // -DAT + 20
163163
#emit push.pri
164164
#emit lref.s.pri cells1
@@ -171,23 +171,23 @@ stock GetAmxHeapBase() {
171171
stock GetAmxHeapTop()
172172
{
173173
// Current heap pointer.
174-
#emit lctrl 2
174+
#emit lctrl __hea
175175
#emit retn
176176
return 0;
177177
}
178178

179179
/// <library>amx_assembly amx_memory</library>
180180
stock GetAmxStackBase()
181181
{
182-
#emit lctrl 3
182+
#emit lctrl __stp
183183
#emit retn
184184
return 0;
185185
}
186186

187187
/// <library>amx_assembly amx_memory</library>
188188
stock GetAmxStackBottom() {
189189
const cells0 = 3 * cellbytes;
190-
#emit lctrl 4
190+
#emit lctrl __stk
191191
#emit add.c cells0
192192
#emit retn
193193
return 0;
@@ -207,29 +207,28 @@ stock GetAmxFrame()
207207
stock SetAmxHeapTop(ptr)
208208
{
209209
#emit load.s.pri ptr
210-
#emit sctrl 2
210+
#emit sctrl __hea
211211
}
212212

213213
/// <library>amx_assembly amx_memory</library>
214214
stock SetAmxStackBottom(ptr) {
215215
const cells0 = 1 * cellbytes;
216-
static
217-
cip = 0;
216+
static cip = 0;
218217
// We need to be tricky here, because the return value is on the stack.
219218
#emit load.s.alt ptr
220219
// Store the return address.
221220
#emit load.s.pri cells0
222221
#emit stor.pri cip
223222
// Reset the frame.
224223
#emit load.s.pri 0
225-
#emit sctrl 5
224+
#emit sctrl __frm
226225
// Modify the stack.
227226
#emit move.pri
228-
#emit sctrl 4
227+
#emit sctrl __stk
229228
// Return.
230229
#emit load.pri cip
231-
#emit sctrl 8
232-
#emit sctrl 6
230+
#emit sctrl __jmp
231+
#emit sctrl __cip
233232
}
234233

235234
/// <library>amx_assembly amx_memory</library>
@@ -241,12 +240,12 @@ stock SetAmxFrame(ptr) {
241240
#emit load.s.alt cells0
242241
// Modify the frame.
243242
#emit load.s.pri ptr
244-
#emit sctrl 5
243+
#emit sctrl __frm
245244
// Return.
246245
#emit move.pri
247246
#emit stack cells1
248-
#emit sctrl 8
249-
#emit sctrl 6
247+
#emit sctrl __jmp
248+
#emit sctrl __cip
250249
}
251250

252251
/// <library>amx_assembly amx_memory</library>
@@ -255,12 +254,12 @@ stock SetAmxNextInstructionPointer(ptr) {
255254
#emit load.s.alt ptr
256255
// Reset the frame.
257256
#emit load.s.pri 0
258-
#emit sctrl 5
257+
#emit sctrl __frm
259258
// Return.
260259
#emit move.pri
261260
#emit stack cells0
262-
#emit sctrl 8
263-
#emit sctrl 6
261+
#emit sctrl __jmp
262+
#emit sctrl __cip
264263
}
265264

266265
#if __pawn_build >= 10

codescan.inc

+6-6
Original file line numberDiff line numberDiff line change
@@ -875,24 +875,24 @@ static stock CodeScanCall(const cs[CodeScanMatcher], matcher__, csState[CodeScan
875875
#emit PUSH.S param
876876
#emit PUSH.S csState
877877
#emit PUSH.C cells0
878-
#emit LCTRL 6
878+
#emit LCTRL __cip
879879
#emit ADD.C cells1
880-
#emit LCTRL 8
880+
#emit LCTRL __jmp
881881
#emit PUSH.pri
882882
#emit LOAD.S.pri func
883-
#emit SCTRL 6
883+
#emit SCTRL __cip
884884
#emit STOR.S.pri func
885885
} else {
886886
const cells2 = 1 * cellbytes;
887887
const cells3 = 9 * cellbytes;
888888
#emit PUSH.S csState
889889
#emit PUSH.C cells2
890-
#emit LCTRL 6
890+
#emit LCTRL __cip
891891
#emit ADD.C cells3
892-
#emit LCTRL 8
892+
#emit LCTRL __jmp
893893
#emit PUSH.pri
894894
#emit LOAD.S.pri func
895-
#emit SCTRL 6
895+
#emit SCTRL __cip
896896
#emit STOR.S.pri func
897897
}
898898
return func;

0 commit comments

Comments
 (0)