[go: up one dir, main page]

Menu

[4cf102]: / frame.inc  Maximize  Restore  History

Download this file

212 lines (188 with data), 3.3 kB

  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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
%ifdef WINDOWS
;
; frame [parameters] [locals] [new_parameters]
; parameters > 4 on stack
;
%macro frame 0-2 0,0,0 ; %1, %2 & %3 default to 0
%if %3 <= 4
%assign xp 0
%else
%assign xp %3-4
%endif
%if %2 <= 4
%assign locals 0
%else
%assign locals %2-4
%endif
; Subtract enough for locals and then parameters past 6
%assign frame_size (4+locals+xp+1)/2*16
%endmacro
%undef xp
%undef locals
; Windows
; First 4 local variables are in the stack frame
local1 equ 16
local2 equ 24
local3 equ 32
local4 equ 40
; Local variables after 4 relative to rfp with negative offsets
;
; local5 will be -8
; local6 will be -16
; ...
; local100 be be -768
; [rfp+localX]
%macro local 1
local%1 equ -8*(%1-4)
%endmacro
%assign i 5
%rep 100
local i
%assign i i+1
%endrep
%undef i
; Windows
; Where to place extra parameters when you call a function with
; more than 4 parameters.
;
; newPar5 will be 32
; newPar6 will be 40
; ...
; newPar100 will be 99*8 = 792
; [rsp+newParX]
%macro newpar 1
newPar%1 equ 8*(i-1)
%endmacro
%assign i 5
%rep 96
newpar i
%assign i i+1
%endrep
%undef i
; Windows
; Where to find additional parameters to current function
; past parameter 4
;
; currPar5 will be 48
; currPar6 will be 56
; ...
; currPar100 will be 808
; [rfp+currParX]
%macro parequ 1
currPar%1 equ 16+8*(%1+1)
%endmacro
%assign i 5
%rep 96
parequ i
%assign i i+1
%endrep
%undef i
%else ; Linux/OS X
;
; frame [parameters] [locals] [new_parameters]
; parameters > 6 on stack
;
%macro frame 0-3 0 ; %2 defaults to 0
%if %3 <= 6
%assign xp 0
%else
%assign xp %3-6
%endif
; Subtract enough for locals and then parameters past 6
%assign frame_size (%2+xp+1)/2*16
%endmacro
%undef xp
; Linux
; Local variables accessed relative to rfp with negative offsets
;
; local1 will be -8
; local2 will be -16
; ...
; local100 be be -800
; [rfp+localX]
%macro local 1
local%1 equ -8*%1
%endmacro
%assign i 1
%rep 100
local i
%assign i i+1
%endrep
%undef i
; Linux
; Where to place extra parameters when you call a function with
; more than 6 parameters.
;
; newPar7 will be 0
; newPar8 will be 8
; ...
; newPar100 will be 93*8 = 744
; [rsp+newParX]
%macro newpar 1
newPar%1 equ 8*(i-7)
%endmacro
%assign i 7
%rep 94
newpar i
%assign i i+1
%endrep
%undef i
; Linux
; Where to find additional parameters to current function
; past parameter 6
;
; currPar7 will be 16
; currPar8 will be 24
; ...
; currPar100 will be 760
; [rfp+currParX]
%macro parequ 1
currPar%1 equ 16+8*(%1-7)
%endmacro
%assign i 7
%rep 94
parequ i
%assign i i+1
%endrep
%undef i
%endif ; from original test on WINDOWS
%macro multipush 2-*
%rep %0
push %1
%rotate 1
%endrep
%endmacro
%macro multipop 2-*
%rep %0
pop %1
%rotate 1
%endrep
%endmacro
%macro alias 2
%define q%1 %2
%define d%1 %2d
%define w%1 %2w
%define b%1 %2b
%define h%1 %2h
%endmacro
%macro unalias 1-*
%rep %0
%undef q%1
%undef d%1
%undef w%1
%undef b%1
%undef h%1
%rotate 1
%endrep
%endmacro
%macro fpalias 2
%define y%1 ymm%2
%define x%1 xmm%2
%endmacro
%macro fpunalias 1-*
%rep %0
%undef y%1
%undef x%1
%rotate 1
%endrep
%endmacro