• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; 7zAsm.asm -- ASM macros
2; 2012-12-30 : Igor Pavlov : Public domain
3
4MY_ASM_START macro
5  ifdef x64
6    .code
7  else
8    .386
9    .model flat
10    _TEXT$00 SEGMENT PARA PUBLIC 'CODE'
11  endif
12endm
13
14MY_PROC macro name:req, numParams:req
15  align 16
16  proc_numParams = numParams
17  ifdef x64
18    proc_name equ name
19  else
20    proc_name equ @CatStr(@,name,@, %numParams * 4)
21  endif
22  proc_name PROC
23endm
24
25MY_ENDP macro
26  ifdef x64
27    ret
28  else
29    if proc_numParams LT 3
30      ret
31    else
32      ret (proc_numParams - 2) * 4
33    endif
34  endif
35  proc_name ENDP
36endm
37
38ifdef x64
39  REG_SIZE equ 8
40  REG_LOGAR_SIZE equ 3
41else
42  REG_SIZE equ 4
43  REG_LOGAR_SIZE equ 2
44endif
45
46  x0 equ EAX
47  x1 equ ECX
48  x2 equ EDX
49  x3 equ EBX
50  x4 equ ESP
51  x5 equ EBP
52  x6 equ ESI
53  x7 equ EDI
54
55  x0_L equ AL
56  x1_L equ CL
57  x2_L equ DL
58  x3_L equ BL
59
60  x0_H equ AH
61  x1_H equ CH
62  x2_H equ DH
63  x3_H equ BH
64
65ifdef x64
66  r0 equ RAX
67  r1 equ RCX
68  r2 equ RDX
69  r3 equ RBX
70  r4 equ RSP
71  r5 equ RBP
72  r6 equ RSI
73  r7 equ RDI
74  x8 equ r8d
75  x9 equ r9d
76  x10 equ r10d
77  x11 equ r11d
78  x12 equ r12d
79  x13 equ r13d
80  x14 equ r14d
81  x15 equ r15d
82else
83  r0 equ x0
84  r1 equ x1
85  r2 equ x2
86  r3 equ x3
87  r4 equ x4
88  r5 equ x5
89  r6 equ x6
90  r7 equ x7
91endif
92
93MY_PUSH_4_REGS macro
94    push    r3
95    push    r5
96    push    r6
97    push    r7
98endm
99
100MY_POP_4_REGS macro
101    pop     r7
102    pop     r6
103    pop     r5
104    pop     r3
105endm
106