OSDN Git Service

jitCompPutImm32等をdefine化
authorhikarupsp <hikarupsp@users.sourceforge.jp>
Sat, 15 Mar 2014 05:22:08 +0000 (14:22 +0900)
committerhikarupsp <hikarupsp@users.sourceforge.jp>
Sat, 15 Mar 2014 05:22:08 +0000 (14:22 +0900)
jitc.h
jitcx86.c

diff --git a/jitc.h b/jitc.h
index 7e49a4a..1ddcae8 100644 (file)
--- a/jitc.h
+++ b/jitc.h
@@ -1,4 +1,4 @@
-\r
+\r
 #ifndef HeavyOSECPU_jitc_h\r
 #define HeavyOSECPU_jitc_h\r
 \r
@@ -51,7 +51,12 @@ int jitCompCmdLen(const unsigned char *src);
 #define envOffset_DBGINFO0             (2304 + 0)\r
 #define envOffset_DBGINFO1             (2304 + 4)\r
 //\r
-#define jitCompPutOp_PUSHAD(p) jitCompPutByte1(p, 0x60);\r
+#define jitCompPutImm32(p, i)                                  jitCompPutByte4(p, ((i) & 0xff), (((i) >> 8) & 0xff), (((i) >> 16) & 0xff), (((i) >> 24) & 0xff))\r
+#define jitCompPutOp_PUSHAD(p)                                 jitCompPutByte1(p, 0x60);\r
+#define jitCompPutOp_POPAD(p)                                  jitCompPutByte1(p, 0x61);\r
+#define jitCompPutOp_PUSH_GReg(p, reg)                 jitCompPutByte1(p, 0x50 | (reg));\r
+#define jitCompPutOp_POP_GReg(p, reg)                  jitCompPutByte1(p, 0x58 | (reg));\r
+#define jitCompPutOp_CALL_Relative(p, diff)            jitCompPutByte1(w.dst, 0xe8); jitCompPutImm32(&w, j);\r
 \r
 \r
 // Optimization settings\r
@@ -76,7 +81,6 @@ struct JitCompWork {
        char prefix;    //CND命令の値を記録(初期値=0)\r
 };\r
 \r
-void jitCompPutImm32(struct JitCompWork *w, int i);\r
 int jitCompGetImm32(const unsigned char *src);\r
 int jitCompGetLabelNum(struct JitCompWork *w, const unsigned char *src);\r
 void jitCompA0001_85DispN(struct JitCompWork *w, int disp, int n);\r
index 18743ab..5c849af 100644 (file)
--- a/jitcx86.c
+++ b/jitcx86.c
@@ -5,16 +5,6 @@
 //\r
 // for x86-32bit\r
 //\r
-\r
-void jitCompPutImm32(struct JitCompWork *w, int i)\r
-{\r
-       jitCompPutByte1(w->dst, i & 0xff);\r
-       jitCompPutByte1(w->dst, (i >> 8) & 0xff);\r
-       jitCompPutByte1(w->dst, (i >> 16) & 0xff);\r
-       jitCompPutByte1(w->dst, (i >> 24) & 0xff);\r
-       return;\r
-}\r
-\r
 int jitCompGetImm32(const unsigned char *src)\r
 {\r
        return (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];\r
@@ -38,7 +28,7 @@ void jitCompA0001_85DispN(struct JitCompWork *w, int disp, int n)
        } else {\r
                // 10 + reg + 101 + disp\r
                jitCompPutByte1(w->dst, 0x85 | (n << 3));\r
-               jitCompPutImm32(w, disp);\r
+               jitCompPutImm32(w->dst, disp);\r
        }\r
        return;\r
 }\r
@@ -64,7 +54,7 @@ void jitCompA0001_movEaxRxx(struct JitCompWork *w, int rxx)
 #if (jitCompA0001_USE_R3F_IMM32 != 0)\r
        if (rxx == 0x3f) {\r
                jitCompPutByte1(w->dst, 0xb8); /* MOV(EAX, ?); */\r
-               jitCompPutImm32(w, w->r3f);\r
+               jitCompPutImm32(w->dst, w->r3f);\r
                return;\r
        }\r
 #endif\r
