"Fossies" - the Fresh Open Source Software Archive

Member "fasm/source/Linux/x64/modes.inc" (21 Feb 2022, 2844 Bytes) of package /linux/misc/fasm-1.73.30.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) fasm source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "modes.inc": 1.73.29_vs_1.73.30.

    1 
    2 ; flat assembler interface for Linux x64
    3 ; Copyright (c) 1999-2022, Tomasz Grysztar.
    4 ; All rights reserved.
    5 
    6 esp equ +rsp
    7 
    8 macro pushD [arg]
    9 {
   10     common
   11         local offset,total
   12         offset = 0
   13         lea rsp,[rsp-total]
   14     forward
   15         offset = offset + 4
   16         if arg eqtype eax
   17             mov dword [rsp+total-offset],arg
   18         else
   19             mov r8d,dword arg
   20             mov [rsp+total-offset],r8d
   21         end if
   22     common
   23         total = offset
   24 }
   25 
   26 macro popD [arg]
   27 {
   28     common
   29         local offset
   30         offset = 0
   31     forward
   32         if arg eqtype [mem]
   33             mov r8d,[rsp+offset]
   34             mov dword arg,r8d
   35         else
   36             mov arg,dword [rsp+offset]
   37         end if
   38         offset = offset + 4
   39     common
   40         lea rsp,[rsp+offset]
   41 }
   42 
   43 macro add dest,src
   44 {
   45     if dest eq esp
   46         add rsp,src
   47     else
   48         add dest,src
   49     end if
   50 }
   51 
   52 macro mov dest,src
   53 {
   54     if src eq esp
   55         mov dest,ESP
   56     else
   57         mov dest,src
   58     end if
   59 }
   60 
   61 macro cmp dest,src
   62 {
   63     if dest eq esp
   64         cmp ESP,src
   65     else
   66         cmp dest,src
   67     end if
   68 }
   69 
   70 macro use32
   71 {
   72 
   73     macro push args
   74     \{
   75         local list,arg,status
   76         define list
   77         define arg
   78         irps sym, args \\{
   79             define status
   80             match =dword, sym \\\{
   81                 define status :
   82             \\\}
   83             match [any, status arg sym \\\{
   84                 define arg [any
   85                 match [mem], arg \\\\{
   86                     match previous, list \\\\\{ define list previous,[mem] \\\\\}
   87                     match , list \\\\\{ define list [mem] \\\\\}
   88                     define arg
   89                 \\\\}
   90                 define status :
   91             \\\}
   92             match [, status arg sym \\\{
   93                 define arg [
   94                 define status :
   95             \\\}
   96             match , status \\\{
   97                 match previous, list \\\\{ define list previous,sym \\\\}
   98                 match , list \\\\{ define list sym \\\\}
   99             \\\}
  100         \\}
  101         match arg, list \\{ pushD arg \\}
  102     \}
  103 
  104     macro pop args
  105     \{
  106         local list,arg,status
  107         define list
  108         define arg
  109         irps sym, args \\{
  110             define status
  111             match =dword, sym \\\{
  112                 define status :
  113             \\\}
  114             match [any, status arg sym \\\{
  115                 define arg [any
  116                 match [mem], arg \\\\{
  117                     match previous, list \\\\\{ define list previous,[mem] \\\\\}
  118                     match , list \\\\\{ define list [mem] \\\\\}
  119                     define arg
  120                 \\\\}
  121                 define status :
  122             \\\}
  123             match [, status arg sym \\\{
  124                 define arg [
  125                 define status :
  126             \\\}
  127             match , status \\\{
  128                 match previous, list \\\\{ define list previous,sym \\\\}
  129                 match , list \\\\{ define list sym \\\\}
  130             \\\}
  131         \\}
  132         match arg, list \\{ popD arg \\}
  133     \}
  134 
  135     macro jmp arg
  136     \{
  137         if arg eq near eax
  138             jmp near rax
  139         else if arg eq near edx
  140             jmp near rdx
  141         else if arg eqtype [mem]
  142             mov r8d,arg
  143             jmp near r8
  144         else
  145             jmp arg
  146         end if
  147     \}
  148 
  149     macro call arg
  150     \{
  151         if 1
  152         match =near =dword [mem], arg \\{
  153             mov r8d,[mem]
  154             call near r8
  155         else
  156         \\}
  157             call arg
  158         end if
  159     \}
  160 
  161     macro salc      ; for fasm's core it does not need to preserve flags
  162     \{
  163         setc al
  164         neg al
  165     \}
  166 
  167     macro jcxz target   ; for fasm's core it does not need to preserve flags
  168     \{
  169         test cx,cx
  170         jz target
  171     \}
  172 
  173     use64
  174 
  175 }
  176 
  177 macro use16
  178 {
  179 
  180     purge push,pop,jmp,call,salc,jcxz
  181 
  182     use16
  183 
  184 }
  185 
  186 use32