-
Notifications
You must be signed in to change notification settings - Fork 1
/
defines.inc
73 lines (56 loc) · 1.42 KB
/
defines.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
%define TAB 9
%define SPACE ' ' ; ASCII 20h
%define CR 13
%define NEWLINE 10
%define NL NEWLINE
%define ENTER NEWLINE
%define NULL 0
%define cstr(x) db x, 0
%define __cdecl ; used to annotate a routine uses c calling convention
%define __cdecl_hybrid ; used to annotate a routine uses a *modified* c calling convention
; no params to routine are pushed on stack. parameters are
; expected in eax, ebx, ecx, and/or edx.
; simplifies caller too b/c no need to adjust/pop params from stack after
%macro C_prologue 1
push ebp
mov ebp, esp
sub esp, %1
push edi
push esi
%endmacro
%macro C_epilogue 0
pop esi
pop edi
mov esp, ebp
pop ebp
ret
%endmacro
; index-1 based local parameter (e.g., C_local(1) is our first local dword
%define C_local(x) [ebp-(x*4)]
; index-1 based parameter to routine (e.g., C_param(1) = first param) - always assumes dword param size
; C_param(0) is undefined
%define C_param(x) [ebp+(4+(x*4))]
;; -----
%macro @PUSH_EAX 0
call _push_asm
%endmacro
%macro @POP_EAX 0
call _pop_asm
%endmacro
%macro @EMIT 0
call _emit_asm
%endmacro
%macro @CR 0
call eol
%endmacro
%macro putc 1
push eax
push ebx
push ecx
mov eax, %1
@PUSH_EAX
@EMIT
pop ecx
pop ebx
pop eax
%endmacro