@@ -242,7 +232,7 @@ void jitCompA0001_checkType0(struct JitCompWork *w, int pxx, int typ, int ac)
        jitCompA0001_movReg32EbpDisp(w, 0 /* EAX */, 256 + pxx * 32 + 4); /* MOV(EAX, [EBP+?]); */      /* typ */\r
        jitCompPutByte3(w->dst, 0x83, 0xf8, typ & 0x7f);        /* CMP(EAX, ?); */\r
        jitCompPutByte2(w->dst, 0x0f, 0x85); /* JNE */\r
-       jitCompPutImm32(w, errfnc - (w->dst + 4));\r
+       jitCompPutImm32(w->dst, errfnc - (w->dst + 4));\r
        return;\r
 }\r
 \r
@@ -259,11 +249,11 @@ void jitCompA0001_checkLimit(struct JitCompWork *w, int reg, int pxx)
        jitCompPutByte1(w->dst, 0x3b);  /* CMP(reg, [EBP+?]); */\r
        jitCompA0001_85DispN(w, 256 + pxx * 32 + 8, reg);       /* p0 */\r
        jitCompPutByte2(w->dst, 0x0f, 0x82); /* JB */\r
-       jitCompPutImm32(w, errfnc - (w->dst + 4));\r
+       jitCompPutImm32(w->dst, errfnc - (w->dst + 4));\r
        jitCompPutByte1(w->dst, 0x3b);  /* CMP(reg, [EBP+?]); */\r
        jitCompA0001_85DispN(w, 256 + pxx * 32 + 12, reg);      /* p1 */\r
        jitCompPutByte2(w->dst, 0x0f, 0x83); /* JAE */\r
-       jitCompPutImm32(w, errfnc - (w->dst + 4));\r
+       jitCompPutImm32(w->dst, errfnc - (w->dst + 4));\r
        return;\r
 }\r
 \r
@@ -301,7 +291,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                jitCompA0001_movEbpDispReg32(&w, envOffset_DBGINFO0, IA32_REG0_EAX);\r
                // MOV(EAX, ?);\r
                jitCompPutByte1(w.dst, 0xb8);   /* MOV(EAX, imm32); */\r
-               jitCompPutImm32(&w, debugInfo1);\r
+               jitCompPutImm32(w.dst, debugInfo1);\r
                jitCompA0001_movEbpDispReg32(&w, envOffset_DBGINFO1, IA32_REG0_EAX); /* MOV(debugInfo1, EAX); */\r
        }\r
        while (src < src1) {\r
@@ -337,7 +327,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        // LB命令の後に0x3C命令・・・beginFunc()\r
                                        jitCompPutByte1(w.dst, 0xe9);   // (x86) JMP rel32 : 次の命令との相対オフセットだけ相対ニアジャンプする\r
                                        enter0 = w.dst;\r
-                                       jitCompPutImm32(&w, 0); // 飛び相対座標が0 ・・・パイプラインのフラッシュ??\r
+                                       jitCompPutImm32(w.dst, 0);      // 飛び相対座標が0 ・・・パイプラインのフラッシュ??\r
                                }\r
                                if (src[6] == 0x34) {   // LBの次の命令がDATA ・・・DAT_SA0(label, typ32, length) ・・・メモリ確保命令\r
                                        tmp_ucp = w.dst;\r
@@ -353,7 +343,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        }\r
                                        j *= jitCompGetImm32(&src[11]);\r
                                        if (j <= 0) w.err = JITC_ERR_BADTYPE;\r
