1; 7zAsm.asm -- ASM macros 2; 2009-12-12 : 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 equ numParams 17 ifdef x64 18 proc_name equ name 19 name PROC 20 else 21 proc_fastcall_name equ @CatStr(@,name,@, %numParams * 4) 22 public proc_fastcall_name 23 proc_fastcall_name: 24 endif 25endm 26 27MY_ENDP macro 28 ifdef x64 29 ret 30 proc_name ENDP 31 else 32 ret (proc_numParams - 2) * 4 33 endif 34endm 35 36ifdef x64 37 REG_SIZE equ 8 38else 39 REG_SIZE equ 4 40endif 41 42 x0 equ EAX 43 x1 equ ECX 44 x2 equ EDX 45 x3 equ EBX 46 x4 equ ESP 47 x5 equ EBP 48 x6 equ ESI 49 x7 equ EDI 50 51 x0_L equ AL 52 x1_L equ CL 53 x2_L equ DL 54 x3_L equ BL 55 56 x0_H equ AH 57 x1_H equ CH 58 x2_H equ DH 59 x3_H equ BH 60 61ifdef x64 62 r0 equ RAX 63 r1 equ RCX 64 r2 equ RDX 65 r3 equ RBX 66 r4 equ RSP 67 r5 equ RBP 68 r6 equ RSI 69 r7 equ RDI 70else 71 r0 equ x0 72 r1 equ x1 73 r2 equ x2 74 r3 equ x3 75 r4 equ x4 76 r5 equ x5 77 r6 equ x6 78 r7 equ x7 79endif 80 81MY_PUSH_4_REGS macro 82 push r3 83 push r5 84 push r6 85 push r7 86endm 87 88MY_POP_4_REGS macro 89 pop r7 90 pop r6 91 pop r5 92 pop r3 93endm 94