From a26431ccbcf6d286bd06f75e469f269c88bf4fc3 Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Fri, 24 Nov 2023 20:20:22 +0100 Subject: [PATCH] revert experimental disassembler stuff --- ui/ui_dasm.h | 10 +-- ui/ui_dbg.h | 4 +- util/disassembler.h | 157 --------------------------------- util/z80dasm.h | 206 +++++++++++++++++++++++--------------------- 4 files changed, 116 insertions(+), 261 deletions(-) delete mode 100644 util/disassembler.h diff --git a/ui/ui_dasm.h b/ui/ui_dasm.h index f4573b5b..762c94c9 100644 --- a/ui/ui_dasm.h +++ b/ui/ui_dasm.h @@ -8,7 +8,7 @@ ~~~C #define CHIPS_UI_IMPL ~~~ - before you include this file in *one* C++ file to create the + before you include this file in *one* C++ file to create the implementation. Select the supported CPUs with the following macros (at least @@ -18,7 +18,7 @@ UI_DASM_USE_M6502 Optionally provide the following macros with your own implementation - + ~~~C CHIPS_ASSERT(c) ~~~ @@ -51,7 +51,7 @@ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source - distribution. + distribution. #*/ #include #include @@ -202,7 +202,7 @@ static void _ui_dasm_disasm(ui_dasm_t* win) { m6502dasm_op(win->cur_addr, _ui_dasm_in_cb, _ui_dasm_out_cb, win); } #elif defined(UI_DASM_USE_Z80) - z80dasm_op(win->cur_addr, _ui_dasm_in_cb, win, _ui_dasm_out_cb, win); + z80dasm_op(win->cur_addr, _ui_dasm_in_cb, _ui_dasm_out_cb, win); #else m6502dasm_op(win->cur_addr, _ui_dasm_in_cb, _ui_dasm_out_cb, win); #endif @@ -275,7 +275,7 @@ static bool _ui_dasm_jumptarget(ui_dasm_t* win, uint16_t pc, uint16_t* out_addr) else if (win->bin_pos == 2) { switch (win->bin_buf[0]) { /* relative branch */ - case 0x10: case 0x30: case 0x50: case 0x70: + case 0x10: case 0x30: case 0x50: case 0x70: case 0x90: case 0xB0: case 0xD0: case 0xF0: *out_addr = pc + (int8_t)win->bin_buf[1]; return true; diff --git a/ui/ui_dbg.h b/ui/ui_dbg.h index 810034e6..e3567b40 100644 --- a/ui/ui_dbg.h +++ b/ui/ui_dbg.h @@ -391,7 +391,7 @@ static inline uint16_t _ui_dbg_disasm(ui_dbg_t* win, uint16_t pc) { win->dasm.str_pos = 0; win->dasm.bin_pos = 0; #if defined(UI_DBG_USE_Z80) - z80dasm_op(pc, _ui_dbg_dasm_in_cb, win, _ui_dbg_dasm_out_cb, win); + z80dasm_op(pc, _ui_dbg_dasm_in_cb, _ui_dbg_dasm_out_cb, win); #elif defined(UI_DBG_USE_M6502) m6502dasm_op(pc, _ui_dbg_dasm_in_cb, _ui_dbg_dasm_out_cb, win); #endif @@ -404,7 +404,7 @@ static inline uint16_t _ui_dbg_disasm_len(ui_dbg_t* win, uint16_t pc) { win->dasm.str_pos = 0; win->dasm.bin_pos = 0; #if defined(UI_DBG_USE_Z80) - uint16_t next_pc = z80dasm_op(pc, _ui_dbg_dasm_in_cb, win, 0, 0); + uint16_t next_pc = z80dasm_op(pc, _ui_dbg_dasm_in_cb, 0, win); #elif defined(UI_DBG_USE_M6502) uint16_t next_pc = m6502dasm_op(pc, _ui_dbg_dasm_in_cb, 0, win); #endif diff --git a/util/disassembler.h b/util/disassembler.h deleted file mode 100644 index b0c8a678..00000000 --- a/util/disassembler.h +++ /dev/null @@ -1,157 +0,0 @@ -#pragma once -/*# - # disassembler.h - - A generic disassembler convenience wrapper around the lower level - m6502dasm.h and z80dasm.h headers. - - Do this: - ~~~C - #define CHIPS_UTIL_IMPL - ~~~ - before you include this file in *one* C or C++ file to create the - implementation. - - Optionally provide the following macros with your own implementation - - Select the supported CPUs with the following macros (define one - or the other, but not both): - - UI_DBG_USE_Z80 - UI_DBG_USE_M6502 - - ~~~C - CHIPS_ASSERT(c) - ~~~ - your own assert macro (default: assert(c)) - - Include one of the following headers (depending on the selected cpu) before - including the disassembler.h implementation: - - m6502dasm.h - z80dasm.h - - ## Usage - - TODO - - ## zlib/libpng license - - Copyright (c) 2023 Andre Weissflog - This software is provided 'as-is', without any express or implied warranty. - In no event will the authors be held liable for any damages arising from the - use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software in a - product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. -*/ -#include -#include -#include - -#if !defined(UI_DBG_USE_Z80) && !defined(UI_DBG_USE_M6502) -#error "please define UI_DBG_USE_Z80 or UI_DBG_USE_M6502" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// callback for checking if an address is known to be the start of an instruction -typedef bool (*dasm_known_op_t)(uint16_t addr, void* user_data); -// callback for reading a byte at address -typedef uint8_t (*dasm_read_byte_t)(uint16_t addr, void* user_data); -// a (computer-system-specific) pattern matcher callback for detecting and skipping trailing inline data -typedef uint16_t (*dasm_next_pc_t)(uint16_t op_addr, uint16_t op_length, dasm_read_byte_t read_fn, void* user_data); - -#define DASM_LINE_TYPE_START (0) // first input only: starts disassembling a new instruction -#define DASM_LINE_TYPE_INSTRUCTION (1) // very likely an instruction -#define DASM_LINE_TYPE_INLINE_DATA (2) // very likely data inlined into code -#define DASM_LINE_TYPE_UNKNOWN (3) // maybe code, maybe data - -// a disassembled 'line' -#define DASM_LINE_MAX_BYTES (8) -#define DASM_LINE_MAX_CHARS (64) -typedef struct dasm_line_t { - uint16_t type; // DASM_LINE_TYPE_xxx - uint16_t addr; - uint16_t next_pc; - uint8_t num_bytes; - uint8_t num_chars; - uint8_t bytes[DASM_LINE_MAX_BYTES]; - uint8_t chars[DASM_LINE_MAX_CHARS]; -} dasm_line_t; - -// dasm state -typedef struct dasm_funcs_t { - dasm_known_op_t knownop_fn; - dasm_read_byte_t readbyte_fn; - dasm_next_pc_t nextpc_fn; - void* userdata; -} dasm_funcs_t; - -// call first with a inout_line { .type=START, .addr=start_addr }, and then with the last output line until result == true -bool dasm_disasm(uint16_t pc, dasm_line_t* inout_line); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -/*-- IMPLEMENTATION ----------------------------------------------------------*/ -#ifdef CHIPS_UI_IMPL -#include -#ifndef CHIPS_ASSERT - #include - #define CHIPS_ASSERT(c) assert(c) -#endif - -bool dasm_disasm(dasm_funcs_t* funcs, dasm_line_t* inout_line) { - CHIPS_ASSERT(funcs); - CHIPS_ASSERT(func->knownop_fn); - CHIPS_ASSERT(func->readbyte_fn); - CHIPS_ASSERT(func->nextpc_fn); - CHIPS_ASSERT(inout_line); - dasm_line_t* l = inout_line; - l->num_bytes = 0; - l->num_chars = 0; - l->chars = 0; - if (l->type == DASM_LINE_TYPE_START) { - if (funcs->knownop_fn(l->addr, funcs->userdata)) { - // we're starting at a known instruction - l->type = DASM_LINE_TYPE_INSTRUCTION; - // FIXME: - // - disassemble instruction - // - call nextpc to check for inline bytes: - // - yes: return false, to gather inline bytes in next call, set nextpc! - // - no: just return true - } else { - // not a known op, return a "line" of unknown bytes - l->type = DASM_LINE_TYPE_UNKNOWN; - // read up to max bytes or a known instruction start and return - static const char* hex_digits = "0123456789ABCDEF"; - while (!funcs->knownop_fn(l->addr + l->num_bytes, funcs->userdata) && (l->num_bytes < DASM_LINE_MAX_BYTES)) { - l->bytes[l->num_bytes++] = funcs->readbyte_fn(l->addr + l->num_bytes, funcs->userdata); - } - return true; - } - } else { - // gather the next chunk of inline bytes - CHIPS_ASSERT((l->type == DASM_LINE_TYPE_INSTRUCTION) || (l->type == DASM_LINE_TYPE_INLINE_DATA)); - l->type = DASM_LINE_TYPE_INLINE_DATA; - // NOTE: addr may wrap around - while ((l->addr != l->next_pc) && (l->num_bytes < DASM_LINE_MAX_BYTES)) { - l->bytes[l->num_bytes++] = funcs->readbyte_fn(l->addr + l->num_bytes, funcs->userdata); - } - // if more inline data follows, return false - return l->addr != l->next_pc; - } -} -#endif \ No newline at end of file diff --git a/util/z80dasm.h b/util/z80dasm.h index 4fc36ec4..604d5d73 100644 --- a/util/z80dasm.h +++ b/util/z80dasm.h @@ -8,11 +8,11 @@ ~~~C #define CHIPS_UTIL_IMPL ~~~ - before you include this file in *one* C or C++ file to create the + before you include this file in *one* C or C++ file to create the implementation. Optionally provide the following macros with your own implementation - + ~~~C CHIPS_ASSERT(c) ~~~ @@ -24,17 +24,16 @@ and produces a stream of ASCII characters for exactly one instruction: ~~~C - uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_userdata, z80dasm_out_t out_fn, void* out_userdata); + uint16_t z80dasm_op(uint16_t pc, z80dasm_input_t in_cb, z80dasm_output_t out_cb, void* user_data) ~~~ - pc - the current 16-bit program counter, this is used to compute + pc - the current 16-bit program counter, this is used to compute absolute target addresses for relative jumps - in_fn - this function is called when the disassembler needs the next - instruction byte: uint8_t in_fn(void* userdata) - in_userdata - a user-provided context pointer for the in_fn callback - out_fn - (optional) this function is called when the disassembler produces a single - ASCII character: void out_fn(char c, void* userdata) - out_userdata - a user-provided context pointer for the out_fn callback + in_cb - this function is called when the disassembler needs the next + instruction byte: uint8_t in_cb(void* user_data) + out_cb - (optional) this function is called when the disassembler produces a single + ASCII character: void out_cb(char c, void* user_data) + user_data - a user-provided context pointer for the callbacks z80dasm_op() returns the new program counter (pc), this should be used as input arg when calling z80dasm_op() for the next instruction. @@ -67,7 +66,7 @@ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source - distribution. + distribution. #*/ #include @@ -75,13 +74,13 @@ extern "C" { #endif -// the input callback type -typedef uint8_t (*z80dasm_in_t)(void* userdata); -// the output callback type -typedef void (*z80dasm_out_t)(char c, void* userdata); +/* the input callback type */ +typedef uint8_t (*z80dasm_input_t)(void* user_data); +/* the output callback type */ +typedef void (*z80dasm_output_t)(char c, void* user_data); -// disassemble a single Z80 instruction into a stream of ASCII characters -uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_userdata, z80dasm_out_t out_fn, void* out_userdata); +/* disassemble a single Z80 instruction into a stream of ASCII characters */ +uint16_t z80dasm_op(uint16_t pc, z80dasm_input_t in_cb, z80dasm_output_t out_cb, void* user_data); #ifdef __cplusplus } /* extern "C" */ @@ -94,72 +93,72 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_userdata, z80dasm_ #define CHIPS_ASSERT(c) assert(c) #endif -// fetch unsigned 8-bit value and track pc +/* fetch unsigned 8-bit value and track pc */ #ifdef _FETCH_U8 #undef _FETCH_U8 #endif -#define _FETCH_U8(v) v=in_fn(in_fn_ud);pc++; -// fetch signed 8-bit value and track pc +#define _FETCH_U8(v) v=in_cb(user_data);pc++; +/* fetch signed 8-bit value and track pc */ #ifdef _FETCH_I8 #undef _FETCH_I8 #endif -#define _FETCH_I8(v) v=(int8_t)in_fn(in_fn_ud);pc++; -// fetch unsigned 16-bit value and track pc +#define _FETCH_I8(v) v=(int8_t)in_cb(user_data);pc++; +/* fetch unsigned 16-bit value and track pc */ #ifdef _FETCH_U16 #undef _FETCH_U16 #endif -#define _FETCH_U16(v) v=in_fn(in_fn_ud);v|=in_fn(in_fn_ud)<<8;pc+=2; -// output character +#define _FETCH_U16(v) v=in_cb(user_data);v|=in_cb(user_data)<<8;pc+=2; +/* output character */ #ifdef _CHR #undef _CHR #endif -#define _CHR(c) if (out_fn) { out_fn(c,out_fn_ud); } -// output string +#define _CHR(c) if (out_cb) { out_cb(c,user_data); } +/* output string */ #ifdef _STR #undef _STR #endif -#define _STR(s) _z80dasm_str(s,out_fn,out_fn_ud); -// output offset as signed 8-bit string (decimal) +#define _STR(s) _z80dasm_str(s,out_cb,user_data); +/* output offset as signed 8-bit string (decimal) */ #ifdef _STR_D8 #undef _STR_D8 #endif -#define _STR_D8(d8) _z80dasm_d8((int8_t)(d8),out_fn,out_fn_ud); -// output number as unsigned 8-bit string (hex) +#define _STR_D8(d8) _z80dasm_d8((int8_t)(d8),out_cb,user_data); +/* output number as unsigned 8-bit string (hex) */ #ifdef _STR_U8 #undef _STR_U8 #endif -#define _STR_U8(u8) _z80dasm_u8((uint8_t)(u8),out_fn,out_fn_ud); -// output number number as unsigned 16-bit string (hex) +#define _STR_U8(u8) _z80dasm_u8((uint8_t)(u8),out_cb,user_data); +/* output number number as unsigned 16-bit string (hex) */ #ifdef _STR_U16 #undef _STR_U16 #endif -#define _STR_U16(u16) _z80dasm_u16((uint16_t)(u16),out_fn,out_fn_ud); -// (HL)/(IX+d)/(IX+d) +#define _STR_U16(u16) _z80dasm_u16((uint16_t)(u16),out_cb,user_data); +/* (HL)/(IX+d)/(IX+d) */ #ifdef _M #undef _M #endif #define _M() _STR(r[6]);if(pre){_FETCH_I8(d);_STR_D8(d);_CHR(')');} -// same as _M, but with given offset byte +/* same as _M, but with given offset byte */ #ifdef _Md #undef _Md #endif #define _Md(d) _STR(r[6]);if(pre){_STR_D8(d);_CHR(')');} -// (HL)/(IX+d)/(IX+d) or r +/* (HL)/(IX+d)/(IX+d) or r */ #ifdef _MR #undef _MR #endif #define _MR(i) if(i==6){_M();}else{_STR(r[i]);} -// same as _MR, but with given offset byte +/* same as _MR, but with given offset byte */ #ifdef _MRd #undef _MRd #endif #define _MRd(i,d) _STR(r[i]);if(i==6 && pre){_STR_D8(d);_CHR(')');} -// output 16-bit immediate operand +/* output 16-bit immediate operand */ #ifdef _IMM16 #undef _IMM16 #endif #define _IMM16() _FETCH_U16(u16); _STR_U16(u16); -// output 8-bit immediate operand +/* output 8-bit immediate operand */ #ifdef _IMM8 #undef _IMM8 #endif @@ -190,59 +189,60 @@ static const char* _z80dasm_oct = "01234567"; static const char* _z80dasm_dec = "0123456789"; static const char* _z80dasm_hex = "0123456789ABCDEF"; -// output a string -static void _z80dasm_str(const char* str, z80dasm_out_t out_fn, void* out_fn_ud) { - if (out_fn) { +/* output a string */ +static void _z80dasm_str(const char* str, z80dasm_output_t out_cb, void* user_data) { + if (out_cb) { char c; while (0 != (c = *str++)) { - out_fn(c, out_fn_ud); + out_cb(c, user_data); } } } -// output a signed 8-bit offset value as decimal string -static void _z80dasm_d8(int8_t val, z80dasm_out_t out_fn, void* out_fn_ud) { - if (out_fn) { +/* output a signed 8-bit offset value as decimal string */ +static void _z80dasm_d8(int8_t val, z80dasm_output_t out_cb, void* user_data) { + if (out_cb) { if (val < 0) { - out_fn('-', out_fn_ud); + out_cb('-', user_data); val = -val; - } else { - out_fn('+', out_fn_ud); + } + else { + out_cb('+', user_data); } if (val >= 100) { - out_fn('1', out_fn_ud); + out_cb('1', user_data); val -= 100; } if ((val/10) != 0) { - out_fn(_z80dasm_dec[val/10], out_fn_ud); + out_cb(_z80dasm_dec[val/10], user_data); } - out_fn(_z80dasm_dec[val%10], out_fn_ud); + out_cb(_z80dasm_dec[val%10], user_data); } } -// output an unsigned 8-bit value as hex string -static void _z80dasm_u8(uint8_t val, z80dasm_out_t out_fn, void* out_fn_ud) { - if (out_fn) { +/* output an unsigned 8-bit value as hex string */ +static void _z80dasm_u8(uint8_t val, z80dasm_output_t out_cb, void* user_data) { + if (out_cb) { for (int i = 1; i >= 0; i--) { - out_fn(_z80dasm_hex[(val>>(i*4)) & 0xF], out_fn_ud); + out_cb(_z80dasm_hex[(val>>(i*4)) & 0xF], user_data); } - out_fn('h',out_fn_ud); + out_cb('h',user_data); } } -// output an unsigned 16-bit value as hex string -static void _z80dasm_u16(uint16_t val, z80dasm_out_t out_fn, void* out_fn_ud) { - if (out_fn) { +/* output an unsigned 16-bit value as hex string */ +static void _z80dasm_u16(uint16_t val, z80dasm_output_t out_cb, void* user_data) { + if (out_cb) { for (int i = 3; i >= 0; i--) { - out_fn(_z80dasm_hex[(val>>(i*4)) & 0xF], out_fn_ud); + out_cb(_z80dasm_hex[(val>>(i*4)) & 0xF], user_data); } - out_fn('h',out_fn_ud); + out_cb('h',user_data); } } -// main disassembler function -uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out_t out_fn, void* out_fn_ud) { - CHIPS_ASSERT(in_fn); +/* main disassembler function */ +uint16_t z80dasm_op(uint16_t pc, z80dasm_input_t in_cb, z80dasm_output_t out_cb, void* user_data) { + CHIPS_ASSERT(in_cb); uint8_t op = 0, pre = 0, u8 = 0; int8_t d = 0; uint16_t u16 = 0; @@ -252,16 +252,16 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out const char** rp = _z80dasm_rp; const char** rp2 = _z80dasm_rp2; - // fetch the first instruction byte + /* fetch the first instruction byte */ _FETCH_U8(op); - // prefixed op? + /* prefixed op? */ if ((0xFD == op) || (0xDD == op)) { pre = op; _FETCH_U8(op); if (op == 0xED) { - pre = 0; // an ED following a prefix cancels the prefix + pre = 0; /* an ED following a prefix cancels the prefix */ } - // if prefixed op, use register tables that replace HL with IX/IY + /* if prefixed op, use register tables that replace HL with IX/IY */ if (pre == 0xDD) { r = _z80dasm_rix; rp = _z80dasm_rpix; @@ -273,47 +273,51 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out rp2 = _z80dasm_rp2iy; } } - - // parse the opcode + + /* parse the opcode */ uint8_t x = (op >> 6) & 3; uint8_t y = (op >> 3) & 7; uint8_t z = op & 7; uint8_t p = y >> 1; uint8_t q = y & 1; if (x == 1) { - // 8-bit load block + /* 8-bit load block */ if (y == 6) { if (z == 6) { - // special case LD (HL),(HL) + /* special case LD (HL),(HL) */ _STR("HALT"); - } else { - // LD (HL),r; LD (IX+d),r; LD (IY+d),r + } + else { + /* LD (HL),r; LD (IX+d),r; LD (IY+d),r */ _STR("LD "); _M(); _CHR(','); if (pre && ((z == 4) || (z == 5))) { - // special case LD (IX+d),L/H (don't use IXL/IXH) + /* special case LD (IX+d),L/H (don't use IXL/IXH) */ _STR(_z80dasm_r[z]); - } else { + } + else { _STR(r[z]); } } } else if (z == 6) { - // LD r,(HL); LD r,(IX+d); LD r,(IY+d) + /* LD r,(HL); LD r,(IX+d); LD r,(IY+d) */ _STR("LD "); if (pre && ((y == 4) || (y == 5))) { - // special case LD H/L,(IX+d) (don't use IXL/IXH) + /* special case LD H/L,(IX+d) (don't use IXL/IXH) */ _STR(_z80dasm_r[y]); - } else { + } + else { _STR(r[y]); } _CHR(','); _M(); - } else { - // regular LD r,s + } + else { + /* regular LD r,s */ _STR("LD "); _STR(r[y]); _CHR(','); _STR(r[z]); } } else if (x == 2) { - // 8-bit ALU block + /* 8-bit ALU block */ _STR(alu[y]); _MR(z); } else if (x == 0) { @@ -330,11 +334,12 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out case 1: if (q == 0) { _STR("LD "); _STR(rp[p]); _CHR(','); _IMM16(); - } else { + } + else { _STR("ADD "); _STR(rp[2]); _CHR(','); _STR(rp[p]); } break; - case 2: + case 2: { _STR("LD "); switch (y) { @@ -355,13 +360,15 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out case 6: _STR("LD "); _MR(y); _CHR(','); _IMM8(); break; case 7: _STR(_z80dasm_x0z7[y]); break; } - } else { + } + else { switch (z) { case 0: _STR("RET "); _STR(cc[y]); break; case 1: if (q == 0) { _STR("POP "); _STR(rp2[p]); - } else { + } + else { switch (p) { case 0: _STR("RET"); break; case 1: _STR("EXX"); break; @@ -389,10 +396,11 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out y = (op >> 3) & 7; z = op & 7; if (x == 0) { - // rot and shift instructions + /* rot and shift instructions */ _STR(_z80dasm_rot[y]); _MRd(z,d); - } else { - // bit instructions + } + else { + /* bit instructions */ if (x == 1) { _STR("BIT "); } else if (x == 2) { _STR("RES "); } else { _STR("SET "); } @@ -408,10 +416,11 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out } break; case 4: _STR("CALL "); _STR(cc[y]); _CHR(','); _IMM16(); break; - case 5: + case 5: if (q == 0) { _STR("PUSH "); _STR(rp2[p]); - } else { + } + else { switch (p) { case 0: _STR("CALL "); _IMM16(); break; case 1: _STR("DBL PREFIX"); break; @@ -428,12 +437,14 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out } else if (x == 2) { if ((y >= 4) && (z <= 3)) { - // block instructions + /* block instructions */ _STR(_z80dasm_bli[y-4][z]); - } else { + } + else { _STR("NOP (ED)"); } - } else { + } + else { switch (z) { case 0: _STR("IN "); if(y!=6){_STR(r[y]);_CHR(',');} _STR("(C)"); break; case 1: _STR("OUT (C),"); _STR(y==6?"0":r[y]); break; @@ -442,7 +453,8 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out _STR("LD "); if (q == 0) { _CHR('('); _IMM16(); _STR("),"); _STR(rp[p]); - } else { + } + else { _STR(rp[p]); _STR(",("); _IMM16(); _CHR(')'); } break; @@ -477,4 +489,4 @@ uint16_t z80dasm_op(uint16_t pc, z80dasm_in_t in_fn, void* in_fn_ud, z80dasm_out #undef _MRd #undef _IMM16 #undef _IMM8 -#endif // CHIPS_UTIL_IMPL +#endif /* CHIPS_UTIL_IMPL */