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
|
; flat assembler interface for Linux x64
; Copyright (c) 1999-2022, Tomasz Grysztar.
; All rights reserved.
esp equ +rsp
macro pushD [arg]
{
common
local offset,total
offset = 0
lea rsp,[rsp-total]
forward
offset = offset + 4
if arg eqtype eax
mov dword [rsp+total-offset],arg
else
mov r8d,dword arg
mov [rsp+total-offset],r8d
end if
common
total = offset
}
macro popD [arg]
{
common
local offset
offset = 0
forward
if arg eqtype [mem]
mov r8d,[rsp+offset]
mov dword arg,r8d
else
mov arg,dword [rsp+offset]
end if
offset = offset + 4
common
lea rsp,[rsp+offset]
}
macro add dest,src
{
if dest eq esp
add rsp,src
else
add dest,src
end if
}
macro mov dest,src
{
if src eq esp
mov dest,ESP
else
mov dest,src
end if
}
macro cmp dest,src
{
if dest eq esp
cmp ESP,src
else
cmp dest,src
end if
}
macro use32
{
macro push args
\{
local list,arg,status
define list
define arg
irps sym, args \\{
define status
match =dword, sym \\\{
define status :
\\\}
match [any, status arg sym \\\{
define arg [any
match [mem], arg \\\\{
match previous, list \\\\\{ define list previous,[mem] \\\\\}
match , list \\\\\{ define list [mem] \\\\\}
define arg
\\\\}
define status :
\\\}
match [, status arg sym \\\{
define arg [
define status :
\\\}
match , status \\\{
match previous, list \\\\{ define list previous,sym \\\\}
match , list \\\\{ define list sym \\\\}
\\\}
\\}
match arg, list \\{ pushD arg \\}
\}
macro pop args
\{
local list,arg,status
define list
define arg
irps sym, args \\{
define status
match =dword, sym \\\{
define status :
\\\}
match [any, status arg sym \\\{
define arg [any
match [mem], arg \\\\{
match previous, list \\\\\{ define list previous,[mem] \\\\\}
match , list \\\\\{ define list [mem] \\\\\}
define arg
\\\\}
define status :
\\\}
match [, status arg sym \\\{
define arg [
define status :
\\\}
match , status \\\{
match previous, list \\\\{ define list previous,sym \\\\}
match , list \\\\{ define list sym \\\\}
\\\}
\\}
match arg, list \\{ popD arg \\}
\}
macro jmp arg
\{
if arg eq near eax
jmp near rax
else if arg eq near edx
jmp near rdx
else if arg eqtype [mem]
mov r8d,arg
jmp near r8
else
jmp arg
end if
\}
macro call arg
\{
if 1
match =near =dword [mem], arg \\{
mov r8d,[mem]
call near r8
else
\\}
call arg
end if
\}
macro salc ; for fasm's core it does not need to preserve flags
\{
setc al
neg al
\}
macro jcxz target ; for fasm's core it does not need to preserve flags
\{
test cx,cx
jz target
\}
use64
}
macro use16
{
purge push,pop,jmp,call,salc,jcxz
use16
}
use32
|