changeset 165:572aff021627

- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading - some "I'm bored"-whitespace-cleanup
author cslag
date Thu, 05 Jan 2017 10:35:12 +0100
parents 2d330a60c44f
children d5705f226298
files ToDo dyncall/dyncall_call.S dyncall/dyncall_call_x64-att.S dyncall/dyncall_call_x64.S dyncall/dyncall_call_x86.S dyncall/gen-masm.sh dyncallback/dyncall_callback_x64.S dyncallback/dyncall_callback_x86.S portasm/portasm-x64-att.S portasm/portasm-x64.S
diffstat 10 files changed, 354 insertions(+), 343 deletions(-) [+]
line wrap: on
line diff
--- a/ToDo	Thu Jan 05 10:17:37 2017 +0100
+++ b/ToDo	Thu Jan 05 10:35:12 2017 +0100
@@ -1,6 +1,17 @@
 1.0:
 ----
+- make sure all assembly files declare (or are built) by setting the noexecstack flag,
+  compared to translating code with gcc, it's manual for the assembler; this depends on arch
+  support (currently it's only done for linux):
+
+    "When you compile source code normally, gcc takes care of adding the GNU_STACK
+    markings so that the final object code is not marked with an executable stack
+    unless it actually needs it. However, if you compile assembly code, gcc will
+    not automatically add GNU_STACK markings."
+
 - dyncallback's "stack_cleanup" can be removed from non x86 impls... test if they still work
+- target a minimum c version, for use with -pedantic, etc.? Right now we use e.g. extensions
+  for anon structs, etc.
 - the CallVM-free functions are per VTable, however the latter can be changed out
   at runtime... which basically changes potentially the deallocator...
   same goes for functions setting the mode. think about how to make this safer - currently
--- a/dyncall/dyncall_call.S	Thu Jan 05 10:17:37 2017 +0100
+++ b/dyncall/dyncall_call.S	Thu Jan 05 10:35:12 2017 +0100
@@ -43,7 +43,7 @@
 #  if defined(DC__Arch_Intel_x86)
 #    include "dyncall_call_x86.S"
 #  elif defined(DC__Arch_AMD64)
-#    include "dyncall_call_x64-att.S"
+#    include "dyncall_call_x64.S"
 #  elif defined(DC__Arch_ARM_ARM)
 #    if defined(DC__ABI_ARM_HF)
 #      include "dyncall_call_arm32_arm_armhf.S"
--- a/dyncall/dyncall_call_x64-att.S	Thu Jan 05 10:17:37 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
-
- Package: dyncall
- Library: dyncall
- File: dyncall/dyncall_call_x64-att.S
- Description: All x64 abi call kernel implementation
- License:
-
-   Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
-                           Tassilo Philipp <tphilipp@potion-studios.com>
-
-   Permission to use, copy, modify, and distribute this software for any
-   purpose with or without fee is hereby granted, provided that the above
-   copyright notice and this permission notice appear in all copies.
-
-   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-*/
-
-
-
-#include "../portasm/portasm-x64-att.S"
-
-BEGIN_ASM
-
-/*---------------------------------------------------------------------------
-  
-  Call Kernel for x64 System V
-  
-  Input:
-    RDI : size of arguments to be passed via stack 
-    RSI : pointer to arguments to be passed via the stack 
-    RDX : pointer to arguments of integral/pointer type to be passed via registers 
-    RCX : pointer to arguments of floating point type to be passed via registers 
-    R8  : target function pointer 
-  Notes:
-    RSP+8: is always 16-byte aligned (32-byte align if __m256 is used)
-*/
-
-GLOBAL(dcCall_x64_sysv)
-BEGIN_PROC(dcCall_x64_sysv)
-	PUSH(RBP)			/* Pseudo-prolog - preserve RBP. */
-	PUSH(RBX)			/* Preserve RBX and store pointer to function in it. */
-	MOV(RSP,RBP)			/* Store stack pointer in RBP. */
-	MOV(R8 ,RBX)
-	MOVSD(QWORD(RCX,0) ,XMM0)	/* Copy first 8 floats to XMM0-XMM7. */
-	MOVSD(QWORD(RCX,8) ,XMM1)
-	MOVSD(QWORD(RCX,16),XMM2)
-	MOVSD(QWORD(RCX,24),XMM3)
-	MOVSD(QWORD(RCX,32),XMM4)
-	MOVSD(QWORD(RCX,40),XMM5)
-	MOVSD(QWORD(RCX,48),XMM6)
-	MOVSD(QWORD(RCX,56),XMM7)
-
-	ADD(LIT(31),RDI)		/* Align stack to 32-byte. */
-	AND(LIT(-32),RDI)
-	ADD(LIT(8),RDI)		/* Adjust by 8-byte for the return-address. */
-	SUB(RDI,RSP)			/* Setup stack frame by subtracting the size of arguments. */
-					
-	MOV(RDI,RCX)			/* Store number of bytes to copy to stack in RCX (for rep movsb). */
-	MOV(RSP,RDI)			/* Store pointer to beginning of stack arguments in RDI (for rep movsb). */
-
-	REP(MOVSB)			/* copy bytes (@@@ should be optimized). */
-
-	MOV(QWORD(RDX,0),RDI)		/* copy first six int/pointer arguments to RDI, RSI, RDX, RCX, R8, R9. */
-	MOV(QWORD(RDX,8),RSI)
-	MOV(QWORD(RDX,24),RCX)
-	MOV(QWORD(RDX,32),R8)
-	MOV(QWORD(RDX,40),R9)
-	MOV(QWORD(RDX,16),RDX)		/* Set RDX last to not overwrite it to soon. */
-
-	MOVB(LIT(8),AL)			/* Put upper bound of number of used xmm registers in AL. */
-	CALL_REG(RBX)			/* Call function. */
-
-	MOV(RBP,RSP)			/* Restore stack pointer. */
-	POP(RBX)			/* Restore RBX. */
-	POP(RBP)			/* Pseudo-epilog. */
-	RET()
-END_PROC(dcCALl_x64_sysv)
-
-/*---------------------------------------------------------------------------
-
-  Call Kernel for x64 Win64
-	
-  Input:
-    RCX : size of arguments to be passed via stack 
-    RDX : pointer to arguments to be passed via the stack 
-    R8  : pointer to arguments of integral/pointer type to be passed via registers 
-    R9  : target function pointer
-
-*/
-
-GLOBAL(dcCall_x64_win64)
-BEGIN_PROC(dcCall_x64_win64)
-
-	PUSH(RBP)			/* Pseudo-prolog - preserve RBP. */
-	PUSH(RSI)			/* Preserve RSI and RDI. */
-	PUSH(RDI)
-	
-	MOV(RSP,RBP)			/* Store stack pointer in RBP. */
-
-	ADD(LIT(15),RCX)		/* Align stack size to 16 bytes. */
-	AND(LIT(-16),RCX)
-	SUB(RCX,RSP)			/* Setup stack frame by subtracting the size of the arguments. */
-
-
-	MOV(RDX, RSI)			/* Let RSI point to the arguments. */
-	MOV(RSP, RDI)			/* Store pointer to beginning of stack arguments in RDI (for rep movsb). */
-	MOV(R9,  RAX)			/* Put function address in RAX. */
-
-	REP(MOVSB) 			/* @@@ should be optimized (e.g. movq) */
-
-	MOV(QWORD(R8,0),RCX)		/* Copy first four arguments to RCX, RDX, R9, R8 ( and XMM0-XMM3. ) */
-	MOV(QWORD(R8,8),RDX)
-	MOV(QWORD(R8,24),R9)
-	MOV(QWORD(R8,16),R8)
-
-	MOVD(RCX, XMM0)
-	MOVD(RDX, XMM1)
-	MOVD(R8,  XMM2)
-	MOVD(R9,  XMM3)
-
-	PUSH(R9)			/* Push first four arguments onto the stack preserve area. */
-	PUSH(R8)
-	PUSH(RDX)
-	PUSH(RCX)
-
-	CALL_REG(RAX)			/* Invoke function. */
-
-	MOV(RBP, RSP)			/* Restore stack pointer (such that we can pop the preserved vALues). */
-
-	POP(RDI)			/* Restore RSI and RDI. */
-	POP(RSI)
-	POP(RBP)			/* Pseudo-epilog. */
-
-	RET()
-
-END_PROC(dcCall_x64_win64)
-
-END_ASM
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dyncall/dyncall_call_x64.S	Thu Jan 05 10:35:12 2017 +0100
@@ -0,0 +1,147 @@
+/*
+
+ Package: dyncall
+ Library: dyncall
+ File: dyncall/dyncall_call_x64.S
+ Description: All x64 abi call kernel implementation
+ License:
+
+   Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
+                           Tassilo Philipp <tphilipp@potion-studios.com>
+
+   Permission to use, copy, modify, and distribute this software for any
+   purpose with or without fee is hereby granted, provided that the above
+   copyright notice and this permission notice appear in all copies.
+
+   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+
+
+
+#include "../portasm/portasm-x64.S"
+
+BEGIN_ASM
+
+/*---------------------------------------------------------------------------
+
+  Call Kernel for x64 System V
+
+  Input:
+    RDI : size of arguments to be passed via stack
+    RSI : pointer to arguments to be passed via the stack
+    RDX : pointer to arguments of integral/pointer type to be passed via registers
+    RCX : pointer to arguments of floating point type to be passed via registers
+    R8  : target function pointer
+  Notes:
+    RSP+8: is always 16-byte aligned (32-byte align if __m256 is used)
+*/
+
+GLOBAL(dcCall_x64_sysv)
+BEGIN_PROC(dcCall_x64_sysv)
+	PUSH(RBP)			/* Pseudo-prolog - preserve RBP. */
+	PUSH(RBX)			/* Preserve RBX and store pointer to function in it. */
+	MOV(RSP,RBP)			/* Store stack pointer in RBP. */
+	MOV(R8 ,RBX)
+	MOVSD(QWORD(RCX,0) ,XMM0)	/* Copy first 8 floats to XMM0-XMM7. */
+	MOVSD(QWORD(RCX,8) ,XMM1)
+	MOVSD(QWORD(RCX,16),XMM2)
+	MOVSD(QWORD(RCX,24),XMM3)
+	MOVSD(QWORD(RCX,32),XMM4)
+	MOVSD(QWORD(RCX,40),XMM5)
+	MOVSD(QWORD(RCX,48),XMM6)
+	MOVSD(QWORD(RCX,56),XMM7)
+
+	ADD(LIT(31),RDI)		/* Align stack to 32-byte. */
+	AND(LIT(-32),RDI)
+	ADD(LIT(8),RDI)		/* Adjust by 8-byte for the return-address. */
+	SUB(RDI,RSP)			/* Setup stack frame by subtracting the size of arguments. */
+
+	MOV(RDI,RCX)			/* Store number of bytes to copy to stack in RCX (for rep movsb). */
+	MOV(RSP,RDI)			/* Store pointer to beginning of stack arguments in RDI (for rep movsb). */
+
+	REP(MOVSB)			/* copy bytes (@@@ should be optimized, movq?). */
+
+	MOV(QWORD(RDX,0),RDI)		/* copy first six int/pointer arguments to RDI, RSI, RDX, RCX, R8, R9. */
+	MOV(QWORD(RDX,8),RSI)
+	MOV(QWORD(RDX,24),RCX)
+	MOV(QWORD(RDX,32),R8)
+	MOV(QWORD(RDX,40),R9)
+	MOV(QWORD(RDX,16),RDX)		/* Set RDX last to not overwrite it to soon. */
+
+	MOVB(LIT(8),AL)			/* Put upper bound of number of used xmm registers in AL. */
+	CALL_REG(RBX)			/* Call function. */
+
+	MOV(RBP,RSP)			/* Restore stack pointer. */
+	POP(RBX)			/* Restore RBX. */
+	POP(RBP)			/* Pseudo-epilog. */
+	RET()
+END_PROC(dcCALl_x64_sysv)
+
+/*---------------------------------------------------------------------------
+
+  Call Kernel for x64 Win64
+
+  Input:
+    RCX : size of arguments to be passed via stack
+    RDX : pointer to arguments to be passed via the stack
+    R8  : pointer to arguments of integral/pointer type to be passed via registers
+    R9  : target function pointer
+
+*/
+
+GLOBAL(dcCall_x64_win64)
+BEGIN_PROC(dcCall_x64_win64)
+
+	PUSH(RBP)			/* Pseudo-prolog - preserve RBP. */
+	PUSH(RSI)			/* Preserve RSI and RDI. */
+	PUSH(RDI)
+
+	MOV(RSP,RBP)			/* Store stack pointer in RBP. */
+
+	ADD(LIT(15),RCX)		/* Align stack size to 16 bytes. */
+	AND(LIT(-16),RCX)
+	SUB(RCX,RSP)			/* Setup stack frame by subtracting the size of the arguments. */
+
+
+	MOV(RDX, RSI)			/* Let RSI point to the arguments. */
+	MOV(RSP, RDI)			/* Store pointer to beginning of stack arguments in RDI (for rep movsb). */
+	MOV(R9,  RAX)			/* Put function address in RAX. */
+
+	REP(MOVSB) 			/* @@@ should be optimized (e.g. movq) */
+
+	MOV(QWORD(R8,0),RCX)		/* Copy first four arguments to RCX, RDX, R9, R8 ( and XMM0-XMM3. ) */
+	MOV(QWORD(R8,8),RDX)
+	MOV(QWORD(R8,24),R9)
+	MOV(QWORD(R8,16),R8)
+
+	MOVD(RCX, XMM0)
+	MOVD(RDX, XMM1)
+	MOVD(R8,  XMM2)
+	MOVD(R9,  XMM3)
+
+	PUSH(R9)			/* Push first four arguments onto the stack preserve area. */
+	PUSH(R8)
+	PUSH(RDX)
+	PUSH(RCX)
+
+	CALL_REG(RAX)			/* Invoke function. */
+
+	MOV(RBP, RSP)			/* Restore stack pointer (such that we can pop the preserved vALues). */
+
+	POP(RDI)			/* Restore RSI and RDI. */
+	POP(RSI)
+	POP(RBP)			/* Pseudo-epilog. */
+
+	RET()
+
+END_PROC(dcCall_x64_win64)
+
+END_ASM
+
--- a/dyncall/dyncall_call_x86.S	Thu Jan 05 10:17:37 2017 +0100
+++ b/dyncall/dyncall_call_x86.S	Thu Jan 05 10:35:12 2017 +0100
@@ -35,7 +35,7 @@
       ddCall_x86_sys_XXX(int_ptr target, void* args, size_t size);
  
    Where XXX is one of calling-conventions,
-	cdecl, win32_msthis, win32_std, win32_fastcall.
+      cdecl, win32_msthis, win32_std, win32_fastcall.
 
    Parameter Stack layout:
       size    :=  EBP + 16
@@ -67,14 +67,14 @@
 	ANDL(LIT(-16),ECX)
 	MOVL(ECX,DWORD(EBP,16))		/* save ECX. */
 	SUBL(ECX,ESP)			/* allocate stack size */
-	MOVL(ESP,EDI)			/* EDI = stack ptr */			
-	
+	MOVL(ESP,EDI)			/* EDI = stack ptr */
+
 	/* 
 		work around for rep movsd (not supported by SunPro) 
-	
-	SHRL(LIT(2),ECX)		
+
+	SHRL(LIT(2),ECX)
 	REP(MOVSD)
-	
+
 	*/
 
 	REP(MOVSB)
@@ -185,7 +185,7 @@
 GLOBAL(dcCall_x86_sys_int80h_linux)
 BEGIN_PROC(dcCall_x86_sys_int80h_linux)
 	PUSH(EBP)        		/* prolog. */
- 	MOVL(ESP,EBP)
+	MOVL(ESP,EBP)
 	PUSH(EBX)			/* save preserved. */
 	PUSH(ESI)               
 	PUSH(EDI)
@@ -215,7 +215,7 @@
 GLOBAL(dcCall_x86_sys_int80h_bsd)
 BEGIN_PROC(dcCall_x86_sys_int80h_bsd)
 	PUSH(EBP)			/* prolog. */
- 	MOVL(ESP,EBP)
+	MOVL(ESP,EBP)
 	PUSH(ESI)			/* save preserved. */
 	PUSH(EDI)
 	MOVL(DWORD(EBP,12),ESI)    	/* ESI = pointer on args. */
--- a/dyncall/gen-masm.sh	Thu Jan 05 10:17:37 2017 +0100
+++ b/dyncall/gen-masm.sh	Thu Jan 05 10:35:12 2017 +0100
@@ -3,5 +3,5 @@
 # Uses portasm to generates MASM sources for intel platforms.
 printf "; auto-generated by `basename $0`\r\n" > dyncall_call_x86_generic_masm.asm
 printf "; auto-generated by `basename $0`\r\n" > dyncall_call_x64_generic_masm.asm
-gcc -E -P -DGEN_MASM dyncall_call_x86.S     | awk '{printf "%s\r\n", $0}' >> dyncall_call_x86_generic_masm.asm
-gcc -E -P -DGEN_MASM dyncall_call_x64-att.S | awk '{printf "%s\r\n", $0}' >> dyncall_call_x64_generic_masm.asm
+gcc -E -P -DGEN_MASM dyncall_call_x86.S | awk '{printf "%s\r\n", $0}' >> dyncall_call_x86_generic_masm.asm
+gcc -E -P -DGEN_MASM dyncall_call_x64.S | awk '{printf "%s\r\n", $0}' >> dyncall_call_x64_generic_masm.asm
--- a/dyncallback/dyncall_callback_x64.S	Thu Jan 05 10:17:37 2017 +0100
+++ b/dyncallback/dyncall_callback_x64.S	Thu Jan 05 10:35:12 2017 +0100
@@ -24,7 +24,7 @@
 
 
 
-#include "../portasm/portasm-x64-att.S"
+#include "../portasm/portasm-x64.S"
 
 /* structure sizes */
 
@@ -58,7 +58,7 @@
 
 GLOBAL(dcCallback_x64_sysv)
 BEGIN_PROC(dcCallback_x64_sysv)
-	
+
 	PUSH(RBP)
 	MOV(RSP,RBP)
 
@@ -66,7 +66,7 @@
 
 	/* float parameters (8 registers spill to DCArgs) */
 
-	SUB(LIT(8*8),RSP)	
+	SUB(LIT(8*8),RSP)
 
 	MOVSD(XMM7, QWORD(RSP,8*7))		/* struct offset 120: float parameter 7 */
 	MOVSD(XMM6, QWORD(RSP,8*6))		/* struct offset 112: float parameter 6 */
@@ -95,7 +95,7 @@
 	PUSH(RDX)
 
 	MOV(RSP,RSI)				/* arg 1 RSI : DCArgs* */
-	
+
 	/* initialize DCValue */
 
 	PUSH(LIT(0))				/* struct offset 0: return value (max long long) */
@@ -121,7 +121,7 @@
 
 GLOBAL(dcCallback_x64_win64)
 BEGIN_PROC(dcCallback_x64_win64)
-	
+
 	PUSH(RBP)
 	MOV(RSP,RBP)
 
@@ -129,7 +129,7 @@
 
 	/* float parameters (4 registers spill to DCArgs) */
 
-	SUB(LIT(4*8),RSP)	
+	SUB(LIT(4*8),RSP)
 
 	MOVSD(XMM3, QWORD(RSP,8*3))		/* struct offset  72: float parameter 3 */
 	MOVSD(XMM2, QWORD(RSP,8*2))		/* struct offset  64: float parameter 2 */
@@ -174,7 +174,7 @@
 	POP(RBP)
 	RET()
 
-END_PROC(dcCallback_x64_win64)	
+END_PROC(dcCallback_x64_win64)
 
 END_ASM
 
--- a/dyncallback/dyncall_callback_x86.S	Thu Jan 05 10:17:37 2017 +0100
+++ b/dyncallback/dyncall_callback_x86.S	Thu Jan 05 10:35:12 2017 +0100
@@ -27,29 +27,29 @@
 #include "../dyncall/dyncall_macros.h"
 
 BEGIN_ASM
-DCThunk_size		= 16
-DCArgs_size		= 20
-DCValue_size		=  8
+DCThunk_size = 16
+DCArgs_size  = 20
+DCValue_size =  8
 
-CTX_thunk		=  0
-CTX_phandler		= 16
-CTX_pargsvt		= 20
-CTX_stack_cleanup	= 24
-CTX_userdata		= 28
+CTX_thunk         =  0
+CTX_phandler      = 16
+CTX_pargsvt       = 20
+CTX_stack_cleanup = 24
+CTX_userdata      = 28
 
-frame_arg0         	=  8
-frame_ret          	=  4
-frame_parent       	=  0
-frame_CTX         	= -4
-frame_DCArgs       	= -24
-frame_DCValue      	= -32
+frame_arg0    =  8
+frame_ret     =  4
+frame_parent  =  0
+frame_CTX     = -4
+frame_DCArgs  = -24
+frame_DCValue = -32
 
-#define ASCII_L	76
-#define ASCII_l	108
-#define ASCII_d	100
-#define ASCII_f	102
-#define ASCII_i	105
-#define ASCII_v	118
+#define ASCII_L 76
+#define ASCII_l 108
+#define ASCII_d 100
+#define ASCII_f 102
+#define ASCII_i 105
+#define ASCII_v 118
 
 GLOBAL(dcCallbackThunkEntry)
 BEGIN_PROC(dcCallbackThunkEntry)
@@ -79,7 +79,7 @@
 	CALL_DWORD(EAX,CTX_phandler)
 	/* cleanup stack */
 	MOVL(EBP,ESP)				/* reset esp to frame */
-	POP(ECX)				/* skip parent frame */	
+	POP(ECX)				/* skip parent frame */
 	POP(ECX)				/* pop return address */
 	MOVL(DWORD(EBP,frame_CTX),EDX)	
 	ADD(DWORD(EDX,CTX_stack_cleanup),ESP)	/* cleanup stack */
@@ -94,7 +94,7 @@
 	CMP(LIT(ASCII_d),AL)
 	JE(LOCAL(return_f64))
 #endif
-	
+
 	/* All int cases (+ pointer & string cases) fall in the return_i64 case, here */
 LOCAL(return_i64):
 	MOVL(DWORD(EDX,0),EAX)
--- a/portasm/portasm-x64-att.S	Thu Jan 05 10:17:37 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-/*
-
- Package: dyncall
- Library: portasm
- File: portasm/portasm-x64-att.S
- Description: Portable Assembler Macros for X64
- License:
-
-   Copyright (c) 2011-2015 Daniel Adler <dadler@uni-goettingen.de>
-
-   Permission to use, copy, modify, and distribute this software for any
-   purpose with or without fee is hereby granted, provided that the above
-   copyright notice and this permission notice appear in all copies.
-
-   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-*/
-
-
-
-/* Common macros. */
-#define XCONCAT(A,B) A##B
-#if defined(GEN_MASM)
-/* MASM syntax. */
-.CODE
-#  define BEGIN_ASM
-#  define END_ASM END
-#  define GLOBAL(X) X PROC
-#  define BEGIN_PROC(X) 	OPTION PROLOGUE:NONE, EPILOGUE:NONE
-#  define END_PROC(X)   X ENDP
-#  define PUSH(R) push R
-#  define POP(R) pop R
-#  define MOV(S,D)  mov D,S
-#  define MOVB(S,D) mov D,S
-#  define MOVL(S,D) mov D,S
-#  define ADDL(S,D) add D,S
-#  define ANDL(S,D) and D,S
-#  define SUBL(S,D) sub D,S
-#  define SHRL(S,D) shr D,S
-#  define MOVQ(S,D) movq D,S
-#  define ADD(S,D)  add D,S
-#  define AND(S,D)  and D,S
-#  define SUB(S,D)  sub D,S
-#  define SHR(S,D)  shr D,S
-#  define MOVD(S,D) movd D,S
-#  define RET() ret
-#  define CALL_DWORD(R,OFF) call DWORD(R,OFF)
-#  define REP(X) rep X
-#  define MOVSB movsb
-#  define MOVSW movsw
-#  define MOVSD(S,D)  movsd D,S
-#  define MOVSDX(S,D) movsdx D,S
-#  define DWORD(R,OFF) dword ptr [R+OFF]
-#  define QWORD(R,OFF) qword ptr [R+OFF]
-#  define LIT(X) X
-#  define INT(X) int X
-#  define HEX(X) XCONCAT(X,h)
-#  define CALL(X) call X
-#  define CALL_REG(X) call X
-#  define LEA(S,D) lea D,S
-#  define SET(K,V) K = V
-#  define JE(X) je X
-#  define JNE(X) jne X
-#  define CMP(A,B) cmp B,A
-#  define LOCAL(X) X
-#else
-/* GNU/SunPro Assembler AT&T Syntax */
-	.text
-#  define BEGIN_ASM
-#  define END_ASM
-#  include "../autovar/autovar_OS.h"
-#  if defined (OS_Darwin)
-#    define CSYM(X) _##X
-#  else
-#    define CSYM(X) X
-#  endif
-#  define RAX %rax
-#  define RBX %rbx
-#  define RCX %rcx
-#  define RDX %rdx
-#  define RSI %rsi
-#  define RDI %rdi
-#  define RBP %rbp
-#  define RSP %rsp
-#  define R8   %r8
-#  define R9   %r9
-#  define R10  %r10
-#  define R11  %r11
-#  define R12  %r12
-#  define R13  %r13
-#  define R14  %r14
-#  define R15  %r15
-#  define XMM0 %xmm0
-#  define XMM1 %xmm1
-#  define XMM2 %xmm2
-#  define XMM3 %xmm3
-#  define XMM4 %xmm4
-#  define XMM5 %xmm5
-#  define XMM6 %xmm6
-#  define XMM7 %xmm7
-#  define AL   %al
-#  define AH   %ah
-#  define BL   %bl
-#  define BH   %bh
-#  define CL   %cl
-#  define CH   %ch
-#  define DL   %dl
-#  define DH   %dh
-#  define GLOBAL(X) .globl CSYM(X)
-#  define BEGIN_PROC(X)  CSYM(X):
-#  define END_PROC(X)
-#  define PUSH(R) pushq R
-#  define POP(R) popq R
-#  define MOV(S,D)  movq S,D
-#  define MOVB(S,D) movb S,D
-#  define MOVL(S,D) movl S,D
-#  define ADDL(S,D) addl S,D
-#  define ANDL(S,D) andl S,D
-#  define SUBL(S,D) subl S,D
-#  define SHRL(S,D) shrl S,D
-#  define MOVQ(S,D) movq S,D
-#  define ADD(S,D) addq S,D
-#  define AND(S,D) andq S,D
-#  define SUB(S,D) subq S,D
-#  define SHR(S,D) shrq S,D
-#  define MOVD(S,D) movd S,D
-#  define RET() ret
-#  define CALL_DWORD(R,OFF) call *DWORD(R,OFF)
-#  define REP(X) rep X
-#  define MOVSB movsb
-#  define MOVSW movsw
-#  define MOVSD(S,D) movsd S,D
-#  define DWORD(R,OFF) OFF(R)
-#  define QWORD(R,OFF) OFF(R)
-#  define LIT(X) $X
-#  define INT(X) int X
-#  define HEX(X) XCONCAT(0x,X)
-#  define CALL(X) call X
-#  define CALL_REG(X) call *X
-#  define LEA(A,B) lea A,B
-#  define CMP(A,B) cmp A,B
-#  define CMPB(A,B) cmpb A,B
-#  define JE(X)    je X
-#  define JNE(X)    jne X
-#  define FLDS(X)  flds X
-#  define FLDL(X)  fldl X
-#  define SET(K,V) .set K,V
-#  define LOCAL(X) .X
-#endif
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/portasm/portasm-x64.S	Thu Jan 05 10:35:12 2017 +0100
@@ -0,0 +1,156 @@
+/*
+
+ Package: dyncall
+ Library: portasm
+ File: portasm/portasm-x64.S
+ Description: Portable Assembler Macros for X64
+ License:
+
+   Copyright (c) 2011-2015 Daniel Adler <dadler@uni-goettingen.de>
+
+   Permission to use, copy, modify, and distribute this software for any
+   purpose with or without fee is hereby granted, provided that the above
+   copyright notice and this permission notice appear in all copies.
+
+   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+
+
+
+/* Common macros. */
+#define XCONCAT(A,B) A##B
+#if defined(GEN_MASM)
+/* MASM syntax. */
+.CODE
+#  define BEGIN_ASM
+#  define END_ASM END
+#  define GLOBAL(X) X PROC
+#  define BEGIN_PROC(X) 	OPTION PROLOGUE:NONE, EPILOGUE:NONE
+#  define END_PROC(X)   X ENDP
+#  define PUSH(R) push R
+#  define POP(R) pop R
+#  define MOV(S,D)  mov D,S
+#  define MOVB(S,D) mov D,S
+#  define MOVL(S,D) mov D,S
+#  define ADDL(S,D) add D,S
+#  define ANDL(S,D) and D,S
+#  define SUBL(S,D) sub D,S
+#  define SHRL(S,D) shr D,S
+#  define MOVQ(S,D) movq D,S
+#  define ADD(S,D)  add D,S
+#  define AND(S,D)  and D,S
+#  define SUB(S,D)  sub D,S
+#  define SHR(S,D)  shr D,S
+#  define MOVD(S,D) movd D,S
+#  define RET() ret
+#  define CALL_DWORD(R,OFF) call DWORD(R,OFF)
+#  define REP(X) rep X
+#  define MOVSB movsb
+#  define MOVSW movsw
+#  define MOVSD(S,D)  movsd D,S
+#  define MOVSDX(S,D) movsdx D,S
+#  define DWORD(R,OFF) dword ptr [R+OFF]
+#  define QWORD(R,OFF) qword ptr [R+OFF]
+#  define LIT(X) X
+#  define INT(X) int X
+#  define HEX(X) XCONCAT(X,h)
+#  define CALL(X) call X
+#  define CALL_REG(X) call X
+#  define LEA(S,D) lea D,S
+#  define SET(K,V) K = V
+#  define JE(X) je X
+#  define JNE(X) jne X
+#  define CMP(A,B) cmp B,A
+#  define LOCAL(X) X
+#else
+/* GNU/SunPro Assembler AT&T Syntax */
+	.text
+#  define BEGIN_ASM
+#  define END_ASM
+#  include "../autovar/autovar_OS.h"
+#  if defined (OS_Darwin)
+#    define CSYM(X) _##X
+#  else
+#    define CSYM(X) X
+#  endif
+#  define RAX %rax
+#  define RBX %rbx
+#  define RCX %rcx
+#  define RDX %rdx
+#  define RSI %rsi
+#  define RDI %rdi
+#  define RBP %rbp
+#  define RSP %rsp
+#  define R8   %r8
+#  define R9   %r9
+#  define R10  %r10
+#  define R11  %r11
+#  define R12  %r12
+#  define R13  %r13
+#  define R14  %r14
+#  define R15  %r15
+#  define XMM0 %xmm0
+#  define XMM1 %xmm1
+#  define XMM2 %xmm2
+#  define XMM3 %xmm3
+#  define XMM4 %xmm4
+#  define XMM5 %xmm5
+#  define XMM6 %xmm6
+#  define XMM7 %xmm7
+#  define AL   %al
+#  define AH   %ah
+#  define BL   %bl
+#  define BH   %bh
+#  define CL   %cl
+#  define CH   %ch
+#  define DL   %dl
+#  define DH   %dh
+#  define GLOBAL(X) .globl CSYM(X)
+#  define BEGIN_PROC(X)  CSYM(X):
+#  define END_PROC(X)
+#  define PUSH(R) pushq R
+#  define POP(R) popq R
+#  define MOV(S,D)  movq S,D
+#  define MOVB(S,D) movb S,D
+#  define MOVL(S,D) movl S,D
+#  define ADDL(S,D) addl S,D
+#  define ANDL(S,D) andl S,D
+#  define SUBL(S,D) subl S,D
+#  define SHRL(S,D) shrl S,D
+#  define MOVQ(S,D) movq S,D
+#  define ADD(S,D) addq S,D
+#  define AND(S,D) andq S,D
+#  define SUB(S,D) subq S,D
+#  define SHR(S,D) shrq S,D
+#  define MOVD(S,D) movd S,D
+#  define RET() ret
+#  define CALL_DWORD(R,OFF) call *DWORD(R,OFF)
+#  define REP(X) rep X
+#  define MOVSB movsb
+#  define MOVSW movsw
+#  define MOVSD(S,D) movsd S,D
+#  define DWORD(R,OFF) OFF(R)
+#  define QWORD(R,OFF) OFF(R)
+#  define LIT(X) $X
+#  define INT(X) int X
+#  define HEX(X) XCONCAT(0x,X)
+#  define CALL(X) call X
+#  define CALL_REG(X) call *X
+#  define LEA(A,B) lea A,B
+#  define CMP(A,B) cmp A,B
+#  define CMPB(A,B) cmpb A,B
+#  define JE(X)    je X
+#  define JNE(X)    jne X
+#  define FLDS(X)  flds X
+#  define FLDL(X)  fldl X
+#  define SET(K,V) .set K,V
+#  define LOCAL(X) .X
+#endif
+