Mercurial > pub > dyncall > dyncall
annotate portasm/portasm-x86.S @ 663:127b569978cc default tip
- another tweak handling clang trying to be too smart (see last commit)
author | Tassilo Philipp |
---|---|
date | Sun, 24 Mar 2024 13:52:44 +0100 |
parents | 6a8aac9b2bcf |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: portasm | |
5 File: portasm/portasm-x86.S | |
6 Description: Portable Assembler Macros for x86 | |
7 License: | |
8 | |
281 | 9 Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de> |
0 | 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 /* MASM syntax. */ | |
30 #if defined(GEN_MASM) | |
31 .386 | |
32 .MODEL FLAT | |
33 .CODE | |
34 # define BEGIN_ASM | |
35 # define END_ASM END | |
36 # define GLOBAL(X) _##X PROC | |
37 # define BEGIN_PROC(X) OPTION PROLOGUE:NONE, EPILOGUE:NONE | |
38 # define END_PROC(X) _##X ENDP | |
39 # define PUSH(R) push R | |
40 # define POP(R) pop R | |
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 RET() ret | |
47 # define CALL_DWORD(R,OFF) call DWORD(R,OFF) | |
48 # define REP(X) rep X | |
49 # define MOVSB movsb | |
50 # define MOVSW movsw | |
51 # define MOVSD movsd | |
52 # define DWORD(R,OFF) dword ptr [R+OFF] | |
53 # define QWORD(R,OFF) qword ptr [R+OFF] | |
54 # define LIT(X) X | |
55 # define INT(X) int X | |
56 # define HEX(X) XCONCAT(X,h) | |
57 # define CALL(X) call X | |
58 # define LEA(S,D) lea D,S | |
59 # define ADD(S,D) add D,S | |
60 # define CMP(S,D) cmp D,S | |
61 # define JE(T) je T | |
62 # define FLDS(OP) fld OP | |
63 # define FLDL(OP) fld OP | |
64 # define LOCAL(NAME) NAME | |
166
d5705f226298
- added portasm support for adding .section .note.GNU-stack "hints" marking generated .o files from assembly files as not needing an executable stack
cslag
parents:
0
diff
changeset
|
65 /* @@@ check if masm support wanted/needed */ |
d5705f226298
- added portasm support for adding .section .note.GNU-stack "hints" marking generated .o files from assembly files as not needing an executable stack
cslag
parents:
0
diff
changeset
|
66 # define SECTION_NOTE_NXSTACK |
0 | 67 #else |
68 /* GNU/SunPro Assembler AT&T Syntax */ | |
69 .text | |
70 # define BEGIN_ASM | |
71 # define END_ASM | |
645
6a8aac9b2bcf
- removal of `autovar` macro detection lib:
Tassilo Philipp
parents:
281
diff
changeset
|
72 # include "../dyncall/dyncall_macros.h" |
6a8aac9b2bcf
- removal of `autovar` macro detection lib:
Tassilo Philipp
parents:
281
diff
changeset
|
73 # if defined(DC__OS_Win32) || defined(DC__OS_Cygwin) || defined(DC__OS_MinGW) || defined(DC__OS_Darwin) || defined(DC__OS_Minix) |
0 | 74 # define CSYM(X) _##X |
75 # else | |
76 # define CSYM(X) X | |
77 # endif | |
78 /* Systems that work without '%' prefix: MinGW,Apple */ | |
79 # define EAX %eax | |
80 # define EBX %ebx | |
81 # define ECX %ecx | |
82 # define EDX %edx | |
83 # define ESI %esi | |
84 # define EDI %edi | |
85 # define EBP %ebp | |
86 # define ESP %esp | |
87 # define AL %al | |
88 # define AH %ah | |
89 # define BL %bl | |
90 # define BH %bh | |
91 # define CL %cl | |
92 # define CH %ch | |
93 # define DL %dl | |
94 # define DH %dh | |
95 # define GLOBAL(X) .globl CSYM(X) | |
96 # define BEGIN_PROC(X) CSYM(X): | |
97 # define END_PROC(X) | |
98 # define PUSH(R) pushl R | |
99 # define POP(R) popl R | |
100 # define MOVL(S,D) movl S,D | |
101 # define ADDL(S,D) addl S,D | |
102 # define ANDL(S,D) andl S,D | |
103 # define SUBL(S,D) subl S,D | |
104 # define SHRL(S,D) shrl S,D | |
105 # define RET() ret | |
106 # define CALL_DWORD(R,OFF) call *DWORD(R,OFF) | |
107 # define REP(X) rep; X | |
108 # define MOVSB movsb | |
109 # define MOVSW movsw | |
110 # define MOVSD movsd | |
111 # define DWORD(R,OFF) OFF(R) | |
112 # define QWORD(R,OFF) OFF(R) | |
645
6a8aac9b2bcf
- removal of `autovar` macro detection lib:
Tassilo Philipp
parents:
281
diff
changeset
|
113 # if defined DC__C_SUNPRO |
0 | 114 # define LIT(X) $X |
115 # else | |
116 # define LIT(X) XCONCAT($,X) | |
117 # endif | |
118 # define INT(X) int X | |
119 # define HEX(X) XCONCAT(0x,X) | |
120 # define CALL(X) call X | |
121 # define LEA(A,B) lea A,B | |
122 # define CMP(A,B) cmp A,B | |
123 # define JE(X) je X | |
124 # define FLDS(X) flds X | |
125 # define FLDL(X) fldl X | |
126 # define ADD(A,B) add A,B | |
127 # define LOCAL(X) .X | |
128 #endif | |
129 |