DGen/SDL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions | Variables
cpudebug.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdint.h>
#include "starcpu.h"
#include "cpudebug.h"

Macros

#define byte   uint8_t
#define word   uit16_t
#define dword   uint32_t
#define int08   int8_t
#define int16   int16_t
#define int32   int32_t
#define ea   eacalc[inst&0x3F]()
#define hex08   "%02X"
#define hex16   "%04X"
#define hex32   "%08X"
#define hexlong   "%06X"
#define isregister   ((inst&0x0030)==0x0000)
#define isaddressr   ((inst&0x0038)==0x0008)
#define eacalc_drd(n, r)   static void n(void){sprintf(eabuffer,"d%d",r);}
#define eacalc_ard(n, r)   static void n(void){sprintf(eabuffer,"a%d",r);}
#define eacalc_ari(n, r)   static void n(void){sprintf(eabuffer,"(a%d)",r);}
#define eacalc_ari_inc(n, r)   static void n(void){sprintf(eabuffer,"(a%d)+",r);}
#define eacalc_ari_dec(n, r)   static void n(void){sprintf(eabuffer,"-(a%d)",r);}
#define eacalc_ari_dis(n, r)
#define eacalc_ari_ind(n, r)
#define bittest_st(name, dump)
#define conditional_branch(name, dump)
#define scc_dbcc(name, dump1, dump2)
#define negate_ea(name, dump)
#define im_to_ea(name, type, hextype, fetchtype, dump, r)
#define ea_to_dn(name, dump)
#define ea_to_an(name, dump)
#define support_addsubx(name, dump)
#define support_bcd(name, dump)
#define support_cmpm(name, dump)
#define dn_to_ea(name, dump, s_cond, s_routine)
#define qn_to_ea(name, dump1)
#define ea_to_ea(name, dump)
#define movem_mem(name, dumpm, dumpx)
#define movem_reg(name, dump)
#define regshift(name, sizedump)

Functions

static void cpudebug_gets (char *s, int n)
static void cpudebug_putc (char c)
static void cpudebug_printf (const char *fmt,...)
int cpudebug_disabled (void)
static word fetch (void)
static dword fetchl (void)
 eacalc_drd (ea_0_0, 0)
static void eacalcspecial_abslong (void)
static void eacalcspecial_immdata (void)
static void eacalcspecial_pci_dis (void)
static void eacalcspecial_pci_ind (void)
static void eacalcspecial_unknown (void)
static void eacalc (void)
static void m68unsupported (void)
static void m68_unrecog_x (void)
static void m68_bitopdn_x (void)
 bittest_st (m68_btst_st_x,"btst")
static void m68_jsr_____x (void)
static void m68_bsr_____x (void)
static void m68_tas_____b (void)
static void m68_lea___n_l (void)
static void m68_pea_____l (void)
 negate_ea (m68_neg_____b,"neg.b ")
