X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=jitc.c;h=abefdcbdc031eb99709e2c6cccaad33b3d3e3fb4;hb=c7fbdf64e053179a13205f7c607ae113a83648eb;hp=ca621d5d93bac022e932cd536e3583d4cf0eb959;hpb=8a7ecbf992367b1f4a309e585a638dee7c44a17c;p=heavyosecpu%2FHeavyOSECPU.git diff --git a/jitc.c b/jitc.c index ca621d5..abefdcb 100644 --- a/jitc.c +++ b/jitc.c @@ -1,69 +1,82 @@ -#include "osecpu.h" -#include "jitc.h" - -// -// JITC common functions (architecture not dependent) -// - -void errorHandler(HOSECPU_RuntimeEnvironment *r) -{ - puts("security error! abort..."); - printf("debugInfo0=%d, debugInfo1=%d\n", r->debugInfo0, r->debugInfo1); -#if (USE_DEBUGGER != 0) - dbgrMain(r); -#endif - exit(1); -} - -int jitCompCmdLen(const unsigned char *src) -{ - //BCode命令長を取得する - int i = 1; - - if (0x01 <= *src && *src < 0x04){ - // LB, LIMM, PLIMM - i = 6; - } else if (*src == 0x04){ - // CND - i = 2; - } else if (0x08 <= *src && *src < 0x0d){ - // LMEM, SMEM, ??, ??, ?? - i = 8 + src[7] * 4; - } else if (0x0e <= *src && *src < 0x10){ - // PADD, PDIF - i = 8; - } else if (0x10 <= *src && *src < 0x1c){ - // CP/OR, XOR, AND, ADD, SUB, MUL, SHL, SAR, DIV, MOD, - i = 4; - } else if (0x1c <= *src && *src < 0x1f){ - // ??, ??, PCP - i = 3; - } else if (*src == 0x1f){ - // ?? - i = 11; - } else if(0x20 <= *src && *src < 0x2e){ - // CMPE, CMPNE, CMPL, CMPGE, CMPLE, CMPG, TSTZ, TSTNZ, - // PCMPE, PCMPNE, PCMPL, PCMPGE, PCMPLE, PCMPG, - i = 4; - } else if (*src == 0x2f){ - // ?? - i = 4 + src[1]; - } else if (0x30 <= *src && *src < 0x34){ - // ??, ??, MALLOC, ?? - i = 4; - } else if (0x3c <= *src && *src < 0x3e){ - // ??, ?? - i = 7; - } else if (*src == 0xfe){ - // REMARK - i = 2 + src[1]; - } - - return i; -} - - - - - - +#include "osecpu.h" +#include "jitc.h" + +// +// JITC common functions (architecture not dependent) +// + +void errorHandler(HOSECPU_RuntimeEnvironment *r) +{ + puts("security error! abort..."); + printf("debugInfo0=%d, debugInfo1=%d\n", r->debugInfo0, r->debugInfo1); +#if (USE_DEBUGGER != 0) + dbgrMain(r); +#endif + exit(1); +} + +int jitCompCmdLen(const unsigned char *src) +{ + //BCode命令長を取得する + int i = 1; + + if (0x01 <= *src && *src < 0x04){ + // LB, LIMM, PLIMM + i = 6; + } else if (*src == 0x04){ + // CND + i = 2; + } else if (0x08 <= *src && *src < 0x0d){ + // LMEM, SMEM, ??, ??, ?? + i = 8 + src[7] * 4; + } else if (0x0e <= *src && *src < 0x10){ + // PADD, PDIF + i = 8; + } else if (0x10 <= *src && *src < 0x1c){ + // CP/OR, XOR, AND, ADD, SUB, MUL, SHL, SAR, DIV, MOD, + i = 4; + } else if (0x1c <= *src && *src < 0x1f){ + // ??, ??, PCP + i = 3; + } else if (*src == 0x1f){ + // ?? + i = 11; + } else if(0x20 <= *src && *src < 0x2e){ + // CMPE, CMPNE, CMPL, CMPGE, CMPLE, CMPG, TSTZ, TSTNZ, + // PCMPE, PCMPNE, PCMPL, PCMPGE, PCMPLE, PCMPG, + i = 4; + } else if (*src == 0x2f){ + // ?? + i = 4 + src[1]; + } else if (0x30 <= *src && *src < 0x34){ + // ??, ??, MALLOC, ?? + i = 4; + } else if (0x3c <= *src && *src < 0x3e){ + // ??, ?? + i = 7; + } else if (*src == 0xfe){ + // REMARK + i = 2 + src[1]; + } + + return i; +} + +void PRegCopy(HOSECPU_PointerRegisterEntry *dst, HOSECPU_PointerRegisterEntry *src) +{ + // なんか直接代入するとMacではアライメントエラーで落ちるのです... + // *dst = *src; + + dst->p = src->p; + dst->typ = src->typ; + dst->p0 = src->p0; + dst->p1 = src->p1; + dst->liveSign = src->liveSign; + dst->pls = src->pls; + dst->flags = src->flags; + dst->dummy = src->dummy; +} + + + +