summaryrefslogtreecommitdiff
path: root/x64dll.asm
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2020-02-07 14:19:46 -0500
committerJeffrey Walton <noloader@gmail.com>2020-02-07 14:19:46 -0500
commit18b535fb5a1e51fab5c5a6fb3dc316ec93b876a4 (patch)
tree727f3de9a55cea7f9ac6a5de1d83c1fcd6b4b6d0 /x64dll.asm
parent9f0b2e27bbae01012cee0dcd2ad0ca9d24f33c33 (diff)
downloadcryptopp-git-18b535fb5a1e51fab5c5a6fb3dc316ec93b876a4.tar.gz
Add CPUID64 for MSVC missing __cpuidex
Diffstat (limited to 'x64dll.asm')
-rw-r--r--x64dll.asm42
1 files changed, 40 insertions, 2 deletions
diff --git a/x64dll.asm b/x64dll.asm
index fdb88ea7..f77525ed 100644
--- a/x64dll.asm
+++ b/x64dll.asm
@@ -1964,10 +1964,23 @@ pop rsi
ret
SHA256_HashMultipleBlocks_SSE2 ENDP
+;; https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention
+;; The first four integer arguments are passed in registers.
+;; Integer values are passed in left-to-right order in RCX,
+;; RDX, R8, and R9, respectively. Arguments five and higher
+;; are passed on the stack.
+
+;; The registers RAX, RCX, RDX, R8, R9, R10, R11, XMM0-5,
+;; and the upper portions of YMM0-15 and ZMM0-15 are
+;; considered volatile and must be considered destroyed on
+;; function calls
+
+;; http://www.agner.org/optimize/vectorclass/read.php?i=65
+;; word64 Xgetbv(word32 ctrl)
+;; ctrl = rcx
+
ALIGN 8
XGETBV64 PROC
-;; First paramter is RCX, and xgetbv expects the CTRL in ECX
-;; http://www.agner.org/optimize/vectorclass/read.php?i=65
DB 0fh, 01h, 0d0h
;; xcr = (EDX << 32) | EAX
and rax, 0ffffffffh
@@ -1976,5 +1989,30 @@ or rax, rdx
ret
XGETBV64 ENDP
+;; word64 CpuId(word32 func, word32 subfunc, word32 output[4])
+;; func = rcx
+;; subfunc = rdx
+;; output = r8
+
+ ALIGN 8
+CPUID64 PROC
+;; must be preserved
+push rbx
+;; eax = func
+mov rax, rcx
+;; ecx = subfunc
+mov rcx, rdx
+cpuid
+mov [r8+0], eax
+mov [r8+4], ebx
+mov [r8+8], ecx
+mov [r8+12], edx
+;; restore
+pop rbx
+;; return
+mov rax, 1
+ret
+CPUID64 ENDP
+
_TEXT ENDS
END