-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.inc
242 lines (208 loc) · 5.77 KB
/
macros.inc
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
;=============
; Local macros
;=============
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
;just a space saving macro
LOAD MACRO dest, src
mov eax, src
mov dest, eax
ENDM
m2m MACRO M1, M2
push M2
pop M1
ENDM
return MACRO arg
mov eax, arg
ret
ENDM
stralloc MACRO ln
invoke SysAllocStringByteLen,0,ln
ENDM
strfree MACRO strhandle
invoke SysFreeString,strhandle
ENDM
QUAD MACRO name,value
.data
name QWORD value
.code
ENDM
; --------------------------------------------------
; Macro for placing an assembler instruction either
; within another or within a procedure call
; --------------------------------------------------
ASM MACRO parameter1,source
LOCAL mnemonic
LOCAL dest
LOCAL poz
% poz INSTR 1,<parameter1>,< > ;; get the space position
mnemonic SUBSTR <parameter1>, 1, poz-1 ;; get the mnemonic
dest SUBSTR <parameter1>, poz+1 ;; get the first argument
mnemonic dest, source
EXITM <dest>
ENDM
; ------------------------------------------------------------
; Macro for nesting function calls in other invoke statements
; ------------------------------------------------------------
FUNC MACRO parameters:VARARG
invoke parameters
EXITM <eax>
ENDM
; -----------------------------------------------------
; Macros for declaring named floating point variables
; -----------------------------------------------------
FLOAT4 MACRO name,value
.data
name REAL4 value
.code
ENDM
FLOAT8 MACRO name,value
.data
name REAL8 value
.code
ENDM
FLOAT10 MACRO name,value
.data
name REAL10 value
.code
ENDM
; -----------------------------------------------------
; Macros for directly inserting floating point values
; into floating point instructions and as parameters
; -----------------------------------------------------
FP4 MACRO value
LOCAL vname
.data
vname REAL4 value
.code
EXITM <vname>
ENDM
FP8 MACRO value
LOCAL vname
.data
vname REAL8 value
.code
EXITM <vname>
ENDM
FP10 MACRO value
LOCAL vname
.data
vname REAL10 value
.code
EXITM <vname>
ENDM
; -------------------------
; initialised GLOBAL value
; -------------------------
IGLOBAL MACRO variable:VARARG
.data
variable
.code
ENDM
; --------------------------------
; initialised GLOBAL string value
; --------------------------------
STRING MACRO variable:REQ,args:VARARG
.data
variable db args,0
.code
ENDM
; ---------------------
; literal string MACRO
; ---------------------
literal MACRO quoted_text:VARARG
LOCAL local_text
.data
local_text db quoted_text,0
.code
EXITM <local_text>
ENDM
; --------------------------------
; string address in INVOKE format
; --------------------------------
SADD MACRO quoted_text:VARARG
EXITM <ADDR literal(quoted_text)>
ENDM
; --------------------------------
; string OFFSET for manual coding
; --------------------------------
CTXT MACRO quoted_text:VARARG
EXITM <offset literal(quoted_text)>
ENDM
ShellAboutBox MACRO handle,IconHandle,quoted_Text_1,quoted_Text_2:VARARG
LOCAL AboutTitle,AboutMsg,buffer
.data
AboutTitle db quoted_Text_1,0
AboutMsg db quoted_Text_2,0
buffer db 128 dup (0)
.code
mov esi, offset AboutTitle
mov edi, offset buffer
mov ecx, lengthof AboutTitle
rep movsb
invoke ShellAbout,handle,ADDR buffer,ADDR AboutMsg,IconHandle
ENDM
AppModel MACRO Processor
Processor ;; Processor type
.model flat, stdcall ;; 32 bit memory model
option casemap :none ;; case sensitive
ENDM
DisplayMenu MACRO handl, IDnum
invoke LoadMenu,hInstance,IDnum
invoke SetMenu,handl,eax
ENDM
DisplayWindow MACRO handl, ShowStyle
invoke ShowWindow,handl, ShowStyle
invoke UpdateWindow,handl
ENDM
AutoScale MACRO swidth, sheight
invoke GetPercent,sWid,swidth
mov Wwd, eax
invoke GetPercent,sHgt,sheight
mov Wht, eax
invoke TopXY,Wwd,sWid
mov Wtx, eax
invoke TopXY,Wht,sHgt
mov Wty, eax
ENDM
SingleInstanceOnly MACRO lpClassName
invoke FindWindow,lpClassName,NULL
cmp eax, 0
je @F
push eax
invoke ShowWindow,eax,SW_RESTORE
pop eax
invoke SetForegroundWindow,eax
mov eax, 0
ret
@@:
ENDM
GLOBAL MACRO var1,var2,var3,var4,var5,var6,var7,var8,var9,var0,
varA,varB,varC,varD,varE,varF,varG,varH,varI,varJ
.data?
var1
var2
var3
var4
var5
var6
var7
var8
var9
var0
varA
varB
varC
varD
varE
varF
varG
varH
varI
varJ
.code
ENDM