void disassembler::decode_modrm(x86_insn *insn) { insn->modrm = fetch_byte(); BX_DECODE_MODRM(insn->modrm, insn->mod, insn->nnn, insn->rm); // MOVs with CRx and DRx always use register ops and ignore the mod field. if ((insn->b1 & ~3) == 0x120) insn->mod = 3; if (insn->mod == 3) { /* mod, reg, reg */ return; } /* 16 bit addressing modes. */ switch (insn->mod) { case 0: resolve_modrm = &disassembler::resolve16_mod0; if(insn->rm == 6) insn->displacement.displ16 = fetch_word(); break; case 1: /* reg, 8-bit displacement, sign extend */ resolve_modrm = &disassembler::resolve16_mod1or2; insn->displacement.displ16 = (int8) fetch_byte(); break; case 2: resolve_modrm = &disassembler::resolve16_mod1or2; insn->displacement.displ16 = fetch_word(); break; } /* switch (mod) ... */ }
void _jmpInd(void) { word iaddr; word eaddr; iaddr = fetch_word((word)(cpu.pc + 1)); eaddr = fetch_word(iaddr); cpu.pc = eaddr; }
int do_command(void) { const char *cmd; int i; char lbuf[10]; cmd = word + 1; /* Comments don't need the space */ if (strncmp(cmd, "\\\"", 2) == 0) cmd = "\\\""; for (i = 0; cmd_list[i].cmd[0]; i++) { if (strcmp(cmd_list[i].cmd, cmd) == 0) break; } if (cmd_list[i].cmd[0] == 0) { if (verbose) { strncpy(lbuf, cmd, 3); lbuf[3] = 0; line_break(); i = left_indent; left_indent = 0; strcpy(word, "**** Unknown formatter command: ."); strcat(word, lbuf); print_word(word); line_break(); left_indent = i; } i = 0; /* Treat as comment */ } switch (cmd_list[i].class) { case 1: /* Parametered commands */ return do_argvcmd(cmd_list[i].id); case 2: /* Font changers */ return do_fontwords(cmd_list[i].id / 10, cmd_list[i].id % 10, 0); case 3: /* .so */ fetch_word(); strcat(man_file, word); close_page(); if (find_page(man_file, (char *) 0) < 0) { fprintf(stderr, "Cannot open .so file %s\n", word); return -1; } ungetc('\r', ifd); break; default: do_skipeol(); if (cmd_list[i].id) return do_noargs(cmd_list[i].id); } return 0; }
void _styAbsl(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); store_byte(addr, cpu.y); cpu.pc += 3; }
void _jsr(void) { word addr; push(hibyte(cpu.pc + 3)); push(lobyte(cpu.pc + 3)); addr = fetch_word((word)(cpu.pc + 1)); cpu.pc = addr; }
void _staAby(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); addr += cpu.y; store_byte(addr, cpu.a); cpu.pc += 3; }
void _rorAbx(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); ROR((word)(addr + cpu.x)); cpu.pc += 3; }
void _aslAbsl(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); ASL(addr); cpu.pc += 3; }
void _oraAbsl(void) { word addr; word res; addr = fetch_word((word)(cpu.pc + 1)); res = cpu.a |= fetch_byte(addr); set_nz(res); cpu.pc += 3; }
void _lsrAbx(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); LSR((word)(addr + cpu.x)); cpu.pc += 3; }
void _lsrAbsl(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); LSR(addr); cpu.pc += 3; }
int process_dri(void) { if (iceenv.cur_segment_len != 4) return ERR_INVALID_SEGMENT_SIZE; iceenv.restart_interval = fetch_word(); iceenv.rstcount = iceenv.restart_interval; return ERR_OK; }
void _brk(void) { push(hibyte(cpu.pc + sizeof(word))); push(lobyte(cpu.pc + sizeof(word))); push(cpu.sr); set_brk_flag(); set_int_disable_flag(); cpu.pc = fetch_word(IRQ_VECTOR); }
void _aslAbx(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); ASL((word)(addr + cpu.x)); cpu.pc += 3; }
void _bitAbsl(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); BIT(addr); cpu.pc += 3; }
void _rorAbsl(void) { word addr; addr = fetch_word((word)(cpu.pc + 1)); ROR(addr); cpu.pc += 3; }
/* * add with carry, absolute mode */ void _adcAbsl(void) { word addr; byte value; addr = fetch_word((word)(cpu.pc + 1)); value = fetch_byte(addr); ADC(value); cpu.pc += 3; }
void _ldaAby(void) { word addr; word res; addr = fetch_word((word)(cpu.pc + 1)); addr += cpu.y; res = cpu.a = fetch_byte(addr); set_nz(res); cpu.pc += 3; }
void _staIdy(void) { byte zaddr; word addr; zaddr = fetch_byte((word)(cpu.pc + 1)); addr = fetch_word(zaddr) + cpu.y; store_byte(addr, cpu.a); cpu.pc += 2; }
void _ldyAbx(void) { word addr; word res; addr = fetch_word((word)(cpu.pc + 1)); addr += cpu.x; res = cpu.y = fetch_byte(addr); set_nz(res); cpu.pc += 3; }
void _sbcAby(void) { word addr; byte value; addr = fetch_word((word)(cpu.pc + 1)); value = fetch_byte((word)(addr + cpu.y)); SBC(value); cpu.pc += 3; }
void _staIdx(void) { byte zaddr; word addr; zaddr = fetch_byte((word)(cpu.pc + 1)); zaddr += cpu.x; addr = fetch_word(zaddr); store_byte(addr, cpu.a); cpu.pc += 2; }
void disassembler::IwIb(const x86_insn *insn) { Bit16u iw = fetch_word(); Bit8u ib = fetch_byte(); if (intel_mode) { dis_sprintf("0x%04x, 0x%02x", iw, ib); } else { dis_sprintf("$0x%02x, $0x%04x", ib, iw); } }
/* * add with carry absolute, y mode */ void _adcAby(void) { word addr; byte value; addr = fetch_word((word)(cpu.pc + 1)); addr += cpu.y; value = fetch_byte(addr); ADC(addr); cpu.pc += 3; }
void _ldaIdy(void) { byte zaddr; word addr; word res; zaddr = fetch_byte((word)(cpu.pc + 1)); addr = fetch_word(zaddr) + cpu.y; res = cpu.a = fetch_byte(addr); set_nz(res); cpu.pc += 2; }
void _oraIdx(void) { byte zaddr; word addr; word res; zaddr = fetch_byte((word)(cpu.pc + 1)); zaddr += cpu.x; addr = fetch_word(zaddr); res = cpu.a |= fetch_byte(addr); set_nz(res); cpu.pc += 2; }
/* * add with carry indirect, y mode */ void _adcIdy(void) { byte zaddr, value; word addr; zaddr = fetch_byte((word)(cpu.pc + 1)); addr = fetch_word(zaddr) + cpu.y; value = fetch_byte(addr); ADC(value); cpu.pc += 2; }
void _cpyAbsl(void) { word addr; word res; addr = fetch_word((word)(cpu.pc + 1)); res = cpu.y - fetch_byte(addr); set_carry(res < 0x100); set_nz(res); cpu.pc += 3; }
void _sbcIdx(void) { byte zaddr, value; word addr; zaddr = fetch_byte((word)(cpu.pc + 1)); zaddr += cpu.x; addr = fetch_word(zaddr); value = fetch_byte(addr); SBC(value); cpu.pc += 2; }
void _decAbsl(void) { word addr; word res; addr = fetch_word((word)(cpu.pc + 1)); res = fetch_byte(addr); res = (res - 1) & 0xFF; store_byte(addr, (byte)res); set_nz(res); cpu.pc += 3; }