offs_t activecpu_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { unsigned result; VERIFY_ACTIVECPU(activecpu_dasm); /* check for disassembler override */ if (cpu_dasm_override[activecpu]) { result = (*cpu_dasm_override[activecpu])(buffer, pc, oprom, opram); if (result != 0) return result; } if (cpu[activecpu].intf.disassemble != NULL) { result = (*cpu[activecpu].intf.disassemble)(buffer, pc, oprom, opram); } else { /* if no disassembler present, dump vanilla bytes */ switch (activecpu_min_instruction_bytes()) { case 1: default: sprintf(buffer, "$%02X", (unsigned) *((UINT8 *) oprom)); result = 1; break; case 2: sprintf(buffer, "$%04X", (unsigned) *((UINT16 *) oprom)); result = 2; break; case 4: sprintf(buffer, "$%08X", (unsigned) *((UINT32 *) oprom)); result = 4; break; } } /* make sure we get good results */ assert((result & DASMFLAG_LENGTHMASK) != 0); #ifdef MAME_DEBUG { int shift = activecpu_addrbus_shift(ADDRESS_SPACE_PROGRAM); int bytes = (shift < 0) ? ((result & DASMFLAG_LENGTHMASK) << -shift) : ((result & DASMFLAG_LENGTHMASK) >> shift); assert(bytes >= activecpu_min_instruction_bytes()); assert(bytes <= activecpu_max_instruction_bytes()); (void) bytes; /* appease compiler */ } #endif return result; }
unsigned activecpu_dasm_new(char *buffer, offs_t pc, UINT8 *oprom, UINT8 *opram, int bytes) { unsigned result; VERIFY_ACTIVECPU(activecpu_dasm_new); if (cpu[activecpu].intf.disassemble_new) { result = (*cpu[activecpu].intf.disassemble_new)(buffer, pc, oprom, opram, bytes); } else { /* if no disassembler present, dump vanilla bytes */ switch(activecpu_min_instruction_bytes()) { case 1: default: sprintf(buffer, "$%02X", (unsigned) *((UINT8 *) oprom)); result = 1; break; case 2: sprintf(buffer, "$%04X", (unsigned) *((UINT16 *) oprom)); result = 2; break; case 4: sprintf(buffer, "$%08X", (unsigned) *((UINT32 *) oprom)); result = 4; break; } } return result; }