19 #define __Z80EX_SELF_INCLUDE
23 #define snprintf _snprintf
34 static const char *formats[] = {
42 int z80ex_dasm(
char *output,
int output_size,
unsigned flags,
int *t_states,
int *t_states2,
50 const char *bytes_format=formats[0];
51 const char *words_format=formats[1];
70 if((
next | 0x20) == 0xFD ||
next == 0xED)
72 strncpy(output,
"NOP*",output_size-1);
82 dasm = (opc==0xDD)? &dasm_ddcb[
next]: &dasm_fdcb[
next];
88 dasm = (opc==0xDD)? &dasm_dd[
next]: &dasm_fd[
next];
91 dasm = &dasm_base[
next];
101 dasm = &dasm_ed[
next];
104 strncpy(output,
"NOP*",output_size-1);
113 dasm = &dasm_cb[
next];
117 dasm = &dasm_base[opc];
128 for(mpos=(dasm->
mnemonic); *mpos && out_len < output_size; mpos++)
139 arglen=snprintf(stmp,
STMP_SIZE,words_format,(
int)(lo+hi*0x100));
147 disp = (disp_u & 0x80)? -(((~disp_u) & 0x7f)+1): disp_u;
150 arglen=snprintf(stmp,
STMP_SIZE,bytes_format,(
int)disp);
160 arglen=snprintf(stmp,
STMP_SIZE,bytes_format,(
int)lo);
173 if(out_len+arglen >= output_size)
break;
186 if(*t_states == *t_states2) *t_states2=0;