nasm/misc/c32.mac

53 lines
550 B
Plaintext
Raw Normal View History

2002-05-01 04:52:49 +08:00
; NASM macro set to make interfacing to 32-bit programs easier -*- nasm -*-
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%imacro proc 1 ; begin a procedure definition
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%push proc
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
global %1
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%1: push ebp
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
mov ebp,esp
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%assign %$arg 8
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%define %$procname %1
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%endmacro
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%imacro arg 0-1 4 ; used with the argument name as a label
2002-05-01 05:08:11 +08:00
%00 equ %$arg
2002-05-01 04:52:49 +08:00
%assign %$arg %1+%$arg
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%endmacro
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%imacro endproc 0
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%ifnctx proc
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%error Mismatched `endproc'/`proc'
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%else
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
leave
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
ret
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
__end_%$procname: ; useful for calculating function size
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%pop
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%endif
2002-05-01 05:08:11 +08:00
2002-05-01 04:52:49 +08:00
%endmacro
2002-05-01 05:08:11 +08:00