comparison portasm/portasm-x64-att.S @ 0:3e629dc19168

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:24:28 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3e629dc19168
1 /*
2
3 Package: dyncall
4 Library: portasm
5 File: portasm/portasm-x64-att.S
6 Description: Portable Assembler Macros for X64
7 License:
8
9 Copyright (c) 2011-2015 Daniel Adler <dadler@uni-goettingen.de>
10
11 Permission to use, copy, modify, and distribute this software for any
12 purpose with or without fee is hereby granted, provided that the above
13 copyright notice and this permission notice appear in all copies.
14
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23 */
24
25
26
27 /* Common macros. */
28 #define XCONCAT(A,B) A##B
29 #if defined(GEN_MASM)
30 /* MASM syntax. */
31 .CODE
32 # define BEGIN_ASM
33 # define END_ASM END
34 # define GLOBAL(X) X PROC
35 # define BEGIN_PROC(X) OPTION PROLOGUE:NONE, EPILOGUE:NONE
36 # define END_PROC(X) X ENDP
37 # define PUSH(R) push R
38 # define POP(R) pop R
39 # define MOV(S,D) mov D,S
40 # define MOVB(S,D) mov D,S
41 # define MOVL(S,D) mov D,S
42 # define ADDL(S,D) add D,S
43 # define ANDL(S,D) and D,S
44 # define SUBL(S,D) sub D,S
45 # define SHRL(S,D) shr D,S
46 # define MOVQ(S,D) movq D,S
47 # define ADD(S,D) add D,S
48 # define AND(S,D) and D,S
49 # define SUB(S,D) sub D,S
50 # define SHR(S,D) shr D,S
51 # define MOVD(S,D) movd D,S
52 # define RET() ret
53 # define CALL_DWORD(R,OFF) call DWORD(R,OFF)
54 # define REP(X) rep X
55 # define MOVSB movsb
56 # define MOVSW movsw
57 # define MOVSD(S,D) movsd D,S
58 # define MOVSDX(S,D) movsdx D,S
59 # define DWORD(R,OFF) dword ptr [R+OFF]
60 # define QWORD(R,OFF) qword ptr [R+OFF]
61 # define LIT(X) X
62 # define INT(X) int X
63 # define HEX(X) XCONCAT(X,h)
64 # define CALL(X) call X
65 # define CALL_REG(X) call X
66 # define LEA(S,D) lea D,S
67 # define SET(K,V) K = V
68 # define JE(X) je X
69 # define JNE(X) jne X
70 # define CMP(A,B) cmp B,A
71 # define LOCAL(X) X
72 #else
73 /* GNU/SunPro Assembler AT&T Syntax */
74 .text
75 # define BEGIN_ASM
76 # define END_ASM
77 # include "../autovar/autovar_OS.h"
78 # if defined (OS_Darwin)
79 # define CSYM(X) _##X
80 # else
81 # define CSYM(X) X
82 # endif
83 # define RAX %rax
84 # define RBX %rbx
85 # define RCX %rcx
86 # define RDX %rdx
87 # define RSI %rsi
88 # define RDI %rdi
89 # define RBP %rbp
90 # define RSP %rsp
91 # define R8 %r8
92 # define R9 %r9
93 # define R10 %r10
94 # define R11 %r11
95 # define R12 %r12
96 # define R13 %r13
97 # define R14 %r14
98 # define R15 %r15
99 # define XMM0 %xmm0
100 # define XMM1 %xmm1
101 # define XMM2 %xmm2
102 # define XMM3 %xmm3
103 # define XMM4 %xmm4
104 # define XMM5 %xmm5
105 # define XMM6 %xmm6
106 # define XMM7 %xmm7
107 # define AL %al
108 # define AH %ah
109 # define BL %bl
110 # define BH %bh
111 # define CL %cl
112 # define CH %ch
113 # define DL %dl
114 # define DH %dh
115 # define GLOBAL(X) .globl CSYM(X)
116 # define BEGIN_PROC(X) CSYM(X):
117 # define END_PROC(X)
118 # define PUSH(R) pushq R
119 # define POP(R) popq R
120 # define MOV(S,D) movq S,D
121 # define MOVB(S,D) movb S,D
122 # define MOVL(S,D) movl S,D
123 # define ADDL(S,D) addl S,D
124 # define ANDL(S,D) andl S,D
125 # define SUBL(S,D) subl S,D
126 # define SHRL(S,D) shrl S,D
127 # define MOVQ(S,D) movq S,D
128 # define ADD(S,D) addq S,D
129 # define AND(S,D) andq S,D
130 # define SUB(S,D) subq S,D
131 # define SHR(S,D) shrq S,D
132 # define MOVD(S,D) movd S,D
133 # define RET() ret
134 # define CALL_DWORD(R,OFF) call *DWORD(R,OFF)
135 # define REP(X) rep X
136 # define MOVSB movsb
137 # define MOVSW movsw
138 # define MOVSD(S,D) movsd S,D
139 # define DWORD(R,OFF) OFF(R)
140 # define QWORD(R,OFF) OFF(R)
141 # define LIT(X) $X
142 # define INT(X) int X
143 # define HEX(X) XCONCAT(0x,X)
144 # define CALL(X) call X
145 # define CALL_REG(X) call *X
146 # define LEA(A,B) lea A,B
147 # define CMP(A,B) cmp A,B
148 # define CMPB(A,B) cmpb A,B
149 # define JE(X) je X
150 # define JNE(X) jne X
151 # define FLDS(X) flds X
152 # define FLDL(X) fldl X
153 # define SET(K,V) .set K,V
154 # define LOCAL(X) .X
155 #endif
156