comparison dyncall/dyncall_call_x64.S @ 339:4f9f49fb82ce

- x64 SysV syscall support
author Tassilo Philipp
date Sat, 04 Jan 2020 01:07:49 +0100
parents f5577f6bf97a
children ab2d78e48ca2
comparison
equal deleted inserted replaced
338:ee2b6e54b074 339:4f9f49fb82ce
4 Library: dyncall 4 Library: dyncall
5 File: dyncall/dyncall_call_x64.S 5 File: dyncall/dyncall_call_x64.S
6 Description: All x64 abi call kernel implementation 6 Description: All x64 abi call kernel implementation
7 License: 7 License:
8 8
9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, 9 Copyright (c) 2007-2020 Daniel Adler <dadler@uni-goettingen.de>,
10 Tassilo Philipp <tphilipp@potion-studios.com> 10 Tassilo Philipp <tphilipp@potion-studios.com>
11 11
12 Permission to use, copy, modify, and distribute this software for any 12 Permission to use, copy, modify, and distribute this software for any
13 purpose with or without fee is hereby granted, provided that the above 13 purpose with or without fee is hereby granted, provided that the above
14 copyright notice and this permission notice appear in all copies. 14 copyright notice and this permission notice appear in all copies.
58 MOVSD(QWORD(RCX,48),XMM6) 58 MOVSD(QWORD(RCX,48),XMM6)
59 MOVSD(QWORD(RCX,56),XMM7) 59 MOVSD(QWORD(RCX,56),XMM7)
60 60
61 ADD(LIT(31),RDI) /* Align stack to 32-byte. */ 61 ADD(LIT(31),RDI) /* Align stack to 32-byte. */
62 AND(LIT(-32),RDI) 62 AND(LIT(-32),RDI)
63 ADD(LIT(8),RDI) /* Adjust by 8-byte for the return-address. */ 63 ADD(LIT(8),RDI) /* Adjust by 8-byte for the return-address. */
64 SUB(RDI,RSP) /* Setup stack frame by subtracting the size of arguments. */ 64 SUB(RDI,RSP) /* Setup stack frame by subtracting the size of arguments. */
65 65
66 MOV(RDI,RCX) /* Store number of bytes to copy to stack in RCX (for rep movsb). */ 66 MOV(RDI,RCX) /* Store number of bytes to copy to stack in RCX (for rep movsb). */
67 MOV(RSP,RDI) /* Store pointer to beginning of stack arguments in RDI (for rep movsb). */ 67 MOV(RSP,RDI) /* Store pointer to beginning of stack arguments in RDI (for rep movsb). */
68 68
141 141
142 RET() 142 RET()
143 143
144 END_PROC(dcCall_x64_win64) 144 END_PROC(dcCall_x64_win64)
145 145
146 /*---------------------------------------------------------------------------
147
148 Call Kernel for x64 System V syscalls
149
150 Input:
151 RDI : pointer to arguments
152 RSI : syscall id
153
154 */
155
156 GLOBAL(dcCall_x64_sys_syscall_sysv)
157 BEGIN_PROC(dcCall_x64_sys_syscall_sysv)
158
159 MOV(RSI,RAX) /* load system call id. */
160 MOV(QWORD(RDI,40),R9) /* copy first six int/pointer arguments to RDI, RSI, RDX, R10, R8, R9. */
161 MOV(QWORD(RDI,32),R8)
162 MOV(QWORD(RDI,24),R10)
163 MOV(QWORD(RDI,16),RDX)
164 MOV(QWORD(RDI,8),RSI)
165 MOV(QWORD(RDI,0),RDI) /* Set RDI last to not overwrite it to soon. */
166 SYSCALL
167 RET()
168
169 END_PROC(dcCall_x64_sys_syscall_sysv)
170
146 END_ASM 171 END_ASM
147 172