diff options
Diffstat (limited to 'sample')
-rw-r--r-- | sample/bf.cpp | 19 | ||||
-rw-r--r-- | sample/calc.cpp | 1 | ||||
-rw-r--r-- | sample/calc2.cpp | 1 | ||||
-rw-r--r-- | sample/jmp_table.cpp | 1 | ||||
-rw-r--r-- | sample/memfd.cpp | 2 | ||||
-rw-r--r-- | sample/memfunc.cpp | 1 | ||||
-rw-r--r-- | sample/protect-re.cpp | 1 | ||||
-rw-r--r-- | sample/quantize.cpp | 1 | ||||
-rw-r--r-- | sample/stackframe.cpp | 1 | ||||
-rw-r--r-- | sample/static_buf.cpp | 1 | ||||
-rw-r--r-- | sample/test0.cpp | 1 | ||||
-rw-r--r-- | sample/toyvm.cpp | 1 |
12 files changed, 17 insertions, 14 deletions
diff --git a/sample/bf.cpp b/sample/bf.cpp index 657c87c..06f1dac 100644 --- a/sample/bf.cpp +++ b/sample/bf.cpp @@ -1,4 +1,3 @@ -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak.h" #include <stdio.h> #include <stdlib.h> @@ -189,18 +188,30 @@ int main(int argc, char *argv[]) fprintf(stderr, "64bit mode\n"); #endif if (argc == 1) { - fprintf(stderr, "bf filename.bf [0|1]\n"); + fprintf(stderr, "bf filename.bf [0|1|2]\n"); return 1; } std::ifstream ifs(argv[1]); int mode = argc == 3 ? atoi(argv[2]) : 0; try { Brainfuck bf(ifs); - if (mode == 0) { + switch (mode) { + case 0: { static int stack[128 * 1024]; bf.getCode<void (*)(const void*, const void*, int *)>()(reinterpret_cast<const void*>(putchar), reinterpret_cast<const void*>(getchar), stack); - } else { + break; + } + case 1: { dump(bf.getCode(), bf.getSize()); + break; + } + default: { + const char *dumpName = "bf.dump"; + printf("dump to %s\n", dumpName); + std::ofstream ofs(dumpName, std::ios::binary); + ofs.write((const char*)bf.getCode(), bf.getSize()); + break; + } } } catch (std::exception& e) { printf("ERR:%s\n", e.what()); diff --git a/sample/calc.cpp b/sample/calc.cpp index 29ad9c3..d543d04 100644 --- a/sample/calc.cpp +++ b/sample/calc.cpp @@ -10,7 +10,6 @@ #include <stdio.h> #include <sstream> #include <map> -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak.h" #ifdef _MSC_VER #pragma warning(disable : 4127) // for boost(constant condition) diff --git a/sample/calc2.cpp b/sample/calc2.cpp index a13d2cf..62fb900 100644 --- a/sample/calc2.cpp +++ b/sample/calc2.cpp @@ -22,7 +22,6 @@ #include <assert.h> #include <string> #include <vector> -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak.h" enum Operand { diff --git a/sample/jmp_table.cpp b/sample/jmp_table.cpp index fb47cac..4e0ca6e 100644 --- a/sample/jmp_table.cpp +++ b/sample/jmp_table.cpp @@ -2,7 +2,6 @@ sample of move(reg, LABEL);, L(LABEL), putL(LABEL); */ #include <stdio.h> -#define XBYAK_NO_OP_NAMES #include <xbyak/xbyak.h> const int expectTbl[] = { diff --git a/sample/memfd.cpp b/sample/memfd.cpp index 2b6d08b..312e7ca 100644 --- a/sample/memfd.cpp +++ b/sample/memfd.cpp @@ -25,6 +25,7 @@ public: int main() { + printf("pid=%d\n", getpid()); Code c1("Xbyak::abc", 123); Code c2("Xbyak::xyz", 456); printf("c1 %d\n", c1.getCode<int (*)()>()()); @@ -36,4 +37,5 @@ int main() printf("%s\n", line.c_str()); } } + getchar(); } diff --git a/sample/memfunc.cpp b/sample/memfunc.cpp index b97630b..65b0f04 100644 --- a/sample/memfunc.cpp +++ b/sample/memfunc.cpp @@ -1,7 +1,6 @@ #include <stdio.h> #include <stdlib.h> #include <memory.h> -#define XBYAK_NO_OP_NAMES #include <xbyak/xbyak.h> struct A { diff --git a/sample/protect-re.cpp b/sample/protect-re.cpp index 6eaa863..a8f77cd 100644 --- a/sample/protect-re.cpp +++ b/sample/protect-re.cpp @@ -1,4 +1,3 @@ -#define XBYAK_NO_OP_NAMES #include <xbyak/xbyak.h> struct Code1 : Xbyak::CodeGenerator { diff --git a/sample/quantize.cpp b/sample/quantize.cpp index ba0fd22..f45337c 100644 --- a/sample/quantize.cpp +++ b/sample/quantize.cpp @@ -42,7 +42,6 @@ #include <stdio.h> #include <stdlib.h> #include <time.h> -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak.h" #ifdef _MSC_VER #pragma warning(disable : 4996) // scanf diff --git a/sample/stackframe.cpp b/sample/stackframe.cpp index 7405b40..f324bde 100644 --- a/sample/stackframe.cpp +++ b/sample/stackframe.cpp @@ -1,4 +1,3 @@ -#define XBYAK_NO_OP_NAMES #include <xbyak/xbyak_util.h> #ifdef XBYAK32 diff --git a/sample/static_buf.cpp b/sample/static_buf.cpp index 0a8ff57..0d87101 100644 --- a/sample/static_buf.cpp +++ b/sample/static_buf.cpp @@ -2,7 +2,6 @@ sample to use static memory */ #include <stdio.h> -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak.h" MIE_ALIGN(4096) char buf[4096]; diff --git a/sample/test0.cpp b/sample/test0.cpp index afbaf83..924c816 100644 --- a/sample/test0.cpp +++ b/sample/test0.cpp @@ -7,7 +7,6 @@ #endif #include <stdio.h> #include <stdlib.h> -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak.h" class Sample : public Xbyak::CodeGenerator { diff --git a/sample/toyvm.cpp b/sample/toyvm.cpp index dff0cb7..b6549a1 100644 --- a/sample/toyvm.cpp +++ b/sample/toyvm.cpp @@ -27,7 +27,6 @@ #include <stdlib.h> #include <memory.h> #include <vector> -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak.h" #include "xbyak/xbyak_util.h" #define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0])) |