diff options
| author | Eugen Wissner <belka@caraus.de> | 2017-07-31 04:23:21 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2017-07-31 04:23:21 +0200 |
| commit | 04864559e23b511ad853c7c1dc0acccce73fa629 (patch) | |
| tree | b8771b4ecb3d640cae8b6f278b4f5cec109d47d3 | |
| parent | 40e43c14657b58cced174f099b0ba2d0cfdb3532 (diff) | |
| download | tanya-04864559e23b511ad853c7c1dc0acccce73fa629.tar.gz | |
Respect how Windows passes arrays on x86_64
tanya.memory.arch.x86_64:
Linux passes the array length and the data pointer in separate registers.
Windows passes a pointer to the whole array instead (pointer to the
array length practically).
| -rw-r--r-- | source/tanya/memory/arch/x86_64.d | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/source/tanya/memory/arch/x86_64.d b/source/tanya/memory/arch/x86_64.d index bd5f5a1..0c3b86f 100644 --- a/source/tanya/memory/arch/x86_64.d +++ b/source/tanya/memory/arch/x86_64.d @@ -22,19 +22,32 @@ pure nothrow @system @nogc { naked; - // RDX - source length. - // RCX - source data. - // RDI - target length. - // RSI - target data. - // RDI and RSI should be preserved. mov RAX, RDI; mov R8, RSI; + } + // Set the registers for movsb/movsq. + version (Windows) asm pure nothrow @nogc + { + // RDX - source. + // RCX - target. + + mov RDI, [ RCX + 8 ]; + mov RSI, [ RDX + 8 ]; + mov RDX, [ RDX ]; + } + else asm pure nothrow @nogc + { + // RDX - source length. + // RCX - source data. + // RDI - target length + // RSI - target data. - // Set the registers for movsb/movsq. mov RDI, RSI; mov RSI, RCX; - + } + asm pure nothrow @nogc + { cmp RDX, 0x08; jc aligned_8; test EDI, 0x07; @@ -54,7 +67,7 @@ pure nothrow @system @nogc and EDX, 0x07; jz end; - // Write remaining bytes. + // Write the remaining bytes. mov RCX, RDX; rep; movsb; |