-                                       jitCompPutImm32(&w, j);\r
+                                       jitCompPutImm32(w.dst, j);\r
 #if (jitCompA0001_OPTIMIZE_JMP != 0)\r
                                        if (j <= 127 - jitCompA0001_OPTIMIZE_ALIGN) {\r
                                                w.dst -= 5;\r
@@ -370,9 +360,9 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        if (i == 2) { jitCompPutByte2(w.dst, 0x89, 0xc0); j += i; } /* MOV(EAX, EAX); */\r
                                        if (i == 3) { jitCompPutByte3(w.dst, 0x8d, 0x76, 0x00); j += i; } /* LEA(ESI, [ESI+0]); */\r
                                        if (i == 4) { jitCompPutByte4(w.dst, 0x8d, 0x74, 0x26, 0x00); j += i; } /* LEA(ESI, [ESI*1+0]); */\r
-                                       if (i == 5) { jitCompPutByte1(w.dst, 0x0d); jitCompPutImm32(&w, 0); j += i; } /* OR(EAX, 0); */\r
-                                       if (i == 6) { jitCompPutByte2(w.dst, 0x8d, 0xb6); jitCompPutImm32(&w, 0); j += i; } /* LEA(ESI, [ESI+0]); */\r
-                                       if (i >= 7) { jitCompPutByte3(w.dst, 0x8d, 0xb4, 0x26); jitCompPutImm32(&w, 0); j += 7; } /* LEA(ESI, [ESI*1+0]); */\r
+                                       if (i == 5) { jitCompPutByte1(w.dst, 0x0d); jitCompPutImm32(w.dst, 0); j += i; } /* OR(EAX, 0); */\r
+                                       if (i == 6) { jitCompPutByte2(w.dst, 0x8d, 0xb6); jitCompPutImm32(w.dst, 0); j += i; } /* LEA(ESI, [ESI+0]); */\r
+                                       if (i >= 7) { jitCompPutByte3(w.dst, 0x8d, 0xb4, 0x26); jitCompPutImm32(w.dst, 0); j += 7; } /* LEA(ESI, [ESI*1+0]); */\r
                                }\r
 #endif\r
                                if (src[6] == 0x34) {\r
@@ -433,7 +423,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                \r
                                /* reg0 のレジスタに対応したMOV命令を発行 */\r
                                jitCompPutByte1(w.dst, 0xb8 | reg0);    /* MOV(reg0, ?);  == 10111000b+wr imm32 */\r
-                               jitCompPutImm32(&w, i);\r
+                               jitCompPutImm32(w.dst, i);\r
                                \r
                                if (reg0 == 0)  // R03以降の、レジスタの内容をメモリ上に格納してエミュレートする場合\r
                                        \r
@@ -482,7 +472,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        j = 0;\r
                                        if ((flags & JITC_PHASE1) != 0 || (((flags & JITC_PHASE1) == 0) && label[i].opt != 0))  // label番号iが確保されていれば (このif文は意味をなさない)\r
                                                j = label[i].p - (w.dst + 4);   // j はとび先の相対番地\r
-                                       jitCompPutImm32(&w, j); // JMP もしくは JZ 命令のアドレス部を記述\r
+                                       jitCompPutImm32(w.dst, j);      // JMP もしくは JZ 命令のアドレス部を記述\r
 #if (jitCompA0001_OPTIMIZE_JMP != 0)\r
                                        if (-128 - 3 <= j && j < 0) {\r
                                                if (w.dst[-5] == 0xe9) {\r
@@ -504,7 +494,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        // 代入先が P01, P02なら ESI, EDI,それ以外ならEAXを指定\r
                                        reg0 = jitCompA000_selectPRegCache(src[1], IA32_REG0_EAX);\r
                                        jitCompPutByte1(w.dst, 0xb8 | reg0);    /* MOV(reg0, ?); */\r
-                                       jitCompPutImm32(&w, (int)label[i].p);   // ラベルのパスを各レジスタに代入\r
+                                       jitCompPutImm32(w.dst, (int)label[i].p);        // ラベルのパスを各レジスタに代入\r
                                        \r
                                        // レジスタへの代入をメモリでエミュレーションする場合は、スタックに積む。\r
                                        if (reg0 == 0)\r
@@ -513,10 +503,10 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        if (level < JITC_LV_FASTEST) {\r
                                                jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 8, reg0); /* MOV([EBP+?], reg0); */ /* p0 */\r
                                                jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */\r
-                                               jitCompPutImm32(&w, label[i].typ);\r
+                                               jitCompPutImm32(w.dst, label[i].typ);\r
                                                jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 4, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ /* typ */\r
                                                jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */\r
-                                               jitCompPutImm32(&w, (int)label[i].p1);\r
+                                               jitCompPutImm32(w.dst, (int)label[i].p1);\r
                                                jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 12, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ /* p1 */\r
                                                jitCompPutByte2(w.dst, 0x31, 0xc0);     /* XOR(EAX, EAX); */\r
                                                jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 16, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ /* liveSign */\r
@@ -546,7 +536,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                else {\r
                                        jitCompPutByte2(w.dst, 0xf7, 0xc0 | reg0); /* TEST(reg0,1); */\r
                                }\r
-                               jitCompPutImm32(&w, 1);\r
+                               jitCompPutImm32(w.dst, 1);\r
                                \r
                                /* JZ命令を発行 */\r
                                jitCompPutByte2(w.dst, 0x74, 0x00);     /* JZ($+2) */\r
@@ -745,7 +735,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        else {\r
                                                jitCompPutByte2(w.dst, 0x81, 0xc0 | reg0);      /* ADD(reg0, ?); */\r
                                        }\r
-                                       jitCompPutImm32(&w, j);\r
+                                       jitCompPutImm32(w.dst, j);\r
                                        goto padd1;\r
                                }\r
 #endif\r
@@ -823,7 +813,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        if (reg2 >= 0)\r
                                                jitCompA000_storeRegCacheAll(&w);\r
                                        jitCompPutByte1(w.dst, 0xb8 | reg0);    /* MOV(reg0, ?); */\r
-                                       jitCompPutImm32(&w, w.r3f);\r
+                                       jitCompPutImm32(w.dst, w.r3f);\r
                                        jitCompPutByte1(w.dst, 0x2b);\r
                                        jitCompA0001_85DispN(&w, src[3] * 4, reg0);\r
                                        if (reg0 == 0)\r
@@ -897,7 +887,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                                jitCompPutByte2(w.dst, 0x69, 0xc0 | reg0 << 3 | reg0);\r
                                                        }\r
                                                }\r
