|
|
| version 1.4, 2004/02/13 14:52:35 | version 1.5, 2004/02/19 03:04:01 |
|---|---|
| Line 409 disasm_codefetch_1(disasm_context_t *ctx | Line 409 disasm_codefetch_1(disasm_context_t *ctx |
| val = cpu_memoryread(ctx->val); | val = cpu_memoryread(ctx->val); |
| ctx->val = val; | ctx->val = val; |
| ctx->opbyte[ctx->nopbyte++] = ctx->val; | ctx->opbyte[ctx->nopbyte++] = (BYTE)ctx->val; |
| ctx->eip++; | ctx->eip++; |
| return 0; | return 0; |
| Line 424 disasm_codefetch_2(disasm_context_t *ctx | Line 424 disasm_codefetch_2(disasm_context_t *ctx |
| rv = disasm_codefetch_1(ctx); | rv = disasm_codefetch_1(ctx); |
| if (rv) | if (rv) |
| return rv; | return rv; |
| val = ctx->val & 0xff; | val = (WORD)(ctx->val & 0xff); |
| rv = disasm_codefetch_1(ctx); | rv = disasm_codefetch_1(ctx); |
| if (rv) | if (rv) |
| return rv; | return rv; |
| Line 464 disasm_codefetch_4(disasm_context_t *ctx | Line 464 disasm_codefetch_4(disasm_context_t *ctx |
| /* | /* |
| * get effective address. | * get effective address. |
| */ | */ |
| static int | static int |
| ea16(disasm_context_t *ctx, char *buf, size_t size) | ea16(disasm_context_t *ctx, char *buf, size_t size) |
| { | { |
| Line 471 ea16(disasm_context_t *ctx, char *buf, s | Line 472 ea16(disasm_context_t *ctx, char *buf, s |
| "bx + si", "bx + di", "bp + si", "bp + di", | "bx + si", "bx + di", "bp + si", "bp + di", |
| "si", "di", "bp", "bx" | "si", "di", "bp", "bx" |
| }; | }; |
| char tmp[32]; | // char tmp[32]; |
| DWORD mod, rm; | DWORD mod, rm; |
| DWORD val; | DWORD val; |
| int rv; | int rv; |
| Line 486 ea16(disasm_context_t *ctx, char *buf, s | Line 487 ea16(disasm_context_t *ctx, char *buf, s |
| if (rv) | if (rv) |
| return rv; | return rv; |
| snprintf(buf, size, "[0x%04x]", ctx->val); | snprintf(buf, size, "[0x%04lx]", ctx->val); |
| } else { | } else { |
| snprintf(buf, size, "[%s]", ea16_str[rm]); | snprintf(buf, size, "[%s]", ea16_str[rm]); |
| } | } |
| Line 509 ea16(disasm_context_t *ctx, char *buf, s | Line 510 ea16(disasm_context_t *ctx, char *buf, s |
| val = ctx->val; | val = ctx->val; |
| } | } |
| snprintf(buf, size, "[%s + 0x%04x]", ea16_str[rm], val); | snprintf(buf, size, "[%s + 0x%04lx]", ea16_str[rm], val); |
| } | } |
| return 0; | return 0; |
| Line 603 ea32(disasm_context_t *ctx, char *buf, s | Line 604 ea32(disasm_context_t *ctx, char *buf, s |
| milstr_ncat(buf, " + ", size); | milstr_ncat(buf, " + ", size); |
| } | } |
| if (count[i] > 1) { | if (count[i] > 1) { |
| snprintf(tmp, size, "%s * %d", | snprintf(tmp, size, "%s * %ld", |
| reg32_str[i], count[i]); | reg32_str[i], count[i]); |
| } else { | } else { |
| milstr_ncpy(tmp, reg32_str[i], sizeof(tmp)); | milstr_ncpy(tmp, reg32_str[i], sizeof(tmp)); |
| Line 616 ea32(disasm_context_t *ctx, char *buf, s | Line 617 ea32(disasm_context_t *ctx, char *buf, s |
| if (n > 0) { | if (n > 0) { |
| milstr_ncat(buf, " + ", size); | milstr_ncat(buf, " + ", size); |
| } | } |
| snprintf(tmp, sizeof(tmp), "0x%08x", count[8]); | snprintf(tmp, sizeof(tmp), "0x%08lx", count[8]); |
| milstr_ncat(buf, tmp, size); | milstr_ncat(buf, tmp, size); |
| } | } |
| milstr_ncat(buf, "]", size); | milstr_ncat(buf, "]", size); |
| Line 646 ea(disasm_context_t *ctx) | Line 647 ea(disasm_context_t *ctx) |
| } else { | } else { |
| milstr_ncat(ctx->next, sep[1], ctx->remain); | milstr_ncat(ctx->next, sep[1], ctx->remain); |
| } | } |
| len += strlen(ctx->next); | len = strlen(ctx->next); |
| len = (len < ctx->remain) ? len : ctx->remain; | len = (len < ctx->remain) ? len : ctx->remain; |
| ctx->next += len; | ctx->next += len; |
| ctx->remain -= len; | ctx->remain -= len; |
| Line 672 static int | Line 673 static int |
| op(disasm_context_t *ctx) | op(disasm_context_t *ctx) |
| { | { |
| const char *opcode; | const char *opcode; |
| DWORD type; | // DWORD type; |
| BYTE op[3]; | BYTE op[3]; |
| int prefix; | int prefix; |
| int len; | int len; |
| Line 684 op(disasm_context_t *ctx) | Line 685 op(disasm_context_t *ctx) |
| if (rv) | if (rv) |
| return rv; | return rv; |
| op[0] = ctx->val & 0xff; | op[0] = (BYTE)(ctx->val & 0xff); |
| if (insttable_info[op[0]] & INST_PREFIX) { | if (insttable_info[op[0]] & INST_PREFIX) { |
| if (ctx->prefix == 0) | if (ctx->prefix == 0) |
| ctx->prefix = ctx->next; | ctx->prefix = ctx->next; |
| Line 728 op(disasm_context_t *ctx) | Line 729 op(disasm_context_t *ctx) |
| } | } |
| } | } |
| len = strlen(ctx->next); | len = strlen(ctx->next); |
| len = (len < ctx->remain) ? len : ctx->remain; | len = (len < (int)ctx->remain) ? len : ctx->remain; |
| ctx->next += len; | ctx->next += len; |
| ctx->remain -= len; | ctx->remain -= len; |
| } | } |
| Line 740 op(disasm_context_t *ctx) | Line 741 op(disasm_context_t *ctx) |
| if (rv) | if (rv) |
| return rv; | return rv; |
| op[1] = ctx->val & 0xff; | op[1] = (BYTE)(ctx->val & 0xff); |
| ctx->opcode[1] = op[1]; | ctx->opcode[1] = op[1]; |
| switch (op[0]) { | switch (op[0]) { |
| Line 751 op(disasm_context_t *ctx) | Line 752 op(disasm_context_t *ctx) |
| if (rv) | if (rv) |
| return rv; | return rv; |
| op[2] = ctx->val & 0xff; | op[2] = (BYTE)(ctx->val & 0xff); |
| ctx->opcode[2] = op[2]; | ctx->opcode[2] = op[2]; |
| switch (op[1]) { | switch (op[1]) { |