diff portasm/portasm-x64.S @ 533:71c884e610f0

- integration of patches from Raphael Luba, Thekla, Inc.: * integration of aggregate-by-value (struct, union) support patch for x64 (win and sysv) * windows/x64 asm additions to specify how stack unwinds (help for debuggers, exception handling, etc.) * see Changelog for details - new calling convention modes for thiscalls (platform agnostic, was specific before) * new signature character for platform agnostic thiscalls ('*' / DC_SIGCHAR_CC_THISCALL) - dcCallF(), dcVCallF(), dcArgF() and dcVArgF(): * added support for aggregates-by-value (wasn't part of patch) * change that those functions don't implicitly call dcReset() anymore, which was unflexible (breaking change) - added macros to feature test implementation for aggregate-by-value and syscall support - changed libdyncall_s.lib and libdyncallback_s.lib order in callback test makefiles, as some toolchains are picky about order - doc: * man page updates to describe aggregate interface * manual overview changes to highlight platforms with aggregate-by-value support - test/plain: replaced tests w/ old/stale sctruct interface with new aggregate one
author Tassilo Philipp
date Thu, 21 Apr 2022 13:35:47 +0200
parents f5577f6bf97a
children 6a8aac9b2bcf
line wrap: on
line diff
--- a/portasm/portasm-x64.S	Sat Apr 16 15:00:58 2022 +0200
+++ b/portasm/portasm-x64.S	Thu Apr 21 13:35:47 2022 +0200
@@ -6,7 +6,8 @@
  Description: Portable Assembler Macros for X64
  License:
 
-   Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>
+   Copyright (c) 2007-2022 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
@@ -31,24 +32,32 @@
 .CODE
 #  define BEGIN_ASM
 #  define END_ASM END
-#  define GLOBAL(X) X PROC
-#  define BEGIN_PROC(X) 	OPTION PROLOGUE:NONE, EPILOGUE:NONE
+#  define CSYM(X) X
+#  define GLOBAL(X)       X PROC
+#  define GLOBAL_FRAME(X) X PROC FRAME
+#  define BEGIN_PROC(X)       OPTION PROLOGUE:NONE, EPILOGUE:NONE
+#  define FRAME_BEGIN_PROC(X) OPTION EPILOGUE:NONE
+#  define FRAME_SET(OFFSET, X)  .setframe X, OFFSET
+#  define FRAME_PUSH_REG(X)   .pushreg X
+#  define FRAME_ENDPROLOG()   .endprolog
 #  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 MOVZXQ(S,D) movzx 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 SHLQ(S,D) shl 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 XOR(S,D) xor D,S
 #  define RET() ret
 #  define CALL_DWORD(R,OFF) call DWORD(R,OFF)
 #  define REP(X) rep X
@@ -56,6 +65,7 @@
 #  define MOVSW movsw
 #  define MOVSD(S,D)  movsd D,S
 #  define MOVSDX(S,D) movsdx D,S
+#  define BYTE(R) byte ptr [R]
 #  define DWORD(R,OFF) dword ptr [R+OFF]
 #  define QWORD(R,OFF) qword ptr [R+OFF]
 #  define LIT(X) X
@@ -67,7 +77,8 @@
 #  define SET(K,V) K = V
 #  define JE(X) je X
 #  define JNE(X) jne X
-#  define CMP(A,B) cmp B,A
+#  define JMP(X) jmp X
+#  define CMPL(A,B) cmp B,A
 #  define LOCAL(X) X
 /* @@@ check if masm support wanted/needed */
 #  define SECTION_NOTE_NXSTACK
@@ -91,6 +102,7 @@
 #  define RBP %rbp
 #  define RSP %rsp
 #  define R8   %r8
+#  define R8D  %r8d
 #  define R9   %r9
 #  define R10  %r10
 #  define R11  %r11
@@ -114,30 +126,38 @@
 #  define CH   %ch
 #  define DL   %dl
 #  define DH   %dh
-#  define GLOBAL(X) .globl CSYM(X)
-#  define BEGIN_PROC(X)  CSYM(X):
+#  define GLOBAL(X)       .globl CSYM(X)
+#  define GLOBAL_FRAME(X) .globl CSYM(X)
+#  define BEGIN_PROC(X)       CSYM(X):
+#  define FRAME_BEGIN_PROC(X) CSYM(X):
+#  define FRAME_SET(OFFSET, X)
+#  define FRAME_PUSH_REG(X)
+#  define FRAME_ENDPROLOG()
 #  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 MOVZXQ(S,D) movzbq 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 SHLQ(S,D) shlq 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 XOR(S,D) xorq 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 BYTE(R)  (R)
 #  define DWORD(R,OFF) OFF(R)
 #  define QWORD(R,OFF) OFF(R)
 #  define LIT(X) $X
@@ -146,10 +166,10 @@
 #  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 CMPL(A,B) cmpl A,B
 #  define JE(X)    je X
 #  define JNE(X)    jne X
+#  define JMP(X)    jmp X
 #  define FLDS(X)  flds X
 #  define FLDL(X)  fldl X
 /* not available on some platforms, e.g. old solaris, so use K=V syntax #  define SET(K,V) .set K,V */