-                                               jitCompPutImm32(&w, w.r3f);\r
+                                               jitCompPutImm32(w.dst, w.r3f);\r
                                                if (reg0 == 0)\r
                                                        jitCompA0001_movRxxEax(&w, src[1]);\r
                                                break;\r
@@ -960,7 +950,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
 #if (jitCompA0001_USE_R3F_IMM32 != 0)\r
                                if (src[2] == 0x3f) {\r
                                        jitCompPutByte1(w.dst, 0xb8);   /* MOV(EAX, ?); */\r
-                                       jitCompPutImm32(&w, w.r3f);\r
+                                       jitCompPutImm32(w.dst, w.r3f);\r
                                }\r
                                else {\r
                                        jitCompA0001_movEaxRxx(&w, src[2]);\r
@@ -985,14 +975,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
 #if (jitCompA0001_USE_R3F_IMM32 != 0)\r
                                if (src[3] == 0x3f) {\r
                                        jitCompPutByte1(w.dst, 0xb8 | 1);       /* MOV(ECX, ?); */\r
-                                       jitCompPutImm32(&w, w.r3f);\r
+                                       jitCompPutImm32(w.dst, w.r3f);\r
                                }\r
                                else {\r
                                        jitCompA0001_movReg32EbpDisp(&w, IA32_REG1_ECX, src[3] * 4); /* MOV(ECX, [EBP+?]); */\r
                                }\r
                                if (src[2] == 0x3f) {\r
                                        jitCompPutByte1(w.dst, 0xb8 | 0);       /* MOV(EAX, ?); */\r
-                                       jitCompPutImm32(&w, w.r3f);\r
+                                       jitCompPutImm32(w.dst, w.r3f);\r
                                }\r
                                else {\r
                                        jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, src[2] * 4); /* MOV(EAX, [EBP+?]); */\r
@@ -1042,7 +1032,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                jitCompA0001_movReg32EbpDisp(&w, 0 /* EAX */, 256 + src[2] * 32 + 4); /* MOV(EAX, [EBP+?]); */  /* typ */\r
                                                jitCompPutByte3(w.dst, 0x83, 0xf8, 0);  /* CMP(EAX, 0); */\r
                                                jitCompPutByte2(w.dst, 0x0f, 0x85); /* JNE */\r
-                                               jitCompPutImm32(&w, errfnc - (w.dst + 4));\r
+                                               jitCompPutImm32(w.dst, errfnc - (w.dst + 4));\r
                                                /* セキュリティチェックが足りてない!(aliveとか) */\r
                                        }\r
                                        reg0 = IA32_REG0_EAX;\r
