--- uae/src/include/newcpu.h 2018/04/24 16:40:18 1.1.1.3 +++ uae/src/include/newcpu.h 2018/04/24 16:46:28 1.1.1.6 @@ -6,6 +6,32 @@ * Copyright 1995 Bernd Schmidt */ +#include + +#ifndef SET_CFLG + +#define SET_CFLG(x) (CFLG = (x)) +#define SET_NFLG(x) (NFLG = (x)) +#define SET_VFLG(x) (VFLG = (x)) +#define SET_ZFLG(x) (ZFLG = (x)) +#define SET_XFLG(x) (XFLG = (x)) + +#define GET_CFLG CFLG +#define GET_NFLG NFLG +#define GET_VFLG VFLG +#define GET_ZFLG ZFLG +#define GET_XFLG XFLG + +#define CLEAR_CZNV do { \ + SET_CFLG (0); \ + SET_ZFLG (0); \ + SET_NFLG (0); \ + SET_VFLG (0); \ +while (0) + +#define COPY_CARRY (SET_XFLG (GET_CFLG)) +#endif + extern int areg_byteinc[]; extern int imm8_table[]; @@ -19,7 +45,7 @@ extern int fpp_movem_next[256]; extern int broken_in; -typedef void cpuop_func(uae_u32) REGPARAM; +typedef unsigned long cpuop_func (uae_u32) REGPARAM; struct cputbl { cpuop_func *handler; @@ -27,7 +53,7 @@ struct cputbl { uae_u16 opcode; }; -extern void op_illg(uae_u32) REGPARAM; +extern unsigned long op_illg (uae_u32) REGPARAM; typedef char flagtype; @@ -65,27 +91,33 @@ extern struct regstruct } regs, lastint_regs; #define m68k_dreg(r,num) ((r).regs[(num)]) -#define m68k_areg(r,num) ((r).regs[(num)+8]) +#define m68k_areg(r,num) (((r).regs + 8)[(num)]) #define get_ibyte(o) do_get_mem_byte((uae_u8 *)(regs.pc_p + (o) + 1)) #define get_iword(o) do_get_mem_word((uae_u16 *)(regs.pc_p + (o))) #define get_ilong(o) do_get_mem_long((uae_u32 *)(regs.pc_p + (o))) -static __inline__ uae_u32 get_ibyte_prefetch(uae_s32 o) +#ifdef HAVE_GET_WORD_UNSWAPPED +#define GET_OPCODE (do_get_mem_word_unswapped (regs.pc_p)) +#else +#define GET_OPCODE (get_iword (0)) +#endif + +static __inline__ uae_u32 get_ibyte_prefetch (uae_s32 o) { if (o > 3 || o < 0) return do_get_mem_byte((uae_u8 *)(regs.pc_p + o + 1)); return do_get_mem_byte((uae_u8 *)(((uae_u8 *)®s.prefetch) + o + 1)); } -static __inline__ uae_u32 get_iword_prefetch(uae_s32 o) +static __inline__ uae_u32 get_iword_prefetch (uae_s32 o) { if (o > 3 || o < 0) return do_get_mem_word((uae_u16 *)(regs.pc_p + o)); return do_get_mem_word((uae_u16 *)(((uae_u8 *)®s.prefetch) + o)); } -static __inline__ uae_u32 get_ilong_prefetch(uae_s32 o) +static __inline__ uae_u32 get_ilong_prefetch (uae_s32 o) { if (o > 3 || o < 0) return do_get_mem_long((uae_u32 *)(regs.pc_p + o)); @@ -96,7 +128,7 @@ static __inline__ uae_u32 get_ilong_pref #define m68k_incpc(o) (regs.pc_p += (o)) -static __inline__ void fill_prefetch_0(void) +static __inline__ void fill_prefetch_0 (void) { uae_u32 r; #ifdef UNALIGNED_PROFITABLE @@ -109,7 +141,7 @@ static __inline__ void fill_prefetch_0(v } #if 0 -static __inline__ void fill_prefetch_2(void) +static __inline__ void fill_prefetch_2 (void) { uae_u32 r = do_get_mem_long (®s.prefetch) << 16; uae_u32 r2 = do_get_mem_word (((uae_u16 *)regs.pc_p) + 1); @@ -122,111 +154,82 @@ static __inline__ void fill_prefetch_2(v /* These are only used by the 68020/68881 code, and therefore don't * need to handle prefetch. */ -static __inline__ uae_u32 next_ibyte(void) +static __inline__ uae_u32 next_ibyte (void) { - uae_u32 r = get_ibyte(0); - m68k_incpc(2); + uae_u32 r = get_ibyte (0); + m68k_incpc (2); return r; } -static __inline__ uae_u32 next_iword(void) +static __inline__ uae_u32 next_iword (void) { - uae_u32 r = get_iword(0); - m68k_incpc(2); + uae_u32 r = get_iword (0); + m68k_incpc (2); return r; } -static __inline__ uae_u32 next_ilong(void) +static __inline__ uae_u32 next_ilong (void) { - uae_u32 r = get_ilong(0); - m68k_incpc(4); + uae_u32 r = get_ilong (0); + m68k_incpc (4); return r; } -#if !defined(USE_COMPILER) -static __inline__ void m68k_setpc(uaecptr newpc) +#if !defined USE_COMPILER +static __inline__ void m68k_setpc (uaecptr newpc) { regs.pc_p = regs.pc_oldp = get_real_address(newpc); regs.pc = newpc; } #else -extern void m68k_setpc(uaecptr newpc); +extern void m68k_setpc (uaecptr newpc); #endif -static __inline__ uaecptr m68k_getpc(void) +static __inline__ uaecptr m68k_getpc (void) { return regs.pc + ((char *)regs.pc_p - (char *)regs.pc_oldp); } +static __inline__ uaecptr m68k_getpc_p (uae_u8 *p) +{ + return regs.pc + ((char *)p - (char *)regs.pc_oldp); +} + #ifdef USE_COMPILER -extern void m68k_setpc_fast(uaecptr newpc); -extern void m68k_setpc_bcc(uaecptr newpc); -extern void m68k_setpc_rte(uaecptr newpc); +extern void m68k_setpc_fast (uaecptr newpc); +extern void m68k_setpc_bcc (uaecptr newpc); +extern void m68k_setpc_rte (uaecptr newpc); #else #define m68k_setpc_fast m68k_setpc #define m68k_setpc_bcc m68k_setpc #define m68k_setpc_rte m68k_setpc #endif -static __inline__ void m68k_setstopped(int stop) +static __inline__ void m68k_setstopped (int stop) { regs.stopped = stop; if (stop) regs.spcflags |= SPCFLAG_STOP; } -static __inline__ uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp) -{ - int reg = (dp >> 12) & 15; - uae_s32 regd = regs.regs[reg]; - if ((dp & 0x800) == 0) - regd = (uae_s32)(uae_s16)regd; - regd <<= (dp >> 9) & 3; - if (dp & 0x100) { - uae_s32 outer = 0; - if (dp & 0x80) base = 0; - if (dp & 0x40) regd = 0; - - if ((dp & 0x30) == 0x20) base += (uae_s32)(uae_s16)next_iword(); - if ((dp & 0x30) == 0x30) base += next_ilong(); - - if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)next_iword(); - if ((dp & 0x3) == 0x3) outer = next_ilong(); - - if ((dp & 0x4) == 0) base += regd; - if (dp & 0x3) base = get_long (base); - if (dp & 0x4) base += regd; - - return base + outer; - } else { - return base + (uae_s32)((uae_s8)dp) + regd; - } -} -static __inline__ uae_u32 get_disp_ea_000 (uae_u32 base, uae_u32 dp) -{ - int reg = (dp >> 12) & 15; - uae_s32 regd = regs.regs[reg]; - - if ((dp & 0x800) == 0) - regd = (uae_s32)(uae_s16)regd; - return base + (uae_s8)dp + regd; -} - -extern uae_s32 ShowEA(int reg, amodes mode, wordsizes size, char *buf); - -extern void MakeSR(void); -extern void MakeFromSR(void); -extern void Exception(int, uaecptr); -extern void dump_counts(void); -extern void m68k_move2c(int, uae_u32 *); -extern void m68k_movec2(int, uae_u32 *); +extern uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp); +extern uae_u32 get_disp_ea_000 (uae_u32 base, uae_u32 dp); + +extern uae_s32 ShowEA (int reg, amodes mode, wordsizes size, char *buf); + +extern void MakeSR (void); +extern void MakeFromSR (void); +extern void Exception (int, uaecptr); +extern void dump_counts (void); +extern void m68k_move2c (int, uae_u32 *); +extern void m68k_movec2 (int, uae_u32 *); extern void m68k_divl (uae_u32, uae_u32, uae_u16, uaecptr); extern void m68k_mull (uae_u32, uae_u32, uae_u16); extern void init_m68k (void); -extern void m68k_go(int); -extern void m68k_dumpstate(uaecptr *); -extern void m68k_disasm(uaecptr,uaecptr *,int); -extern void m68k_reset(void); +extern void m68k_go (int); +extern void m68k_dumpstate (uaecptr *); +extern void m68k_disasm (uaecptr, uaecptr *, int); +extern void m68k_reset (void); extern void mmu_op (uae_u32, uae_u16);