static void m68support_exg_diff (void)
 dn_to_ea (m68_add_e_n_b,"add.b", dn_to_ea(isregister, m68support_addx_b)
 ea_to_ea (m68_move____b,"move.b")
static void getreglistb (word mask, char *rl)
 movem_mem (m68_movem___w,"movem ","ext ")
static void m68_movefsr_w (void)
static void m68_move2cc_w (void)
static void m68_movefcc_w (void)
static void m68_rts_____x (void)
 regshift (m68_shl_r_n_b,"l.b")
static void m68_link_an_w (void)
static void m68_unlk_an_x (void)
static void m68_stop____x (void)
static void m68_rte_____x (void)
static void m68_rtr_____x (void)
static void m68_reset___x (void)
static void m68_rtd_____x (void)
static void m68_divu__n_w (void)
static void m68_divs__n_w (void)
static void m68_mulu__n_w (void)
static void m68_muls__n_w (void)
static void m68_asr_m___w (void)
static void m68_asl_m___w (void)
static void m68_lsr_m___w (void)
static void m68_lsl_m___w (void)
static void m68_roxr_m__w (void)
static void m68_roxl_m__w (void)
static void m68_ror_m___w (void)
static void m68_rol_m___w (void)
static void m68_nbcd____b (void)
static void m68_chk___n_w (void)
static void m68_trap_nn_x (void)
static void m68_move_2u_l (void)
static void m68_move_fu_l (void)
static void m68_trapv___x (void)
static char * specialregister (unsigned short int code)
static void m68_movec_r_x (void)
static void m68_movec_c_x (void)
static void debugspecialmap (void)
static void m68_special_x (void)
static void debugmap (void)
static void cpudebug_disassemble (int n)
static void cpudebug_hexdump (void)
static void cpudebug_registerdump (void)
int cpudebug_interactive (int cpun, void(*put)(const char *), void(*get)(char *, int), void(*execstep)(void), void(*dump)(void))

Variables

void(* cpudebug_get )(char *, int)
void(* cpudebug_put )(const char *)
static char eabuffer [20]
static char sdebug [80]
static dword debugpc
static dword hexaddr
static int isize
static word inst
static int08 opsize [1024]

Macro Definition Documentation

#define bittest_st (   name,
  dump 
)
Value:
static void name(void){\
byte shiftby=(fetch()&0xFF);\
ea;sprintf(sdebug,"%s #$"hex08",%s",dump,shiftby,eabuffer);\
}
#define byte   uint8_t
#define conditional_branch (   name,
  dump 
)
Value:
static void name(void){\
int16 disp;\
int32 currentpc=debugpc;\
disp=(int08)(inst&0xFF);\
if(!disp)disp=fetch();\
sprintf(sdebug,"%s ($"hexlong")",dump,currentpc+disp);\
}
#define dn_to_ea (   name,
  dump,
  s_cond,
  s_routine 
)
Value:
static void name(void){\
ea;if(s_cond)s_routine();\
else sprintf(sdebug,"%s d%d,%s",dump,(inst>>9)&7,eabuffer);\
}
#define dword   uint32_t
#define ea   eacalc[inst&0x3F]()
#define ea_to_an (   name,
  dump 
)
Value:
static void name(void){\
ea;sprintf(sdebug,"%s %s,a%d",dump,eabuffer,((inst>>9)&7));\
}
#define ea_to_dn (   name,
  dump 
)
Value:
static void name(void){\
ea;sprintf(sdebug,"%s %s,d%d",dump,eabuffer,(inst>>9)&7);\
}
#define ea_to_ea (   name,
  dump 
)
Value:
static void name(void){\
char tmpbuf[40];\
ea;strcpy(tmpbuf,eabuffer);\
eacalc[((((inst>>3)&(7<<3)))|((inst>>9)&7))]();\
sprintf(sdebug,"%s %s,%s",dump,tmpbuf,eabuffer);\
}
#define eacalc_ard (   n,
 
)    static void n(void){sprintf(eabuffer,"a%d",r);}
#define eacalc_ari (   n,
 
)    static void n(void){sprintf(eabuffer,"(a%d)",r);}
#define eacalc_ari_dec (   n,
 
)    static void n(void){sprintf(eabuffer,"-(a%d)",r);}
#define eacalc_ari_dis (   n,
 
)
Value:
static void n(void){\
int16 briefext=fetch();\
sprintf(eabuffer,"%c$" hex16 "(a%d)",(briefext<0)?'-':'+',(briefext<0)?-briefext:briefext,r);\
}
#define eacalc_ari_inc (   n,
 
)    static void n(void){sprintf(eabuffer,"(a%d)+",r);}
#define eacalc_ari_ind (   n,
 
)
Value:
static void n(void){\
int16 briefext=fetch();\
if(briefext<0)sprintf(eabuffer,"-$" hex08 "(a%d,%c%d.%c)",\
(int08)-briefext,r,\
briefext&0x8000?'a':'d',(briefext>>12)&7,\
briefext&0x800?'l':'w');\
else sprintf(eabuffer,"+$" hex08 "(a%d,%c%d.%c)",\
(int08)briefext,r,\
briefext&0x8000?'a':'d',(briefext>>12)&7,\
briefext&0x800?'l':'w');\
}
#define eacalc_drd (   n,
 
)    static void n(void){sprintf(eabuffer,"d%d",r);}
#define hex08   "%02X"
#define hex16   "%04X"
#define hex32   "%08X"
#define hexlong   "%06X"
#define im_to_ea (   name,
  type,
  hextype,
  fetchtype,
  dump,
 
)
Value:
static void name(void){\
type src=(type)fetchtype();\
if((inst&0x3F)==0x3C){\
sprintf(sdebug,"%s #$"hextype",%s",dump,src,r);\
}else{\
ea;sprintf(sdebug,"%s #$"hextype",%s",dump,src,eabuffer);\
}\
}
#define int08   int8_t
#define int16   int16_t
#define int32   int32_t
#define isaddressr   ((inst&0x0038)==0x0008)
#define isregister   ((inst&0x0030)==0x0000)
#define movem_mem (   name,
  dumpm,
  dumpx 
)
Value:
static void name(void){\
word regmask;\
char reglist[50];\
if((inst&0x38)==0x0000){ /* ext */\
sprintf(sdebug,dumpx"d%d",inst&7);\
}else if((inst&0x38)==0x0020){ /* predecrement addressing mode */\
regmask=fetch();\
getreglistb(regmask,reglist);\
sprintf(sdebug,dumpm"%s,-(a%d)",reglist,inst&7);\
}else{\
regmask=fetch();\
ea;getreglistf(regmask,reglist);\
sprintf(sdebug,dumpm "%s,%s",reglist,eabuffer);\
}\
}
#define movem_reg (   name,
  dump 
)
Value:
static void name(void){\
word regmask;\
char reglist[50];\
regmask=fetch();\
ea;getreglistf(regmask,reglist);\
sprintf(sdebug,dump "%s,%s",eabuffer,reglist);\
}
#define negate_ea (   name,
  dump 
)
Value:
static void name(void){\
ea;sprintf(sdebug,"%s %s",dump,eabuffer);\
}
#define qn_to_ea (   name,
  dump1 
)
Value:
static void name(void){\
ea;sprintf(sdebug,"%s #%d,%s",dump1,(((inst>>9)&7)==0)?8:(inst>>9)&7,eabuffer);\
}
#define regshift (   name,
  sizedump 
)
Value:
static void name(void){\
char tmpbuf[10];\
if((inst&0x20)==0)sprintf(tmpbuf,"#$"hex08",d%d",(((inst>>9)&7)==0)?8:(inst>>9)&7,inst&7);\
else sprintf(tmpbuf,"d%d,d%d",(inst>>9)&7,inst&7);\
switch(inst&0x18){\
case 0x00:sprintf(sdebug,"as%s %s",sizedump,tmpbuf);break;\
case 0x08:sprintf(sdebug,"ls%s %s",sizedump,tmpbuf);break;\
case 0x10:sprintf(sdebug,"rox%s %s",sizedump,tmpbuf);break;\
case 0x18:sprintf(sdebug,"ro%s %s",sizedump,tmpbuf);break;\
}\
}
#define scc_dbcc (   name,
  dump1,
  dump2 
)
Value:
static void name(void){\
ea;if(isaddressr){\
int16 disp;\
disp=fetch();\
sprintf(sdebug,"%s d%d,($"hexlong")",dump2,inst&7,debugpc+disp-2);\
}else sprintf(sdebug,"%s %s",dump1,eabuffer);\
}
#define support_addsubx (   name,
  dump 
)
Value:
static void name(void){\
word nregx=(inst>>9)&7,nregy=inst&7;\
if(inst&0x0008)sprintf(sdebug,"%s -(a%d),-(a%d)",dump,nregy,nregx);\
else sprintf(sdebug,"%s d%d,d%d",dump,nregy,nregx);\
}
#define support_bcd (   name,
  dump 
)
Value:
static void name(void){\
word nregx=(inst>>9)&7,nregy=inst&7;\
if(inst&0x0008)sprintf(sdebug,"%s -(a%d),-(a%d)",dump,nregy,nregx);\
else sprintf(sdebug,"%s d%d,d%d",dump,nregy,nregx);\
}
#define support_cmpm (   name,
  dump 
)
Value:
static void name(void){\
sprintf(sdebug,"%s (a%d)+,(a%d)+",dump,inst&7,(inst>>9)&7);\
}
#define word   uit16_t