@@ -1052,7 +1042,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                jitCompPutByte1(w.dst, 0x3b);   /* CMP(reg0, [EBP+?]); */\r
                                                jitCompA0001_85DispN(&w, 256 + src[2] * 32 + 8, reg0);  /* p0 */\r
                                                jitCompPutByte2(w.dst, 0x0f, 0x85); /* JNE */\r
-                                               jitCompPutImm32(&w, errfnc - (w.dst + 4));\r
+                                               jitCompPutImm32(w.dst, errfnc - (w.dst + 4));\r
                                        }\r
                                        jitCompPutByte2(w.dst, 0xff, 0xe0);     /* JMP(EAX); */\r
                                }\r
@@ -1067,12 +1057,12 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, 256 + src[6] * 32 + i); /* MOV(EAX, [EBP+?]); */\r
                                                if (i == 4) {\r
                                                        jitCompPutByte1(w.dst, 0x0d); /* OR(EAX, ?); */\r
-                                                       jitCompPutImm32(&w, 0x80000000);\r
+                                                       jitCompPutImm32(w.dst, 0x80000000);\r
                                                }\r
                                                jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + i, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */\r
                                        }\r
                                        jitCompPutByte1(w.dst, 0xb8);   /* MOV(EAX, ?); */\r
-                                       jitCompPutImm32(&w, debugInfo1);\r
+                                       jitCompPutImm32(w.dst, debugInfo1);\r
                                        jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 28, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */\r
                                        jitCompA000_loadPRegCacheAll(&w); // 手抜き.\r
                                        cmp0reg = -1;\r
@@ -1084,14 +1074,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                jitCompA0001_movReg32EbpDisp(&w, 0 /* EAX */, 256 + src[6] * 32 + i); /* MOV(EAX, [EBP+?]); */\r
                                                if (i == 4) {\r
                                                        jitCompPutByte1(w.dst, 0x25); /* AND(EAX, ?); */\r
-                                                       jitCompPutImm32(&w, 0x7fffffff);\r
+                                                       jitCompPutImm32(w.dst, 0x7fffffff);\r
                                                }\r
                                                jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + i, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */\r
                                        }\r
                                        if (level < JITC_LV_FASTER) {\r
                                                jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, 256 + src[6] * 32 + 28); /* MOV(EAX, [EBP+?]); */\r
                                                jitCompPutByte1(w.dst, 0x3d);   /* CMP(EAX, ?); */\r
-                                               jitCompPutImm32(&w, debugInfo1);\r
+                                               jitCompPutImm32(w.dst, debugInfo1);\r
                                                jitCompPutByte2(w.dst, 0x74, 8); /* JE */\r
                                                jitCompPutByte2(w.dst, 0x31, 0xc0);     /* XOR(EAX, EAX); (2) */\r
                                                jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 0, IA32_REG0_EAX); /* MOV([EBP+?], EAX); (1+1+4) */\r
@@ -1155,7 +1145,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                if (*src <= 0x25) { jitCompPutByte2(w.dst, 0x81, 0xf8 | reg0); }\r
                                                if (*src >= 0x26) { jitCompPutByte2(w.dst, 0xf7, 0xc0 | reg0); }\r
                                        }\r
-                                       jitCompPutImm32(&w, w.r3f);\r
+                                       jitCompPutImm32(w.dst, w.r3f);\r
                                        goto cmpcc1;\r
                                }\r
 #endif\r
