xref: /reactos/sdk/lib/ucrt/inc/macamd64.inc (revision 04e0dc4a)
1*04e0dc4aSTimo Kreuzer;++
2*04e0dc4aSTimo Kreuzer;
3*04e0dc4aSTimo Kreuzer; Copyright (c) Microsoft Corporation.  All rights reserved.
4*04e0dc4aSTimo Kreuzer;
5*04e0dc4aSTimo Kreuzer;
6*04e0dc4aSTimo Kreuzer; Module:
7*04e0dc4aSTimo Kreuzer;
8*04e0dc4aSTimo Kreuzer;   macamd64.w
9*04e0dc4aSTimo Kreuzer;
10*04e0dc4aSTimo Kreuzer; Astract:
11*04e0dc4aSTimo Kreuzer;
12*04e0dc4aSTimo Kreuzer;   Contains AMD64 public architecture constants and assembly macros.
13*04e0dc4aSTimo Kreuzer;
14*04e0dc4aSTimo Kreuzer; Author:
15*04e0dc4aSTimo Kreuzer;--
16*04e0dc4aSTimo Kreuzer
17*04e0dc4aSTimo Kreuzer;++
18*04e0dc4aSTimo Kreuzer;
19*04e0dc4aSTimo Kreuzer; push_reg <reg>
20*04e0dc4aSTimo Kreuzer;
21*04e0dc4aSTimo Kreuzer; Macro Description:
22*04e0dc4aSTimo Kreuzer;
23*04e0dc4aSTimo Kreuzer;   This macro emits a single-byte push <reg> instruction in a
24*04e0dc4aSTimo Kreuzer;   nested prologue, as well as the associated unwind code.
25*04e0dc4aSTimo Kreuzer;
26*04e0dc4aSTimo Kreuzer; Arguments:
27*04e0dc4aSTimo Kreuzer;
28*04e0dc4aSTimo Kreuzer;   reg - supplies the integer register to push
29*04e0dc4aSTimo Kreuzer;
30*04e0dc4aSTimo Kreuzer;--
31*04e0dc4aSTimo Kreuzer
32*04e0dc4aSTimo Kreuzerpush_reg macro Reg
33*04e0dc4aSTimo Kreuzer
34*04e0dc4aSTimo Kreuzer        push    Reg
35*04e0dc4aSTimo Kreuzer        .pushreg Reg
36*04e0dc4aSTimo Kreuzer
37*04e0dc4aSTimo Kreuzer        endm
38*04e0dc4aSTimo Kreuzer
39*04e0dc4aSTimo Kreuzer;++
40*04e0dc4aSTimo Kreuzer;
41*04e0dc4aSTimo Kreuzer; rex_push_reg <reg>
42*04e0dc4aSTimo Kreuzer;
43*04e0dc4aSTimo Kreuzer; Macro Description:
44*04e0dc4aSTimo Kreuzer;
45*04e0dc4aSTimo Kreuzer;   This macro emits a single-byte push <reg> instruction in a
46*04e0dc4aSTimo Kreuzer;   nested prologue, as well as the associated unwind code.
47*04e0dc4aSTimo Kreuzer;
48*04e0dc4aSTimo Kreuzer;   This differs from push_reg only in that a redundant rex prefix
49*04e0dc4aSTimo Kreuzer;   is added.  rex_push_reg must be used in lieu of push_reg when it
50*04e0dc4aSTimo Kreuzer;   appears as the first instruction in a function, as the calling
51*04e0dc4aSTimo Kreuzer;   standard dictates that functions must not begin with a single
52*04e0dc4aSTimo Kreuzer;   byte instruction.
53*04e0dc4aSTimo Kreuzer;
54*04e0dc4aSTimo Kreuzer; Arguments:
55*04e0dc4aSTimo Kreuzer;
56*04e0dc4aSTimo Kreuzer;   reg - supplies the integer register to push
57*04e0dc4aSTimo Kreuzer;
58*04e0dc4aSTimo Kreuzer;--
59*04e0dc4aSTimo Kreuzer
60*04e0dc4aSTimo Kreuzerrex_push_reg macro Reg
61*04e0dc4aSTimo Kreuzer
62*04e0dc4aSTimo Kreuzer        db      048h
63*04e0dc4aSTimo Kreuzer        push    Reg
64*04e0dc4aSTimo Kreuzer        .pushreg Reg
65*04e0dc4aSTimo Kreuzer
66*04e0dc4aSTimo Kreuzer        endm
67*04e0dc4aSTimo Kreuzer
68*04e0dc4aSTimo Kreuzer;++
69*04e0dc4aSTimo Kreuzer;
70*04e0dc4aSTimo Kreuzer; push_eflags
71*04e0dc4aSTimo Kreuzer;
72*04e0dc4aSTimo Kreuzer; Macro Description:
73*04e0dc4aSTimo Kreuzer;
74*04e0dc4aSTimo Kreuzer;   This macro emits a single-byte pushfq instruction in a
75*04e0dc4aSTimo Kreuzer;   nested prologue, as well as the associated unwind code.
76*04e0dc4aSTimo Kreuzer;
77*04e0dc4aSTimo Kreuzer; Arguments:
78*04e0dc4aSTimo Kreuzer;
79*04e0dc4aSTimo Kreuzer;   none
80*04e0dc4aSTimo Kreuzer;
81*04e0dc4aSTimo Kreuzer;--
82*04e0dc4aSTimo Kreuzer
83*04e0dc4aSTimo Kreuzerpush_eflags macro
84*04e0dc4aSTimo Kreuzer
85*04e0dc4aSTimo Kreuzer        pushfq
86*04e0dc4aSTimo Kreuzer        .allocstack 8
87*04e0dc4aSTimo Kreuzer
88*04e0dc4aSTimo Kreuzer        endm
89*04e0dc4aSTimo Kreuzer
90*04e0dc4aSTimo Kreuzer;++
91*04e0dc4aSTimo Kreuzer;
92*04e0dc4aSTimo Kreuzer; rex_push_eflags
93*04e0dc4aSTimo Kreuzer;
94*04e0dc4aSTimo Kreuzer; Macro Description:
95*04e0dc4aSTimo Kreuzer;
96*04e0dc4aSTimo Kreuzer;   This macro emits a single-byte pushfq instruction in a
97*04e0dc4aSTimo Kreuzer;   nested prologue, as well as the associated unwind code.
98*04e0dc4aSTimo Kreuzer;
99*04e0dc4aSTimo Kreuzer;   This differs from push_eflags only in that a redundant rex prefix
100*04e0dc4aSTimo Kreuzer;   is added.  rex_push_eflags must be used in lieu of push_eflags when it
101*04e0dc4aSTimo Kreuzer;   appears as the first instruction in a function, as the calling
102*04e0dc4aSTimo Kreuzer;   standard dictates that functions must not begin with a single
103*04e0dc4aSTimo Kreuzer;   byte instruction.
104*04e0dc4aSTimo Kreuzer;
105*04e0dc4aSTimo Kreuzer; Arguments:
106*04e0dc4aSTimo Kreuzer;
107*04e0dc4aSTimo Kreuzer;   none
108*04e0dc4aSTimo Kreuzer;
109*04e0dc4aSTimo Kreuzer;--
110*04e0dc4aSTimo Kreuzer
111*04e0dc4aSTimo Kreuzerrex_push_eflags macro
112*04e0dc4aSTimo Kreuzer
113*04e0dc4aSTimo Kreuzer        db      048h
114*04e0dc4aSTimo Kreuzer        pushfq
115*04e0dc4aSTimo Kreuzer        .allocstack 8
116*04e0dc4aSTimo Kreuzer
117*04e0dc4aSTimo Kreuzer        endm
118*04e0dc4aSTimo Kreuzer
119*04e0dc4aSTimo Kreuzer;++
120*04e0dc4aSTimo Kreuzer;
121*04e0dc4aSTimo Kreuzer; rex_jmp_reg <reg>
122*04e0dc4aSTimo Kreuzer;
123*04e0dc4aSTimo Kreuzer; Macro Description:
124*04e0dc4aSTimo Kreuzer;
125*04e0dc4aSTimo Kreuzer;   This macro emits a jmp <reg> instruction in a nested epilogue.
126*04e0dc4aSTimo Kreuzer;
127*04e0dc4aSTimo Kreuzer;   This differs from jmp reg only in that a redundant rex prefix
128*04e0dc4aSTimo Kreuzer;   is added.  rex_jmp_reg must be be used in lieu of jmp when it
129*04e0dc4aSTimo Kreuzer;   appears as a tail call terminating an epilogue of a function,
130*04e0dc4aSTimo Kreuzer;   as the calling dictates that functions that exit an epilogue
131*04e0dc4aSTimo Kreuzer;   with a jmp reg must include a redundant rex prefix to signify
132*04e0dc4aSTimo Kreuzer;   the presence of a tail call epilogue to the unwinder.
133*04e0dc4aSTimo Kreuzer;
134*04e0dc4aSTimo Kreuzer; Arguments:
135*04e0dc4aSTimo Kreuzer;
136*04e0dc4aSTimo Kreuzer;   reg - supplies the integer register to jump to.
137*04e0dc4aSTimo Kreuzer;
138*04e0dc4aSTimo Kreuzer;--
139*04e0dc4aSTimo Kreuzer
140*04e0dc4aSTimo Kreuzerrex_jmp_reg macro Reg
141*04e0dc4aSTimo Kreuzer
142*04e0dc4aSTimo Kreuzer   rexw jmp Reg
143*04e0dc4aSTimo Kreuzer
144*04e0dc4aSTimo Kreuzer        endm
145*04e0dc4aSTimo Kreuzer
146*04e0dc4aSTimo Kreuzer;++
147*04e0dc4aSTimo Kreuzer;
148*04e0dc4aSTimo Kreuzer; ret_zero
149*04e0dc4aSTimo Kreuzer;
150*04e0dc4aSTimo Kreuzer; Macro Description:
151*04e0dc4aSTimo Kreuzer;
152*04e0dc4aSTimo Kreuzer;   This macro emits a three byte return instruction.
153*04e0dc4aSTimo Kreuzer;
154*04e0dc4aSTimo Kreuzer;   This differs from the typical ret in that it adds additional padding bytes
155*04e0dc4aSTimo Kreuzer;   that prevent branch misprediction problems when the ret is the target of
156*04e0dc4aSTimo Kreuzer;   a (un)conditional branch, or is immediately preceded by a conditional branch.
157*04e0dc4aSTimo Kreuzer;
158*04e0dc4aSTimo Kreuzer; Arguments:
159*04e0dc4aSTimo Kreuzer;
160*04e0dc4aSTimo Kreuzer;   none
161*04e0dc4aSTimo Kreuzer;
162*04e0dc4aSTimo Kreuzer;--
163*04e0dc4aSTimo Kreuzer
164*04e0dc4aSTimo Kreuzerret_zero macro
165*04e0dc4aSTimo Kreuzer
166*04e0dc4aSTimo Kreuzer        ret
167*04e0dc4aSTimo Kreuzer
168*04e0dc4aSTimo Kreuzer        endm
169*04e0dc4aSTimo Kreuzer
170*04e0dc4aSTimo Kreuzer;++
171*04e0dc4aSTimo Kreuzer;
172*04e0dc4aSTimo Kreuzer; alloc_stack <Size>
173*04e0dc4aSTimo Kreuzer;
174*04e0dc4aSTimo Kreuzer; Macro Description:
175*04e0dc4aSTimo Kreuzer;
176*04e0dc4aSTimo Kreuzer;   This macro emits an opcode to subtract <Size> from rsp, as well
177*04e0dc4aSTimo Kreuzer;   as the associated unwind code.
178*04e0dc4aSTimo Kreuzer;
179*04e0dc4aSTimo Kreuzer; Arguments:
180*04e0dc4aSTimo Kreuzer;
181*04e0dc4aSTimo Kreuzer;   Size - The number of bytes to subtract from rsp.
182*04e0dc4aSTimo Kreuzer;
183*04e0dc4aSTimo Kreuzer;--
184*04e0dc4aSTimo Kreuzer
185*04e0dc4aSTimo Kreuzeralloc_stack macro Size
186*04e0dc4aSTimo Kreuzer
187*04e0dc4aSTimo Kreuzer        sub     rsp, Size
188*04e0dc4aSTimo Kreuzer        .allocstack Size
189*04e0dc4aSTimo Kreuzer
190*04e0dc4aSTimo Kreuzer        endm
191*04e0dc4aSTimo Kreuzer
192*04e0dc4aSTimo Kreuzer;++
193*04e0dc4aSTimo Kreuzer;
194*04e0dc4aSTimo Kreuzer; save_reg   <Reg>, <Offset>
195*04e0dc4aSTimo Kreuzer;
196*04e0dc4aSTimo Kreuzer; Macro Description:
197*04e0dc4aSTimo Kreuzer;
198*04e0dc4aSTimo Kreuzer;   This macro emits an opcode to save the non-volatile 64-bit general purpose
199*04e0dc4aSTimo Kreuzer;   register indicated by <Reg> at offset <Offset> relative to the current
200*04e0dc4aSTimo Kreuzer;   position of the stack pointer.  It also generates the associated unwind
201*04e0dc4aSTimo Kreuzer;   code.
202*04e0dc4aSTimo Kreuzer;
203*04e0dc4aSTimo Kreuzer; Arguments:
204*04e0dc4aSTimo Kreuzer;
205*04e0dc4aSTimo Kreuzer;   Reg - Supplies the integer register to save
206*04e0dc4aSTimo Kreuzer;
207*04e0dc4aSTimo Kreuzer;   Offset - Supplies the offset relative to the current position of the stack
208*04e0dc4aSTimo Kreuzer;            pointer.
209*04e0dc4aSTimo Kreuzer;
210*04e0dc4aSTimo Kreuzer;--
211*04e0dc4aSTimo Kreuzer
212*04e0dc4aSTimo Kreuzersave_reg macro Reg, Offset
213*04e0dc4aSTimo Kreuzer
214*04e0dc4aSTimo Kreuzer        mov     Offset[rsp], Reg
215*04e0dc4aSTimo Kreuzer        .savereg Reg, Offset
216*04e0dc4aSTimo Kreuzer
217*04e0dc4aSTimo Kreuzer        endm
218*04e0dc4aSTimo Kreuzer
219*04e0dc4aSTimo Kreuzer;++
220*04e0dc4aSTimo Kreuzer;
221*04e0dc4aSTimo Kreuzer; save_xmm128   <Reg>, <Offset>
222*04e0dc4aSTimo Kreuzer;
223*04e0dc4aSTimo Kreuzer; Macro Description:
224*04e0dc4aSTimo Kreuzer;
225*04e0dc4aSTimo Kreuzer;   This macro emits an opcode to save the 128-bit non-volatile xmm register
226*04e0dc4aSTimo Kreuzer;   indicated by <Reg> at offset <Offset> relative to the current position
227*04e0dc4aSTimo Kreuzer;   of the stack pointer.  It also generates the associated unwind code.
228*04e0dc4aSTimo Kreuzer;
229*04e0dc4aSTimo Kreuzer; Arguments:
230*04e0dc4aSTimo Kreuzer;
231*04e0dc4aSTimo Kreuzer;   Reg - Supplies the xmm register register to save
232*04e0dc4aSTimo Kreuzer;
233*04e0dc4aSTimo Kreuzer;   Offset - Supplies the offset relative to the current position of the stack
234*04e0dc4aSTimo Kreuzer;            pointer.
235*04e0dc4aSTimo Kreuzer;
236*04e0dc4aSTimo Kreuzer;--
237*04e0dc4aSTimo Kreuzer
238*04e0dc4aSTimo Kreuzersave_xmm128 macro Reg, Offset
239*04e0dc4aSTimo Kreuzer
240*04e0dc4aSTimo Kreuzer        movaps  Offset[rsp], Reg
241*04e0dc4aSTimo Kreuzer        .savexmm128 Reg, Offset
242*04e0dc4aSTimo Kreuzer
243*04e0dc4aSTimo Kreuzer        endm
244*04e0dc4aSTimo Kreuzer
245*04e0dc4aSTimo Kreuzer;++
246*04e0dc4aSTimo Kreuzer;
247*04e0dc4aSTimo Kreuzer; push_frame
248*04e0dc4aSTimo Kreuzer;
249*04e0dc4aSTimo Kreuzer; Macro Description:
250*04e0dc4aSTimo Kreuzer;
251*04e0dc4aSTimo Kreuzer;   This macro emits unwind data indicating that a machine frame has been
252*04e0dc4aSTimo Kreuzer;   pushed on the stack (usually by the CPU in response to a trap or fault).
253*04e0dc4aSTimo Kreuzer;
254*04e0dc4aSTimo Kreuzer; Arguments:
255*04e0dc4aSTimo Kreuzer;
256*04e0dc4aSTimo Kreuzer;   None.
257*04e0dc4aSTimo Kreuzer;
258*04e0dc4aSTimo Kreuzer;--
259*04e0dc4aSTimo Kreuzer
260*04e0dc4aSTimo Kreuzerpush_frame macro Code
261*04e0dc4aSTimo Kreuzer
262*04e0dc4aSTimo Kreuzer        .pushframe Code
263*04e0dc4aSTimo Kreuzer
264*04e0dc4aSTimo Kreuzer        endm
265*04e0dc4aSTimo Kreuzer
266*04e0dc4aSTimo Kreuzer;++
267*04e0dc4aSTimo Kreuzer;
268*04e0dc4aSTimo Kreuzer; set_frame <Reg>, <Offset>
269*04e0dc4aSTimo Kreuzer;
270*04e0dc4aSTimo Kreuzer; Macro Description:
271*04e0dc4aSTimo Kreuzer;
272*04e0dc4aSTimo Kreuzer;   This macro emits an opcode and unwind data establishing the use of <Reg>
273*04e0dc4aSTimo Kreuzer;   as the current stack frame pointer.
274*04e0dc4aSTimo Kreuzer;
275*04e0dc4aSTimo Kreuzer; Arguments:
276*04e0dc4aSTimo Kreuzer;
277*04e0dc4aSTimo Kreuzer;   Reg - Supplies the integer register to use as the current stack frame
278*04e0dc4aSTimo Kreuzer;         pointer.
279*04e0dc4aSTimo Kreuzer;
280*04e0dc4aSTimo Kreuzer;   Offset - Supplies the optional offset of the frame pointer relative to
281*04e0dc4aSTimo Kreuzer;            the stack frame.  In stack frames greater than 080h bytes,
282*04e0dc4aSTimo Kreuzer;            a non-zero offset can help reduce the size of subsequent opcodes
283*04e0dc4aSTimo Kreuzer;            that access portions of the stack frame by facilitating the use of
284*04e0dc4aSTimo Kreuzer;            positive and negative single-byte displacements.
285*04e0dc4aSTimo Kreuzer;
286*04e0dc4aSTimo Kreuzer;            If not supplied, no offset is assumed.
287*04e0dc4aSTimo Kreuzer;
288*04e0dc4aSTimo Kreuzer;--
289*04e0dc4aSTimo Kreuzer
290*04e0dc4aSTimo Kreuzerset_frame macro Reg, Offset
291*04e0dc4aSTimo Kreuzer
292*04e0dc4aSTimo Kreuzerif Offset
293*04e0dc4aSTimo Kreuzer
294*04e0dc4aSTimo Kreuzer        lea     Reg, Offset[rsp]
295*04e0dc4aSTimo Kreuzer
296*04e0dc4aSTimo Kreuzerelse
297*04e0dc4aSTimo Kreuzer
298*04e0dc4aSTimo Kreuzer        mov     Reg, rsp
299*04e0dc4aSTimo Kreuzer
300*04e0dc4aSTimo Kreuzerendif
301*04e0dc4aSTimo Kreuzer
302*04e0dc4aSTimo Kreuzer        .setframe Reg, Offset
303*04e0dc4aSTimo Kreuzer
304*04e0dc4aSTimo Kreuzer        endm
305*04e0dc4aSTimo Kreuzer
306*04e0dc4aSTimo Kreuzer;++
307*04e0dc4aSTimo Kreuzer;
308*04e0dc4aSTimo Kreuzer; END_PROLOGUE
309*04e0dc4aSTimo Kreuzer;
310*04e0dc4aSTimo Kreuzer; Macro Description:
311*04e0dc4aSTimo Kreuzer;
312*04e0dc4aSTimo Kreuzer;   This macro marks the end of the prologue.  This must appear after all
313*04e0dc4aSTimo Kreuzer;   of the prologue directives in a nested function.
314*04e0dc4aSTimo Kreuzer;
315*04e0dc4aSTimo Kreuzer; Arguments:
316*04e0dc4aSTimo Kreuzer;
317*04e0dc4aSTimo Kreuzer;   None.
318*04e0dc4aSTimo Kreuzer;
319*04e0dc4aSTimo Kreuzer;--
320*04e0dc4aSTimo Kreuzer
321*04e0dc4aSTimo KreuzerEND_PROLOGUE macro
322*04e0dc4aSTimo Kreuzer
323*04e0dc4aSTimo Kreuzer        .endprolog
324*04e0dc4aSTimo Kreuzer
325*04e0dc4aSTimo Kreuzer        endm
326*04e0dc4aSTimo Kreuzer
327*04e0dc4aSTimo Kreuzer;++
328*04e0dc4aSTimo Kreuzer;
329*04e0dc4aSTimo Kreuzer; Macro Description:
330*04e0dc4aSTimo Kreuzer;
331*04e0dc4aSTimo Kreuzer;   This macro marks the beginning of a function epilogue. It may appear
332*04e0dc4aSTimo Kreuzer;   one or more times within a function body. The epilogue ends at the
333*04e0dc4aSTimo Kreuzer;   next control transfer instruction.
334*04e0dc4aSTimo Kreuzer;
335*04e0dc4aSTimo Kreuzer; Arguments:
336*04e0dc4aSTimo Kreuzer;
337*04e0dc4aSTimo Kreuzer;   None.
338*04e0dc4aSTimo Kreuzer;
339*04e0dc4aSTimo Kreuzer;--
340*04e0dc4aSTimo Kreuzer
341*04e0dc4aSTimo KreuzerBEGIN_EPILOGUE macro
342*04e0dc4aSTimo Kreuzer
343*04e0dc4aSTimo Kreuzer        .beginepilog
344*04e0dc4aSTimo Kreuzer
345*04e0dc4aSTimo Kreuzer        endm
346*04e0dc4aSTimo Kreuzer
347*04e0dc4aSTimo Kreuzer;++
348*04e0dc4aSTimo Kreuzer;
349*04e0dc4aSTimo Kreuzer; LEAF_ENTRY <Name>, <Section>, <NoPad>
350*04e0dc4aSTimo Kreuzer;
351*04e0dc4aSTimo Kreuzer; Macro Description:
352*04e0dc4aSTimo Kreuzer;
353*04e0dc4aSTimo Kreuzer;   This macro indicates the beginning of a leaf function.
354*04e0dc4aSTimo Kreuzer;
355*04e0dc4aSTimo Kreuzer;   A leaf function is one that DOES NOT:
356*04e0dc4aSTimo Kreuzer;
357*04e0dc4aSTimo Kreuzer;   - manipulate non-volatile registers
358*04e0dc4aSTimo Kreuzer;   - manipulate the stack pointer
359*04e0dc4aSTimo Kreuzer;   - call other functions
360*04e0dc4aSTimo Kreuzer;   - reference an exception handler
361*04e0dc4aSTimo Kreuzer;   - contain a prologue
362*04e0dc4aSTimo Kreuzer;   - have any unwind data associated with it
363*04e0dc4aSTimo Kreuzer;
364*04e0dc4aSTimo Kreuzer; Arguments:
365*04e0dc4aSTimo Kreuzer;
366*04e0dc4aSTimo Kreuzer;   Name - Supplies the name of the function
367*04e0dc4aSTimo Kreuzer;
368*04e0dc4aSTimo Kreuzer;   Section - Supplies the name of the section within which the function
369*04e0dc4aSTimo Kreuzer;             is to appear
370*04e0dc4aSTimo Kreuzer;
371*04e0dc4aSTimo Kreuzer;   NoPad - If present, indicates that the function should not be prefixed
372*04e0dc4aSTimo Kreuzer;           with 6 bytes of padding.  This is for internal use only - the
373*04e0dc4aSTimo Kreuzer;           calling standard dictates that functions (nested and leaf) must
374*04e0dc4aSTimo Kreuzer;           be prefixed with padding.
375*04e0dc4aSTimo Kreuzer;
376*04e0dc4aSTimo Kreuzer;--
377*04e0dc4aSTimo Kreuzer
378*04e0dc4aSTimo KreuzerLEAF_ENTRY macro Name, Section, NoPad
379*04e0dc4aSTimo Kreuzer
380*04e0dc4aSTimo KreuzerSection segment para 'CODE'
381*04e0dc4aSTimo Kreuzer
382*04e0dc4aSTimo Kreuzerifb <NoPad>
383*04e0dc4aSTimo Kreuzer
384*04e0dc4aSTimo Kreuzer        db      6 dup (0cch)
385*04e0dc4aSTimo Kreuzer
386*04e0dc4aSTimo Kreuzerendif
387*04e0dc4aSTimo Kreuzer
388*04e0dc4aSTimo Kreuzer        align   16
389*04e0dc4aSTimo Kreuzer
390*04e0dc4aSTimo Kreuzer        public  Name
391*04e0dc4aSTimo KreuzerName    proc    frame
392*04e0dc4aSTimo Kreuzer
393*04e0dc4aSTimo Kreuzer        END_PROLOGUE
394*04e0dc4aSTimo Kreuzer
395*04e0dc4aSTimo Kreuzer        endm
396*04e0dc4aSTimo Kreuzer
397*04e0dc4aSTimo Kreuzer;++
398*04e0dc4aSTimo Kreuzer;
399*04e0dc4aSTimo Kreuzer;  LEAF_ENTRY_ARG1 <Name>, <Section>, <Arg1>, <NoPad>
400*04e0dc4aSTimo Kreuzer;
401*04e0dc4aSTimo Kreuzer; Macro Description:
402*04e0dc4aSTimo Kreuzer;
403*04e0dc4aSTimo Kreuzer; Indicates the beginning of a leaf function, as LEAF_ENTRY above,
404*04e0dc4aSTimo Kreuzer; and declares one input parameter so that debug info will be
405*04e0dc4aSTimo Kreuzer; generated for it. The other forms, LEAF_ENTRY_ARG2 and LEAF_ENTRY_ARG3,
406*04e0dc4aSTimo Kreuzer; are similar.
407*04e0dc4aSTimo Kreuzer;
408*04e0dc4aSTimo Kreuzer;--
409*04e0dc4aSTimo Kreuzer
410*04e0dc4aSTimo KreuzerLEAF_ENTRY_ARG1 macro Name, Section, Arg1, NoPad
411*04e0dc4aSTimo Kreuzer
412*04e0dc4aSTimo KreuzerSection segment para 'CODE'
413*04e0dc4aSTimo Kreuzer
414*04e0dc4aSTimo Kreuzerifb <NoPad>
415*04e0dc4aSTimo Kreuzer
416*04e0dc4aSTimo Kreuzer        db      6 dup (0cch)
417*04e0dc4aSTimo Kreuzer
418*04e0dc4aSTimo Kreuzerendif
419*04e0dc4aSTimo Kreuzer
420*04e0dc4aSTimo Kreuzer        align   16
421*04e0dc4aSTimo Kreuzer
422*04e0dc4aSTimo Kreuzer        public  Name
423*04e0dc4aSTimo KreuzerName    proc    frame
424*04e0dc4aSTimo Kreuzer
425*04e0dc4aSTimo Kreuzer        END_PROLOGUE
426*04e0dc4aSTimo Kreuzer
427*04e0dc4aSTimo Kreuzer        endm
428*04e0dc4aSTimo Kreuzer
429*04e0dc4aSTimo Kreuzer;++
430*04e0dc4aSTimo Kreuzer;
431*04e0dc4aSTimo Kreuzer; LEAF_ENTRY_ARG2 <Name>, <Section>, <Arg1>, <Arg2>, <NoPad>
432*04e0dc4aSTimo Kreuzer;
433*04e0dc4aSTimo Kreuzer; Macro Description:
434*04e0dc4aSTimo Kreuzer;
435*04e0dc4aSTimo Kreuzer; As LEAF_ENTRY_ARG1 above, marks the entry to a leaf function
436*04e0dc4aSTimo Kreuzer; and defines 2 input parameters.
437*04e0dc4aSTimo Kreuzer;
438*04e0dc4aSTimo Kreuzer;--
439*04e0dc4aSTimo Kreuzer
440*04e0dc4aSTimo KreuzerLEAF_ENTRY_ARG2 macro Name, Section, Arg1, Arg2, NoPad
441*04e0dc4aSTimo Kreuzer
442*04e0dc4aSTimo KreuzerSection segment para 'CODE'
443*04e0dc4aSTimo Kreuzer
444*04e0dc4aSTimo Kreuzerifb <NoPad>
445*04e0dc4aSTimo Kreuzer
446*04e0dc4aSTimo Kreuzer        db      6 dup (0cch)
447*04e0dc4aSTimo Kreuzer
448*04e0dc4aSTimo Kreuzerendif
449*04e0dc4aSTimo Kreuzer
450*04e0dc4aSTimo Kreuzer        align   16
451*04e0dc4aSTimo Kreuzer
452*04e0dc4aSTimo Kreuzer        public  Name
453*04e0dc4aSTimo KreuzerName    proc    frame
454*04e0dc4aSTimo Kreuzer
455*04e0dc4aSTimo Kreuzer        END_PROLOGUE
456*04e0dc4aSTimo Kreuzer
457*04e0dc4aSTimo Kreuzer        endm
458*04e0dc4aSTimo Kreuzer
459*04e0dc4aSTimo Kreuzer;++
460*04e0dc4aSTimo Kreuzer;
461*04e0dc4aSTimo Kreuzer; LEAF_ENTRY_ARG3 <Name>, <Section>, <Arg1>, <Arg2>, <Arg3>, <NoPad>
462*04e0dc4aSTimo Kreuzer;
463*04e0dc4aSTimo Kreuzer; Macro Description:
464*04e0dc4aSTimo Kreuzer;
465*04e0dc4aSTimo Kreuzer; As LEAF_ENTRY_ARG1 above, marks the entry to a leaf function
466*04e0dc4aSTimo Kreuzer; and defines 3 input parameters.
467*04e0dc4aSTimo Kreuzer;
468*04e0dc4aSTimo Kreuzer;--
469*04e0dc4aSTimo Kreuzer
470*04e0dc4aSTimo KreuzerLEAF_ENTRY_ARG3 macro Name, Section, Arg1, Arg2, Arg3, NoPad
471*04e0dc4aSTimo Kreuzer
472*04e0dc4aSTimo KreuzerSection segment para 'CODE'
473*04e0dc4aSTimo Kreuzer
474*04e0dc4aSTimo Kreuzerifb <NoPad>
475*04e0dc4aSTimo Kreuzer
476*04e0dc4aSTimo Kreuzer        db      6 dup (0cch)
477*04e0dc4aSTimo Kreuzer
478*04e0dc4aSTimo Kreuzerendif
479*04e0dc4aSTimo Kreuzer
480*04e0dc4aSTimo Kreuzer        align   16
481*04e0dc4aSTimo Kreuzer
482*04e0dc4aSTimo Kreuzer        public  Name
483*04e0dc4aSTimo KreuzerName    proc    frame
484*04e0dc4aSTimo Kreuzer
485*04e0dc4aSTimo Kreuzer        END_PROLOGUE
486*04e0dc4aSTimo Kreuzer
487*04e0dc4aSTimo Kreuzer        endm
488*04e0dc4aSTimo Kreuzer
489*04e0dc4aSTimo Kreuzer;++
490*04e0dc4aSTimo Kreuzer;
491*04e0dc4aSTimo Kreuzer; LEAF_END <Name>, <Section>
492*04e0dc4aSTimo Kreuzer;
493*04e0dc4aSTimo Kreuzer; Macro Description:
494*04e0dc4aSTimo Kreuzer;
495*04e0dc4aSTimo Kreuzer;   This macro indicates the end of a leaf function.  It must be paired
496*04e0dc4aSTimo Kreuzer;   with a LEAF_ENTRY macro that includes matching Name and Section
497*04e0dc4aSTimo Kreuzer;   parameters.
498*04e0dc4aSTimo Kreuzer;
499*04e0dc4aSTimo Kreuzer; Arguments:
500*04e0dc4aSTimo Kreuzer;
501*04e0dc4aSTimo Kreuzer;   Name - Supplies the name of the function.  Must match that supplied to
502*04e0dc4aSTimo Kreuzer;          the corresponding LEAF_ENTRY macro.
503*04e0dc4aSTimo Kreuzer;
504*04e0dc4aSTimo Kreuzer;   Section - Supplies the name of the section within which the function
505*04e0dc4aSTimo Kreuzer;             is to appear.  Must match that supplied to the corresponding
506*04e0dc4aSTimo Kreuzer;             LEAF_ENTRY macro.
507*04e0dc4aSTimo Kreuzer;
508*04e0dc4aSTimo Kreuzer;--
509*04e0dc4aSTimo Kreuzer
510*04e0dc4aSTimo KreuzerLEAF_END macro Name, section
511*04e0dc4aSTimo Kreuzer
512*04e0dc4aSTimo KreuzerName    endp
513*04e0dc4aSTimo Kreuzer
514*04e0dc4aSTimo KreuzerSection ends
515*04e0dc4aSTimo Kreuzer
516*04e0dc4aSTimo Kreuzer        endm
517*04e0dc4aSTimo Kreuzer
518*04e0dc4aSTimo Kreuzer;++
519*04e0dc4aSTimo Kreuzer;
520*04e0dc4aSTimo Kreuzer; NESTED_ENTRY <Name>, <Section>, <Handler>, <NoPad>
521*04e0dc4aSTimo Kreuzer;
522*04e0dc4aSTimo Kreuzer; Macro Description:
523*04e0dc4aSTimo Kreuzer;
524*04e0dc4aSTimo Kreuzer;   This macro indicates the beginning of a nested function.
525*04e0dc4aSTimo Kreuzer;
526*04e0dc4aSTimo Kreuzer;   A nested function is one that does any of the following:
527*04e0dc4aSTimo Kreuzer;
528*04e0dc4aSTimo Kreuzer;   - manipulates non-volatile registers
529*04e0dc4aSTimo Kreuzer;   - manipulates the stack pointer
530*04e0dc4aSTimo Kreuzer;   - references an exception handler
531*04e0dc4aSTimo Kreuzer;   - calls other functions
532*04e0dc4aSTimo Kreuzer;
533*04e0dc4aSTimo Kreuzer;   A nested function must include a prologue with unwind data.
534*04e0dc4aSTimo Kreuzer;
535*04e0dc4aSTimo Kreuzer; Arguments:
536*04e0dc4aSTimo Kreuzer;
537*04e0dc4aSTimo Kreuzer;   Name - Supplies the name of the function.
538*04e0dc4aSTimo Kreuzer;
539*04e0dc4aSTimo Kreuzer;   Section - Supplies the name of the section within which the function
540*04e0dc4aSTimo Kreuzer;             is to appear.
541*04e0dc4aSTimo Kreuzer;
542*04e0dc4aSTimo Kreuzer;   Handler - Supplies the name of the handler for exceptions raised
543*04e0dc4aSTimo Kreuzer;             within the scope of this function.
544*04e0dc4aSTimo Kreuzer;
545*04e0dc4aSTimo Kreuzer;   NoPad - If present, indicates that the function should not be prefixed
546*04e0dc4aSTimo Kreuzer;           with 6 bytes of padding.  This is for internal use only - the
547*04e0dc4aSTimo Kreuzer;           calling standard dictates that functions (nested and leaf) must
548*04e0dc4aSTimo Kreuzer;           be prefixed with padding.
549*04e0dc4aSTimo Kreuzer;
550*04e0dc4aSTimo Kreuzer;--
551*04e0dc4aSTimo Kreuzer
552*04e0dc4aSTimo KreuzerNESTED_ENTRY macro Name, Section, Handler, NoPad
553*04e0dc4aSTimo Kreuzer
554*04e0dc4aSTimo Kreuzerifdef _CurrentSection_
555*04e0dc4aSTimo Kreuzer
556*04e0dc4aSTimo Kreuzerifdif <Section>, _CurrentSection_
557*04e0dc4aSTimo Kreuzer
558*04e0dc4aSTimo Kreuzer.err <NESTED_ENTRY invoked for different sections within same module>
559*04e0dc4aSTimo Kreuzer
560*04e0dc4aSTimo Kreuzerendif
561*04e0dc4aSTimo Kreuzer
562*04e0dc4aSTimo Kreuzerendif
563*04e0dc4aSTimo Kreuzer
564*04e0dc4aSTimo Kreuzer_CurrentSection_ EQU <Section>
565*04e0dc4aSTimo Kreuzer
566*04e0dc4aSTimo KreuzerSection segment para 'CODE'
567*04e0dc4aSTimo Kreuzer
568*04e0dc4aSTimo Kreuzerifb <NoPad>
569*04e0dc4aSTimo Kreuzer
570*04e0dc4aSTimo Kreuzer        db      6 dup (0cch)
571*04e0dc4aSTimo Kreuzer
572*04e0dc4aSTimo Kreuzerendif
573*04e0dc4aSTimo Kreuzer
574*04e0dc4aSTimo Kreuzer        align   16
575*04e0dc4aSTimo Kreuzer
576*04e0dc4aSTimo Kreuzer        public  Name
577*04e0dc4aSTimo Kreuzer
578*04e0dc4aSTimo Kreuzerifb <Handler>
579*04e0dc4aSTimo Kreuzer
580*04e0dc4aSTimo KreuzerName    proc    frame
581*04e0dc4aSTimo Kreuzer
582*04e0dc4aSTimo Kreuzerelse
583*04e0dc4aSTimo Kreuzer
584*04e0dc4aSTimo KreuzerName    proc    frame:Handler
585*04e0dc4aSTimo Kreuzer
586*04e0dc4aSTimo Kreuzerendif
587*04e0dc4aSTimo Kreuzer
588*04e0dc4aSTimo Kreuzer        endm
589*04e0dc4aSTimo Kreuzer
590*04e0dc4aSTimo Kreuzer;++
591*04e0dc4aSTimo Kreuzer;
592*04e0dc4aSTimo Kreuzer; NESTED_END <Name>, <Section>
593*04e0dc4aSTimo Kreuzer;
594*04e0dc4aSTimo Kreuzer; Macro Description:
595*04e0dc4aSTimo Kreuzer;
596*04e0dc4aSTimo Kreuzer;   This macro indicates the end of a nested function.  It must be paired
597*04e0dc4aSTimo Kreuzer;   with a NESTED_ENTRY macro that includes matching Name and Section
598*04e0dc4aSTimo Kreuzer;   parameters.
599*04e0dc4aSTimo Kreuzer;
600*04e0dc4aSTimo Kreuzer; Arguments:
601*04e0dc4aSTimo Kreuzer;
602*04e0dc4aSTimo Kreuzer;   Name - Supplies the name of the function.  Must match that supplied to
603*04e0dc4aSTimo Kreuzer;          the corresponding NESTED_ENTRY macro.
604*04e0dc4aSTimo Kreuzer;
605*04e0dc4aSTimo Kreuzer;   Section - Supplies the name of the section within which the function
606*04e0dc4aSTimo Kreuzer;             is to appear.  Must match that supplied to the corresponding
607*04e0dc4aSTimo Kreuzer;             NESTED_ENTRY macro.
608*04e0dc4aSTimo Kreuzer;
609*04e0dc4aSTimo Kreuzer;--
610*04e0dc4aSTimo Kreuzer
611*04e0dc4aSTimo KreuzerNESTED_END macro Name, section
612*04e0dc4aSTimo Kreuzer
613*04e0dc4aSTimo KreuzerName    endp
614*04e0dc4aSTimo Kreuzer
615*04e0dc4aSTimo KreuzerSection ends
616*04e0dc4aSTimo Kreuzer
617*04e0dc4aSTimo Kreuzer        endm
618*04e0dc4aSTimo Kreuzer
619*04e0dc4aSTimo Kreuzer;++
620*04e0dc4aSTimo Kreuzer;
621*04e0dc4aSTimo Kreuzer; ALTERNATE_ENTRY <Name>
622*04e0dc4aSTimo Kreuzer;
623*04e0dc4aSTimo Kreuzer; Macro Description:
624*04e0dc4aSTimo Kreuzer;
625*04e0dc4aSTimo Kreuzer;   This macro indicates an alternate entry point in a function, or
626*04e0dc4aSTimo Kreuzer;   a synonymous name for an existing function.
627*04e0dc4aSTimo Kreuzer;
628*04e0dc4aSTimo Kreuzer; Arguments:
629*04e0dc4aSTimo Kreuzer;
630*04e0dc4aSTimo Kreuzer;   Name - Supplies the name of the alternate entry point.
631*04e0dc4aSTimo Kreuzer;
632*04e0dc4aSTimo Kreuzer;--
633*04e0dc4aSTimo Kreuzer
634*04e0dc4aSTimo KreuzerALTERNATE_ENTRY macro Name
635*04e0dc4aSTimo Kreuzer
636*04e0dc4aSTimo KreuzerName:
637*04e0dc4aSTimo Kreuzer        endm
638*04e0dc4aSTimo Kreuzer
639*04e0dc4aSTimo Kreuzer;++
640*04e0dc4aSTimo Kreuzer;
641*04e0dc4aSTimo Kreuzer; Yield
642*04e0dc4aSTimo Kreuzer;
643*04e0dc4aSTimo Kreuzer; Macro Description:
644*04e0dc4aSTimo Kreuzer;
645*04e0dc4aSTimo Kreuzer;   This macro generates a yield instruction, interpreted by SMT processors
646*04e0dc4aSTimo Kreuzer;   as an indication of a stall or idle condition.
647*04e0dc4aSTimo Kreuzer;
648*04e0dc4aSTimo Kreuzer; Arguments:
649*04e0dc4aSTimo Kreuzer;
650*04e0dc4aSTimo Kreuzer;   None.
651*04e0dc4aSTimo Kreuzer;
652*04e0dc4aSTimo Kreuzer;--
653*04e0dc4aSTimo Kreuzer
654*04e0dc4aSTimo KreuzerYield   macro
655*04e0dc4aSTimo Kreuzer
656*04e0dc4aSTimo Kreuzer        pause                           ; yield execution on SMT processors
657*04e0dc4aSTimo Kreuzer
658*04e0dc4aSTimo Kreuzer        endm
659*04e0dc4aSTimo Kreuzer
660*04e0dc4aSTimo Kreuzer;++
661*04e0dc4aSTimo Kreuzer;
662*04e0dc4aSTimo Kreuzer; RetpolineIgnore
663*04e0dc4aSTimo Kreuzer;
664*04e0dc4aSTimo Kreuzer; Macro Description:
665*04e0dc4aSTimo Kreuzer;
666*04e0dc4aSTimo Kreuzer;   This macro generates a retpoline ignore directive which informs tools that
667*04e0dc4aSTimo Kreuzer;   retpoline instrumentation is not required.
668*04e0dc4aSTimo Kreuzer;
669*04e0dc4aSTimo Kreuzer; Arguments:
670*04e0dc4aSTimo Kreuzer;
671*04e0dc4aSTimo Kreuzer;   None.
672*04e0dc4aSTimo Kreuzer;
673*04e0dc4aSTimo Kreuzer;--
674*04e0dc4aSTimo Kreuzer
675*04e0dc4aSTimo KreuzerRetpolineIgnore macro
676*04e0dc4aSTimo Kreuzer
677*04e0dc4aSTimo Kreuzerifdef _RETPOLINE
678*04e0dc4aSTimo Kreuzer
679*04e0dc4aSTimo Kreuzer        .retpolineignore                ; mark branch as retpoline-ignored
680*04e0dc4aSTimo Kreuzer
681*04e0dc4aSTimo Kreuzerendif
682*04e0dc4aSTimo Kreuzer
683*04e0dc4aSTimo Kreuzer        endm
684*04e0dc4aSTimo Kreuzer
685*04e0dc4aSTimo Kreuzer
686