Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_mmx.cpp
Go to the documentation of this file.
1#if defined(_MSC_VER) && (_MSC_VER <= 1200)
2 #pragma warning(disable:4514)
3 #pragma warning(disable:4786)
4#endif
5#include <stdio.h>
6#include <stdlib.h>
7#include "../../include.mie/mie_thread.h"
8#include "xbyak/xbyak.h"
9
11public:
13 {
14#ifdef XBYAK32
15 mov(ecx, ptr [esp + 4]);
16#endif
17 movd(mm0, ecx);
18 ret();
19 }
20 void (*set() const)(int x) { return (void (*)(int x))getCode(); }
21};
22
24public:
26 {
27 movd(eax, mm0);
28 ret();
29 }
30 int (*get() const)() { return (int (*)())getCode(); }
31};
32
33class Test : public MIE::ThreadBase<Test> {
34 int n_;
35public:
36 Test(int n)
37 : n_(n)
38 {
39 }
41 {
42 printf("n=%d\n", n_);
43 WriteMMX w;
44 w.set()(n_);
45 ReadMMX r;
46 for (;;) {
47 int b = r.get()();
48 printf("b=%d\n", b);
49 if (b != n_) {
50 printf("mm0 has changed!\n");
51 }
52 MIE::MIE_Sleep(1000);
53 }
54 }
55 void stopThread() { }
56};
57
58int main(int argc, char *argv[])
59{
60#ifdef XBYAK32
61 puts("32bit");
62#else
63 puts("64bit");
64#endif
65 try {
66 int n = atoi(argc == 1 ? "1223" : argv[1]);
67 Test test0(n), test1(n + 1);
68 test0.beginThread();
69 test1.beginThread();
70
71 test0.joinThread();
72 test1.joinThread();
73 } catch (std::exception& e) {
74 printf("ERR:%s\n", e.what());
75 } catch (...) {
76 printf("unknown error\n");
77 }
78}
void test1()
const mie::Vuint & r
Definition bn.cpp:28
int(*)() get() const
Definition test_mmx.cpp:30
void stopThread()
Definition test_mmx.cpp:55
Test(int n)
Definition test_mmx.cpp:36
void threadEntry()
Definition test_mmx.cpp:40
void(*)(int x) set() const
Definition test_mmx.cpp:20
const uint8 * getCode() const
Definition xbyak.h:905
const Reg32 esp
Definition xbyak.h:2087
const Reg32 eax
Definition xbyak.h:2087
void movd(const Address &addr, const Mmx &mmx)
Definition xbyak.h:454
const Reg32 ecx
Definition xbyak.h:2087
void mov(const Operand &reg1, const Operand &reg2)
Definition xbyak.h:2210
const AddressFrame ptr
Definition xbyak.h:2090
char ** argv
Xbyak ; JIT assembler for x86(IA32)/x64 by C++.
CK_RV ret