@@ -1188,7 +1178,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                        j = 0;\r
                                        if ((flags & JITC_PHASE1) != 0 || (((flags & JITC_PHASE1) == 0) && label[i].opt != 0))\r
                                                j = label[i].p - (w.dst + 4);\r
-                                       jitCompPutImm32(&w, j);\r
+                                       jitCompPutImm32(w.dst, j);\r
 #if (jitCompA0001_OPTIMIZE_JMP != 0)\r
                                        if (-128 - 4 <= j && j < 0) {\r
                                                j += 4;\r
@@ -1256,7 +1246,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                if (*src == 0x31) j = ((unsigned char *)&funcf5) - (w.dst + 4);\r
                                if (*src == 0x32) j = ((unsigned char *)&funcf6) - (w.dst + 4);\r
                                if (*src == 0x33) j = ((unsigned char *)&funcf7) - (w.dst + 4);\r
-                               jitCompPutImm32(&w, j);\r
+                               jitCompPutImm32(w.dst, j);\r
                                jitCompPutByte3(w.dst, 0x83, 0xc4, 0x10);       /* ADD(ESP,16); */\r
                                jitCompA000_loadRegCacheAll(&w); // 手抜き.\r
                                jitCompA000_loadPRegCacheAll(&w); // 手抜き.\r
@@ -1308,14 +1298,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                if ((flags & JITC_PHASE1) != 0 && w.err == 0) {\r
                                                        if (label[i].opt == 0) { w.err = JITC_ERR_LABELNODEF; goto err_w; }\r
                                                }\r
-                                               jitCompPutImm32(&w, (int)label[i].p);\r
-                                               jitCompPutImm32(&w, label[i].typ);\r
-                                               jitCompPutImm32(&w, (int)label[i].p);\r
-                                               jitCompPutImm32(&w, (int)label[i].p1);\r
-                                               jitCompPutImm32(&w, 0); /* liveSign */\r
-                                               jitCompPutImm32(&w, 2320); /* pls */\r
-                                               jitCompPutImm32(&w, 0);\r
-                                               jitCompPutImm32(&w, 0);\r
+                                               jitCompPutImm32(w.dst, (int)label[i].p);\r
+                                               jitCompPutImm32(w.dst, label[i].typ);\r
+                                               jitCompPutImm32(w.dst, (int)label[i].p);\r
+                                               jitCompPutImm32(w.dst, (int)label[i].p1);\r
+                                               jitCompPutImm32(w.dst, 0); /* liveSign */\r
+                                               jitCompPutImm32(w.dst, 2320); /* pls */\r
+                                               jitCompPutImm32(w.dst, 0);\r
+                                               jitCompPutImm32(w.dst, 0);\r
                                                j--;\r
                                        }\r
                                }\r
@@ -1336,7 +1326,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                jitCompPutByte1(w.dst, 0x55);   /* PUSH(EBP); */\r
                                jitCompPutByte1(w.dst, 0xe8);\r
                                j = ((unsigned char *)&func3c) - (w.dst + 4);\r
-                               jitCompPutImm32(&w, j);\r
+                               jitCompPutImm32(w.dst, j);\r
                                jitCompPutByte3(w.dst, 0x83, 0xc4, 0x20);       /* ADD(ESP,32); */\r
                                jitCompA000_loadRegCacheAll(&w); // 手抜き.\r
                                jitCompA000_loadPRegCacheAll(&w); // 手抜き.\r
@@ -1356,7 +1346,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                jitCompPutByte1(w.dst, 0x55);   /* PUSH(EBP); */\r
                                jitCompPutByte1(w.dst, 0xe8);\r
                                j = ((unsigned char *)&func3d) - (w.dst + 4);\r
-                               jitCompPutImm32(&w, j);\r
+                               jitCompPutImm32(w.dst, j);\r
                                jitCompPutByte3(w.dst, 0x83, 0xc4, 0x20);       /* ADD(ESP,32); */\r
                                jitCompA000_loadRegCacheAll(&w); // 手抜き.\r
                                jitCompA000_loadPRegCacheAll(&w); // 手抜き.\r