Function Documentation

bittest_st ( m68_btst_st_x  ,
"btst"   
)
int cpudebug_disabled ( void  )
static void cpudebug_disassemble ( int  n)
static
static void cpudebug_gets ( char *  s,
int  n 
)
static
static void cpudebug_hexdump ( void  )
static
int cpudebug_interactive ( int  cpun,
void(*)(const char *)  put,
void(*)(char *, int)  get,
void(*)(void)  execstep,
void(*)(void)  dump 
)
static void cpudebug_printf ( const char *  fmt,
  ... 
)
static
static void cpudebug_putc ( char  c)
static
static void cpudebug_registerdump ( void  )
static
static void debugmap ( void  )
static
static void debugspecialmap ( void  )
static
dn_to_ea ( m68_add_e_n_b  ,
"add.b"  ,
dn_to_ea(  isregister,
m68support_addx_b   
)
ea_to_ea ( m68_move____b  ,
"move.b"   
)
static void eacalc ( void  )
static
eacalc_drd ( ea_0_0  ,
 
)
static void eacalcspecial_abslong ( void  )
static
static void eacalcspecial_immdata ( void  )
static
static void eacalcspecial_pci_dis ( void  )
static
static void eacalcspecial_pci_ind ( void  )
static
static void eacalcspecial_unknown ( void  )
static
static word fetch ( void  )
static
static dword fetchl ( void  )
static
static void getreglistb ( word  mask,
char *  rl 
)
static
static void m68_asl_m___w ( void  )
static
static void m68_asr_m___w ( void  )
static
static void m68_bitopdn_x ( void  )
static
static void m68_bsr_____x ( void  )
static
static void m68_chk___n_w ( void  )
static
static void m68_divs__n_w ( void  )
static
static void m68_divu__n_w ( void  )
static
static void m68_jsr_____x ( void  )
static
static void m68_lea___n_l ( void  )
static
static void m68_link_an_w ( void  )
static
static void m68_lsl_m___w ( void  )
static
static void m68_lsr_m___w ( void  )
static
static void m68_move2cc_w ( void  )
static
static void m68_move_2u_l ( void  )
static
static void m68_move_fu_l ( void  )
static
static void m68_movec_c_x ( void  )
static
static void m68_movec_r_x ( void  )
static
static void m68_movefcc_w ( void  )
static
static void m68_movefsr_w ( void  )
static
static void m68_muls__n_w ( void  )
static
static void m68_mulu__n_w ( void  )
static
static void m68_nbcd____b ( void  )
static
static void m68_pea_____l ( void  )
static
static void m68_reset___x ( void  )
static
static void m68_rol_m___w ( void  )
static
static void m68_ror_m___w ( void  )
static
static void m68_roxl_m__w ( void  )
static
static void m68_roxr_m__w ( void  )
static
static void m68_rtd_____x ( void  )
static
static void m68_rte_____x ( void  )
static
static void m68_rtr_____x ( void  )
static
static void m68_rts_____x ( void  )
static
static void m68_special_x ( void  )
static
static void m68_stop____x ( void  )
static
static void m68_tas_____b ( void  )
static
static void m68_trap_nn_x ( void  )
static
static void m68_trapv___x ( void  )
static
static void m68_unlk_an_x ( void  )
static
static void m68_unrecog_x ( void  )
static
static void m68support_exg_diff ( void  )
static
static void m68unsupported ( void  )
static
movem_mem ( m68_movem___w  ,
"movem "  ,
"ext "   
)
negate_ea ( m68_neg_____b  ,
"neg.b "   
)
regshift ( m68_shl_r_n_b  ,
"l.b"   
)
static char* specialregister ( unsigned short int  code)
static

Variable Documentation

void(* cpudebug_get)(char *, int)
void(* cpudebug_put)(const char *)
dword debugpc
static
char eabuffer[20]
static
dword hexaddr
static
word inst
static
int isize
static
int08 opsize[1024]
static
char sdebug[80]
static