annotate dyncall/dyncall_call_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 e5ad8cf0aa72
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 Library: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 File: dyncall/dyncall_call_x86.S
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: All - except Plan9 - x86 abi call kernel implementation
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8
281
f5577f6bf97a - file header cleanups for release
Tassilo Philipp
parents: 256
diff changeset
9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 #include "../portasm/portasm-x86.S"
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29 BEGIN_ASM
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 /* ============================================================================
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 DynCall Call Kernels for X86 Architecture
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 ----------------------------------------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 C Interface:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 dcCall_x86_XXX(void* target, void* args, size_t size);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35 ddCall_x86_sys_XXX(int_ptr target, void* args, size_t size);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 Where XXX is one of calling-conventions,
165
572aff021627 - file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents: 0
diff changeset
38 cdecl, win32_msthis, win32_std, win32_fastcall.
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 Parameter Stack layout:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41 size := EBP + 16
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 args := EBP + 12
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43 target := EBP + 8
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45 NOTES:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46 - epilog restore ESP serves callee cleanup
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47 - 16 byte alignment (to be compatible with darwin).
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51 /*--- default / cdecl --------------------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 Details:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 - caller clean-up
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
55
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58 GLOBAL(dcCall_x86_cdecl)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59 BEGIN_PROC(dcCall_x86_cdecl)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
60 PUSH(EBP) /* prolog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61 MOVL(ESP,EBP)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
62 PUSH(ESI) /* save preserved registers. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63 PUSH(EDI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
64 MOVL(DWORD(EBP,12),ESI) /* ESI = arg buffer ptr */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
65 MOVL(DWORD(EBP,16),ECX) /* ECX = arg buffer size */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
66 ADDL(LIT(15),ECX) /* ECX = align(ECX,16) */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67 ANDL(LIT(-16),ECX)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
68 MOVL(ECX,DWORD(EBP,16)) /* save ECX. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
69 SUBL(ECX,ESP) /* allocate stack size */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
70 MOVL(ESP,EDI) /* EDI = stack ptr */
165
572aff021627 - file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents: 0
diff changeset
71
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 work around for rep movsd (not supported by SunPro)
165
572aff021627 - file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents: 0
diff changeset
74
572aff021627 - file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents: 0
diff changeset
75 SHRL(LIT(2),ECX)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 REP(MOVSD)
165
572aff021627 - file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents: 0
diff changeset
77
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80 REP(MOVSB)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81 CALL_DWORD(EBP,8)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82 ADDL(DWORD(EBP,16),ESP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 POP(EDI)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 POP(ESI)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
85 MOVL(EBP,ESP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86 POP(EBP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87 RET()
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88 END_PROC(dcCall_x86_cdecl)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
89
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
90
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
91 /* ---- C++ this calls (microsoft) ------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
92
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
93 Details:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
94 - this pointer is in ECX
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
95
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
96 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 GLOBAL(dcCall_x86_win32_msthis)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
99 BEGIN_PROC(dcCall_x86_win32_msthis)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
100 PUSH(EBP) /* prolog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
101 MOVL(ESP,EBP)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
102 PUSH(ESI) /* save preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
103 PUSH(EDI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
104 MOVL(DWORD(EBP,12),ESI) /* ESI = pointer on args. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
105 MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
106 MOVL(DWORD(ESI,0),EAX) /* EAX = this pointer. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
107 ADDL(LIT(4),ESI) /* increment args pointer by thisptr. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
108 SUBL(LIT(4),ECX) /* decrement size by sizeof(thisptr). */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
109 SUBL(ECX,ESP) /* allocate argument-block on stack. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
110 MOVL(ESP,EDI) /* EDI = stack args. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
111 REP(MOVSB) /* copy arguments. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
112 MOVL(EAX,ECX) /* ECX = this pointer. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
113 CALL_DWORD(EBP,8) /* call function. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
114 POP(EDI) /* restore preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
115 POP(ESI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
116 MOVL(EBP,ESP) /* epilog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
117 POP(EBP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
118 RET()
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
119 END_PROC(dcCall_x86_win32_msthis)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
120
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
121
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
122 /*---- win32 stdcall ---------------------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
123
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
124 Details:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
125 - callee cleans up stack
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
126
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
127 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
128
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
129 GLOBAL(dcCall_x86_win32_std)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
130 BEGIN_PROC(dcCall_x86_win32_std)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
131 PUSH(EBP) /* prolog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
132 MOVL(ESP,EBP)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
133 PUSH(ESI) /* save ESI, EDI. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
134 PUSH(EDI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
135 MOVL(DWORD(EBP,12),ESI) /* ESI = args. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
136 MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
137 SUBL(ECX,ESP) /* allocate size bytes on stack. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
138 MOVL(ESP,EDI) /* EDI = copy destination stack. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
139 REP(MOVSB) /* copy BYTEs. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
140 CALL_DWORD(EBP,8) /* call target. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
141 POP(EDI) /* restore EDI, ESI. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
142 POP(ESI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
143 MOVL(EBP,ESP) /* epilog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
144 POP(EBP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
145 RET()
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
146 END_PROC(dcCall_x86_win32_std)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
147
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
148
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
149 /*---- win32 fastcall (GNU/Microsoft) ----------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
150
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
151 Details:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
152 - callee cleans up stack
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
153 - first two integer (up to 32bits) are passed in ECX and EDX
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
154
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
155 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
156
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
157 GLOBAL(dcCall_x86_win32_fast)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
158 BEGIN_PROC(dcCall_x86_win32_fast)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
159 PUSH(EBP) /* prolog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
160 MOVL(ESP,EBP)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
161 PUSH(ESI) /* save preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
162 PUSH(EDI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
163 MOVL(DWORD(EBP,12),ESI) /* ESI = copy source args. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
164 MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
165 MOVL(DWORD(ESI,0),EAX) /* EAX = first argument. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
166 MOVL(DWORD(ESI,4),EDX) /* EDX = second argument. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
167 ADDL(LIT(8),ESI) /* skip registers. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
168 SUBL(LIT(8),ECX)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
169 MOVL(ECX,DWORD(EBP,16)) /* save stack alloc size. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
170 SUBL(ECX,ESP) /* allocate stack. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
171 MOVL(ESP,EDI) /* EDI = stack args. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
172 REP(MOVSB) /* copy BYTEs. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
173 MOVL(EAX,ECX) /* ECX = first argument. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
174 CALL_DWORD(EBP,8) /* call target. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
175 POP(EDI) /* restore preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
176 POP(ESI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
177 MOVL(EBP,ESP) /* epilog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
178 POP(EBP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
179 RET()
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
180 END_PROC(dcCall_x86_win32_fast)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
181
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
182
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
183 /*--- syscall int80 linux ---------------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
184
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
185 Details:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
186 - all arguments are passed via registers
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
187
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
188 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
189
341
ab2d78e48ca2 - gen-masm
Tassilo Philipp
parents: 281
diff changeset
190 GLOBAL(dcCall_x86_syscall_int80h_linux)
ab2d78e48ca2 - gen-masm
Tassilo Philipp
parents: 281
diff changeset
191 BEGIN_PROC(dcCall_x86_syscall_int80h_linux)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
192 PUSH(EBP) /* prolog. */
165
572aff021627 - file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents: 0
diff changeset
193 MOVL(ESP,EBP)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
194 PUSH(EBX) /* save preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
195 PUSH(ESI)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
196 PUSH(EDI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
197 MOVL(DWORD(EBP,12),EAX) /* EAX = argument buffer. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
198 MOVL(DWORD(EAX,0),EBX) /* move first five arguments. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
199 MOVL(DWORD(EAX,4),ECX)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
200 MOVL(DWORD(EAX,8),EDX)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
201 MOVL(DWORD(EAX,12),ESI)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
202 MOVL(DWORD(EAX,16),EDI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
203 MOVL(DWORD(EBP,8),EAX) /* EAX = syscall id. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
204 INT(LIT(HEX(80)))
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
205 POP(EDI) /* restore preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
206 POP(ESI)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
207 POP(EBX)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
208 MOVL(EBP,ESP) /* epilog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
209 POP(EBP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
210 RET()
341
ab2d78e48ca2 - gen-masm
Tassilo Philipp
parents: 281
diff changeset
211 END_PROC(dcCall_x86_syscall_int80h_linux)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
212
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
213
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
214 /*--- syscall int80 bsd -----------------------------------------------------
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
215
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
216 Details:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
217 - all arguments are passed via stack
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
218
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
219 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
220
341
ab2d78e48ca2 - gen-masm
Tassilo Philipp
parents: 281
diff changeset
221 GLOBAL(dcCall_x86_syscall_int80h_bsd)
ab2d78e48ca2 - gen-masm
Tassilo Philipp
parents: 281
diff changeset
222 BEGIN_PROC(dcCall_x86_syscall_int80h_bsd)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
223 PUSH(EBP) /* prolog. */
165
572aff021627 - file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents: 0
diff changeset
224 MOVL(ESP,EBP)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
225 PUSH(ESI) /* save preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
226 PUSH(EDI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
227 MOVL(DWORD(EBP,12),ESI) /* ESI = pointer on args. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
228 MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
229 SUBL(ECX,ESP) /* allocate stack space. */
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
230 MOVL(ESP,EDI) /* EDI = stack args. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
231 REP(MOVSB)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
232 MOVL(DWORD(EBP,8),EAX) /* load system call id. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
233 CALL(_do_int)
631
e5ad8cf0aa72 - BSD syscall segfault fix
Tassilo Philipp
parents: 610
diff changeset
234 ADDL(DWORD(EBP,16),ESP)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
235 POP(EDI) /* restore preserved. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
236 POP(ESI)
610
fea865cd1305 - whitespace cosmetics
Tassilo Philipp
parents: 341
diff changeset
237 MOVL(EBP,ESP) /* epilog. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
238 POP(EBP)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
239 RET()
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
240 _do_int:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
241 INT(LIT(HEX(80)))
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
242 RET()
341
ab2d78e48ca2 - gen-masm
Tassilo Philipp
parents: 281
diff changeset
243 END_PROC(dcCall_x86_syscall_int80h_bsd)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
244
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
245 END_ASM
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
246