@@ -1367,14 +1357,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                if (src[1] == 0x01 && src[2] == 0x00) { // DBGINFO1\r
                                        if (level <= JITC_LV_SLOWER) {\r
                                                jitCompPutByte1(w.dst, 0xb8);   /* MOV(EAX, ?); */\r
-                                               jitCompPutImm32(&w, debugInfo1);\r
+                                               jitCompPutImm32(w.dst, debugInfo1);\r
                                                jitCompA0001_movEbpDispReg32(&w, 2304 + 4, IA32_REG0_EAX); /* MOV(debugInfo1, EAX); */\r
                                        }\r
                                }\r
                                if (src[1] == 0x01 && src[2] == 0x03) { // DBGINFO1CLR\r
                                        if (level <= JITC_LV_SLOWER) {\r
                                                jitCompPutByte1(w.dst, 0xb8);   /* MOV(EAX, ?); */\r
-                                               jitCompPutImm32(&w, -1);\r
+                                               jitCompPutImm32(w.dst, -1);\r
                                                jitCompA0001_movEbpDispReg32(&w, 2304 + 4, IA32_REG0_EAX); /* MOV(debugInfo1, EAX); */\r
                                        }\r
                                }\r
@@ -1384,7 +1374,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                                                //      jitCompPutByte1(w.dst, 0xbf);   /* MOV(EDI, ?); */\r
                                                //      jitCompPutImm32(&w, debugInfo0);\r
                                                jitCompPutByte1(w.dst, 0xb8);   /* MOV(EAX, ?); */\r
-                                               jitCompPutImm32(&w, debugInfo0);\r
+                                               jitCompPutImm32(w.dst, debugInfo0);\r
                                                jitCompA0001_movEbpDispReg32(&w, 2304 + 0, IA32_REG0_EAX); /* MOV(debugInfo0, EAX); */\r
                                        }\r
                                }\r
@@ -1458,18 +1448,18 @@ unsigned char *jitCompCallFunc(unsigned char *dst, void *func)
        w.dst = dst;\r
        jitCompA000_storeRegCacheAll(&w);\r
        jitCompA000_storePRegCacheAll(&w);\r
-       jitCompPutByte1(w.dst, 0x60);   /* PUSHAD(); */\r
-       jitCompPutByte1(w.dst, 0x50);   /* PUSH(EAX); */        /* for 16byte-align(win32では不要なのだけど、MacOSには必要らしい) */\r
-       jitCompPutByte1(w.dst, 0x55);   /* PUSH(EBP); */\r
+       jitCompPutOp_PUSHAD(w.dst);\r
+       jitCompPutOp_PUSH_GReg(w.dst, IA32_REG0_EAX);   /* for 16Byte-align(Mac OSX) */\r
+       jitCompPutOp_PUSH_GReg(w.dst, IA32_REG5_EBP);   /* PUSH(EBP); */\r
        jitCompPutByte1(w.dst, 0xe8);   /* CALL(func); */\r
        int j = ((unsigned char *)func) - (w.dst + 4);\r
        \r
        //この関数の中では結局w->dstしか参照していない\r
-       jitCompPutImm32(&w, j);\r
+       jitCompPutImm32(w.dst, j);\r
        \r
-       jitCompPutByte1(w.dst, 0x58);   /* POP(EAX); */         /* (win32では不要なのだけど、MacOSには必要らしい) */\r
-       jitCompPutByte1(w.dst, 0x58);   /* POP(EAX); */\r
-       jitCompPutByte1(w.dst, 0x61);   /* POPAD(); */\r
+       jitCompPutOp_POP_GReg(w.dst, IA32_REG0_EAX);            /* for 16Byte-align (Mac OSX) */\r
+       jitCompPutOp_POP_GReg(w.dst, IA32_REG0_EAX);\r
+       jitCompPutOp_POPAD(w.dst);\r
        jitCompA000_loadRegCacheAll(&w);\r
        jitCompA000_loadPRegCacheAll(&w);\r
        jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, 256 + 0x30 * 32 + 0); /* MOV(EAX, [EBP+?]); */\r