summaryrefslogtreecommitdiff
path: root/TestPrograms/test_x86_via_rng.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2021-04-20 04:44:21 -0400
committerJeffrey Walton <noloader@gmail.com>2021-04-20 04:44:21 -0400
commitc15aeaa7b5cdf4409d034a50efb3c0d2959a3f6a (patch)
tree0aabdf1ae1eccc30a641901e3c87144c6a6a6338 /TestPrograms/test_x86_via_rng.cpp
parent21799b1fba6d9d3148cb56003a21f42f6fd086ed (diff)
downloadcryptopp-git-c15aeaa7b5cdf4409d034a50efb3c0d2959a3f6a.tar.gz
Use *.cpp file extension for test programs (GH #1024)
Diffstat (limited to 'TestPrograms/test_x86_via_rng.cpp')
-rw-r--r--TestPrograms/test_x86_via_rng.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/TestPrograms/test_x86_via_rng.cpp b/TestPrograms/test_x86_via_rng.cpp
new file mode 100644
index 00000000..1ecd8f53
--- /dev/null
+++ b/TestPrograms/test_x86_via_rng.cpp
@@ -0,0 +1,38 @@
+#include <cstdlib>
+int main(int argc, char* argv[])
+{
+ unsigned int msr=0;
+ unsigned int divisor=2;
+ unsigned int buffer;
+
+ __asm__ __volatile__
+ (
+#if defined(__x86_64__) || defined(__amd64__)
+ "mov %1, %%rdi ;\n"
+ "movl %2, %%edx ;\n"
+#else
+ "mov %1, %%edi ;\n"
+ "movl %2, %%edx ;\n"
+#endif
+
+ // xstore-rng
+ ".byte 0x0f, 0xa7, 0xc0 ;\n"
+
+#if defined(__x86_64__) || defined(__amd64__)
+ "andq %%rax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#else
+ "andl %%eax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#endif
+
+ : "=g" (msr) : "g" (buffer), "g" (divisor)
+#if defined(__x86_64__) || defined(__amd64__)
+ : "rax", "rdx", "rdi", "cc"
+#else
+ : "eax", "edx", "edi", "cc"
+#endif
+ );
+
+ return 0;
+}