attempt to fix build
[pcsx_rearmed.git] / deps / libchdr / deps / lzma-22.01 / src / Asm / x86 / 7zAsm.asm
CommitLineData
9e052883 1; 7zAsm.asm -- ASM macros\r
2; 2022-05-16 : Igor Pavlov : Public domain\r
3\r
4\r
5; UASM can require these changes\r
6; OPTION FRAMEPRESERVEFLAGS:ON\r
7; OPTION PROLOGUE:NONE\r
8; OPTION EPILOGUE:NONE\r
9\r
10ifdef @wordsize\r
11; @wordsize is defined only in JWASM and ASMC and is not defined in MASM\r
12; @wordsize eq 8 for 64-bit x64\r
13; @wordsize eq 2 for 32-bit x86\r
14if @wordsize eq 8\r
15 x64 equ 1\r
16endif\r
17else\r
18ifdef RAX\r
19 x64 equ 1\r
20endif\r
21endif\r
22\r
23\r
24ifdef x64\r
25 IS_X64 equ 1\r
26else\r
27 IS_X64 equ 0\r
28endif\r
29\r
30ifdef ABI_LINUX\r
31 IS_LINUX equ 1\r
32else\r
33 IS_LINUX equ 0\r
34endif\r
35\r
36ifndef x64\r
37; Use ABI_CDECL for x86 (32-bit) only\r
38; if ABI_CDECL is not defined, we use fastcall abi\r
39ifdef ABI_CDECL\r
40 IS_CDECL equ 1\r
41else\r
42 IS_CDECL equ 0\r
43endif\r
44endif\r
45\r
46OPTION PROLOGUE:NONE \r
47OPTION EPILOGUE:NONE\r
48\r
49MY_ASM_START macro\r
50 ifdef x64\r
51 .code\r
52 else\r
53 .386\r
54 .model flat\r
55 _TEXT$00 SEGMENT PARA PUBLIC 'CODE'\r
56 endif\r
57endm\r
58\r
59MY_PROC macro name:req, numParams:req\r
60 align 16\r
61 proc_numParams = numParams\r
62 if (IS_X64 gt 0)\r
63 proc_name equ name\r
64 elseif (IS_LINUX gt 0)\r
65 proc_name equ name\r
66 elseif (IS_CDECL gt 0)\r
67 proc_name equ @CatStr(_,name)\r
68 else\r
69 proc_name equ @CatStr(@,name,@, %numParams * 4)\r
70 endif\r
71 proc_name PROC\r
72endm\r
73\r
74MY_ENDP macro\r
75 if (IS_X64 gt 0)\r
76 ret\r
77 elseif (IS_CDECL gt 0)\r
78 ret\r
79 elseif (proc_numParams LT 3)\r
80 ret\r
81 else\r
82 ret (proc_numParams - 2) * 4\r
83 endif\r
84 proc_name ENDP\r
85endm\r
86\r
87\r
88ifdef x64\r
89 REG_SIZE equ 8\r
90 REG_LOGAR_SIZE equ 3\r
91else\r
92 REG_SIZE equ 4\r
93 REG_LOGAR_SIZE equ 2\r
94endif\r
95\r
96 x0 equ EAX\r
97 x1 equ ECX\r
98 x2 equ EDX\r
99 x3 equ EBX\r
100 x4 equ ESP\r
101 x5 equ EBP\r
102 x6 equ ESI\r
103 x7 equ EDI\r
104\r
105 x0_W equ AX\r
106 x1_W equ CX\r
107 x2_W equ DX\r
108 x3_W equ BX\r
109\r
110 x5_W equ BP\r
111 x6_W equ SI\r
112 x7_W equ DI\r
113\r
114 x0_L equ AL\r
115 x1_L equ CL\r
116 x2_L equ DL\r
117 x3_L equ BL\r
118\r
119 x0_H equ AH\r
120 x1_H equ CH\r
121 x2_H equ DH\r
122 x3_H equ BH\r
123\r
124ifdef x64\r
125 x5_L equ BPL\r
126 x6_L equ SIL\r
127 x7_L equ DIL\r
128\r
129 r0 equ RAX\r
130 r1 equ RCX\r
131 r2 equ RDX\r
132 r3 equ RBX\r
133 r4 equ RSP\r
134 r5 equ RBP\r
135 r6 equ RSI\r
136 r7 equ RDI\r
137 x8 equ r8d\r
138 x9 equ r9d\r
139 x10 equ r10d\r
140 x11 equ r11d\r
141 x12 equ r12d\r
142 x13 equ r13d\r
143 x14 equ r14d\r
144 x15 equ r15d\r
145else\r
146 r0 equ x0\r
147 r1 equ x1\r
148 r2 equ x2\r
149 r3 equ x3\r
150 r4 equ x4\r
151 r5 equ x5\r
152 r6 equ x6\r
153 r7 equ x7\r
154endif\r
155\r
156\r
157ifdef x64\r
158ifdef ABI_LINUX\r
159\r
160MY_PUSH_2_REGS macro\r
161 push r3\r
162 push r5\r
163endm\r
164\r
165MY_POP_2_REGS macro\r
166 pop r5\r
167 pop r3\r
168endm\r
169\r
170endif\r
171endif\r
172\r
173\r
174MY_PUSH_4_REGS macro\r
175 push r3\r
176 push r5\r
177 push r6\r
178 push r7\r
179endm\r
180\r
181MY_POP_4_REGS macro\r
182 pop r7\r
183 pop r6\r
184 pop r5\r
185 pop r3\r
186endm\r
187\r
188\r
189; for fastcall and for WIN-x64\r
190REG_PARAM_0_x equ x1\r
191REG_PARAM_0 equ r1\r
192REG_PARAM_1_x equ x2\r
193REG_PARAM_1 equ r2\r
194\r
195ifndef x64\r
196; for x86-fastcall\r
197\r
198REG_ABI_PARAM_0_x equ REG_PARAM_0_x\r
199REG_ABI_PARAM_0 equ REG_PARAM_0\r
200REG_ABI_PARAM_1_x equ REG_PARAM_1_x\r
201REG_ABI_PARAM_1 equ REG_PARAM_1\r
202\r
203else\r
204; x64\r
205\r
206if (IS_LINUX eq 0)\r
207\r
208; for WIN-x64:\r
209REG_PARAM_2_x equ x8\r
210REG_PARAM_2 equ r8\r
211REG_PARAM_3 equ r9\r
212\r
213REG_ABI_PARAM_0_x equ REG_PARAM_0_x\r
214REG_ABI_PARAM_0 equ REG_PARAM_0\r
215REG_ABI_PARAM_1_x equ REG_PARAM_1_x\r
216REG_ABI_PARAM_1 equ REG_PARAM_1\r
217REG_ABI_PARAM_2_x equ REG_PARAM_2_x\r
218REG_ABI_PARAM_2 equ REG_PARAM_2\r
219REG_ABI_PARAM_3 equ REG_PARAM_3\r
220\r
221else\r
222; for LINUX-x64:\r
223REG_LINUX_PARAM_0_x equ x7\r
224REG_LINUX_PARAM_0 equ r7\r
225REG_LINUX_PARAM_1_x equ x6\r
226REG_LINUX_PARAM_1 equ r6\r
227REG_LINUX_PARAM_2 equ r2\r
228REG_LINUX_PARAM_3 equ r1\r
229REG_LINUX_PARAM_4_x equ x8\r
230REG_LINUX_PARAM_4 equ r8\r
231REG_LINUX_PARAM_5 equ r9\r
232\r
233REG_ABI_PARAM_0_x equ REG_LINUX_PARAM_0_x\r
234REG_ABI_PARAM_0 equ REG_LINUX_PARAM_0\r
235REG_ABI_PARAM_1_x equ REG_LINUX_PARAM_1_x\r
236REG_ABI_PARAM_1 equ REG_LINUX_PARAM_1\r
237REG_ABI_PARAM_2 equ REG_LINUX_PARAM_2\r
238REG_ABI_PARAM_3 equ REG_LINUX_PARAM_3\r
239REG_ABI_PARAM_4_x equ REG_LINUX_PARAM_4_x\r
240REG_ABI_PARAM_4 equ REG_LINUX_PARAM_4\r
241REG_ABI_PARAM_5 equ REG_LINUX_PARAM_5\r
242\r
243MY_ABI_LINUX_TO_WIN_2 macro\r
244 mov r2, r6\r
245 mov r1, r7\r
246endm\r
247\r
248MY_ABI_LINUX_TO_WIN_3 macro\r
249 mov r8, r2\r
250 mov r2, r6\r
251 mov r1, r7\r
252endm\r
253\r
254MY_ABI_LINUX_TO_WIN_4 macro\r
255 mov r9, r1\r
256 mov r8, r2\r
257 mov r2, r6\r
258 mov r1, r7\r
259endm\r
260\r
261endif ; IS_LINUX\r
262\r
263\r
264MY_PUSH_PRESERVED_ABI_REGS macro\r
265 if (IS_LINUX gt 0)\r
266 MY_PUSH_2_REGS\r
267 else\r
268 MY_PUSH_4_REGS\r
269 endif\r
270 push r12\r
271 push r13\r
272 push r14\r
273 push r15\r
274endm\r
275\r
276\r
277MY_POP_PRESERVED_ABI_REGS macro\r
278 pop r15\r
279 pop r14\r
280 pop r13\r
281 pop r12\r
282 if (IS_LINUX gt 0)\r
283 MY_POP_2_REGS\r
284 else\r
285 MY_POP_4_REGS\r
286 endif\r
287endm\r
288\r
289endif ; x64\r