Annotation of uae/src/include/newcpu.h, revision 1.1.1.11

1.1.1.3   root        1:  /*
1.1       root        2:   * UAE - The Un*x Amiga Emulator
1.1.1.3   root        3:   *
1.1       root        4:   * MC68000 emulation
                      5:   *
                      6:   * Copyright 1995 Bernd Schmidt
                      7:   */
                      8: 
1.1.1.10  root        9: #include "readcpu.h"
                     10: #include "machdep/m68k.h"
1.1.1.6   root       11: 
                     12: #ifndef SET_CFLG
                     13: 
                     14: #define SET_CFLG(x) (CFLG = (x))
                     15: #define SET_NFLG(x) (NFLG = (x))
                     16: #define SET_VFLG(x) (VFLG = (x))
                     17: #define SET_ZFLG(x) (ZFLG = (x))
                     18: #define SET_XFLG(x) (XFLG = (x))
                     19: 
                     20: #define GET_CFLG CFLG
                     21: #define GET_NFLG NFLG
                     22: #define GET_VFLG VFLG
                     23: #define GET_ZFLG ZFLG
                     24: #define GET_XFLG XFLG
                     25: 
                     26: #define CLEAR_CZNV do { \
                     27:  SET_CFLG (0); \
                     28:  SET_ZFLG (0); \
                     29:  SET_NFLG (0); \
                     30:  SET_VFLG (0); \
1.1.1.7   root       31: } while (0)
1.1.1.6   root       32: 
                     33: #define COPY_CARRY (SET_XFLG (GET_CFLG))
                     34: #endif
                     35: 
1.1       root       36: extern int areg_byteinc[];
                     37: extern int imm8_table[];
                     38: 
                     39: extern int movem_index1[256];
                     40: extern int movem_index2[256];
                     41: extern int movem_next[256];
                     42: 
                     43: extern int fpp_movem_index1[256];
                     44: extern int fpp_movem_index2[256];
                     45: extern int fpp_movem_next[256];
                     46: 
                     47: extern int broken_in;
                     48: 
1.1.1.4   root       49: typedef unsigned long cpuop_func (uae_u32) REGPARAM;
1.1       root       50: 
                     51: struct cputbl {
                     52:     cpuop_func *handler;
                     53:     int specific;
1.1.1.3   root       54:     uae_u16 opcode;
1.1       root       55: };
                     56: 
1.1.1.4   root       57: extern unsigned long op_illg (uae_u32) REGPARAM;
1.1       root       58: 
1.1.1.2   root       59: typedef char flagtype;
1.1       root       60: 
1.1.1.11! root       61: /* You can set this to long double to be more accurate. However, the
        !            62:    resulting alignment issues will cost a lot of performance in some
        !            63:    apps */
        !            64: #define USE_LONG_DOUBLE 0
        !            65: 
        !            66: #if USE_LONG_DOUBLE
        !            67: typedef long double fptype;
        !            68: #else
        !            69: typedef double fptype;
        !            70: #endif
        !            71: 
1.1.1.3   root       72: extern struct regstruct
1.1       root       73: {
1.1.1.3   root       74:     uae_u32 regs[16];
                     75:     uaecptr  usp,isp,msp;
                     76:     uae_u16 sr;
1.1       root       77:     flagtype t1;
                     78:     flagtype t0;
                     79:     flagtype s;
                     80:     flagtype m;
                     81:     flagtype x;
                     82:     flagtype stopped;
                     83:     int intmask;
1.1.1.3   root       84: 
                     85:     uae_u32 pc;
                     86:     uae_u8 *pc_p;
                     87:     uae_u8 *pc_oldp;
                     88: 
                     89:     uae_u32 vbr,sfc,dfc;
1.1       root       90: 
1.1.1.11! root       91:     fptype fp[8];
        !            92:     fptype fp_result;
        !            93: 
1.1.1.3   root       94:     uae_u32 fpcr,fpsr,fpiar;
1.1.1.11! root       95:     uae_u32 fpsr_highbyte;
1.1.1.3   root       96: 
                     97:     uae_u32 spcflags;
                     98:     uae_u32 kick_mask;
                     99: 
                    100:     /* Fellow sources say this is 4 longwords. That's impossible. It needs
                    101:      * to be at least a longword. The HRM has some cryptic comment about two
                    102:      * instructions being on the same longword boundary.
                    103:      * The way this is implemented now seems like a good compromise.
                    104:      */
                    105:     uae_u32 prefetch;
1.1       root      106: } regs, lastint_regs;
                    107: 
1.1.1.10  root      108: STATIC_INLINE void set_special (uae_u32 x)
                    109: {
                    110:     regs.spcflags |= x;
                    111: }
                    112: 
                    113: STATIC_INLINE void unset_special (uae_u32 x)
                    114: {
                    115:     regs.spcflags &= ~x;
                    116: }
                    117: 
1.1.1.2   root      118: #define m68k_dreg(r,num) ((r).regs[(num)])
1.1.1.4   root      119: #define m68k_areg(r,num) (((r).regs + 8)[(num)])
1.1       root      120: 
1.1.1.3   root      121: #define get_ibyte(o) do_get_mem_byte((uae_u8 *)(regs.pc_p + (o) + 1))
                    122: #define get_iword(o) do_get_mem_word((uae_u16 *)(regs.pc_p + (o)))
                    123: #define get_ilong(o) do_get_mem_long((uae_u32 *)(regs.pc_p + (o)))
                    124: 
1.1.1.7   root      125: STATIC_INLINE uae_u32 get_ibyte_prefetch (uae_s32 o)
1.1       root      126: {
1.1.1.3   root      127:     if (o > 3 || o < 0)
                    128:        return do_get_mem_byte((uae_u8 *)(regs.pc_p + o + 1));
                    129: 
                    130:     return do_get_mem_byte((uae_u8 *)(((uae_u8 *)&regs.prefetch) + o + 1));
1.1.1.2   root      131: }
1.1.1.7   root      132: STATIC_INLINE uae_u32 get_iword_prefetch (uae_s32 o)
1.1.1.3   root      133: {
                    134:     if (o > 3 || o < 0)
                    135:        return do_get_mem_word((uae_u16 *)(regs.pc_p + o));
1.1.1.2   root      136: 
1.1.1.3   root      137:     return do_get_mem_word((uae_u16 *)(((uae_u8 *)&regs.prefetch) + o));
                    138: }
1.1.1.7   root      139: STATIC_INLINE uae_u32 get_ilong_prefetch (uae_s32 o)
1.1.1.2   root      140: {
1.1.1.3   root      141:     if (o > 3 || o < 0)
                    142:        return do_get_mem_long((uae_u32 *)(regs.pc_p + o));
                    143:     if (o == 0)
                    144:        return do_get_mem_long(&regs.prefetch);
                    145:     return (do_get_mem_word (((uae_u16 *)&regs.prefetch) + 1) << 16) | do_get_mem_word ((uae_u16 *)(regs.pc_p + 4));
1.1       root      146: }
                    147: 
1.1.1.3   root      148: #define m68k_incpc(o) (regs.pc_p += (o))
                    149: 
1.1.1.7   root      150: STATIC_INLINE void fill_prefetch_0 (void)
1.1       root      151: {
1.1.1.3   root      152:     uae_u32 r;
                    153: #ifdef UNALIGNED_PROFITABLE
                    154:     r = *(uae_u32 *)regs.pc_p;
                    155:     regs.prefetch = r;
                    156: #else
                    157:     r = do_get_mem_long ((uae_u32 *)regs.pc_p);
                    158:     do_put_mem_long (&regs.prefetch, r);
                    159: #endif
                    160: }
                    161: 
                    162: #if 0
1.1.1.7   root      163: STATIC_INLINE void fill_prefetch_2 (void)
1.1.1.3   root      164: {
                    165:     uae_u32 r = do_get_mem_long (&regs.prefetch) << 16;
                    166:     uae_u32 r2 = do_get_mem_word (((uae_u16 *)regs.pc_p) + 1);
                    167:     r |= r2;
                    168:     do_put_mem_long (&regs.prefetch, r);
1.1       root      169: }
                    170: #else
1.1.1.3   root      171: #define fill_prefetch_2 fill_prefetch_0
                    172: #endif
1.1       root      173: 
1.1.1.3   root      174: /* These are only used by the 68020/68881 code, and therefore don't
                    175:  * need to handle prefetch.  */
1.1.1.7   root      176: STATIC_INLINE uae_u32 next_ibyte (void)
1.1       root      177: {
1.1.1.4   root      178:     uae_u32 r = get_ibyte (0);
                    179:     m68k_incpc (2);
1.1.1.2   root      180:     return r;
                    181: }
                    182: 
1.1.1.7   root      183: STATIC_INLINE uae_u32 next_iword (void)
1.1.1.2   root      184: {
1.1.1.4   root      185:     uae_u32 r = get_iword (0);
                    186:     m68k_incpc (2);
1.1       root      187:     return r;
                    188: }
                    189: 
1.1.1.7   root      190: STATIC_INLINE uae_u32 next_ilong (void)
1.1       root      191: {
1.1.1.4   root      192:     uae_u32 r = get_ilong (0);
                    193:     m68k_incpc (4);
1.1       root      194:     return r;
                    195: }
                    196: 
1.1.1.4   root      197: #if !defined USE_COMPILER
1.1.1.7   root      198: STATIC_INLINE void m68k_setpc (uaecptr newpc)
1.1       root      199: {
                    200:     regs.pc_p = regs.pc_oldp = get_real_address(newpc);
1.1.1.2   root      201:     regs.pc = newpc;
1.1       root      202: }
                    203: #else
1.1.1.4   root      204: extern void m68k_setpc (uaecptr newpc);
1.1       root      205: #endif
                    206: 
1.1.1.7   root      207: STATIC_INLINE uaecptr m68k_getpc (void)
1.1       root      208: {
                    209:     return regs.pc + ((char *)regs.pc_p - (char *)regs.pc_oldp);
                    210: }
                    211: 
1.1.1.7   root      212: STATIC_INLINE uaecptr m68k_getpc_p (uae_u8 *p)
1.1.1.4   root      213: {
                    214:     return regs.pc + ((char *)p - (char *)regs.pc_oldp);
                    215: }
                    216: 
1.1       root      217: #ifdef USE_COMPILER
1.1.1.4   root      218: extern void m68k_setpc_fast (uaecptr newpc);
                    219: extern void m68k_setpc_bcc (uaecptr newpc);
                    220: extern void m68k_setpc_rte (uaecptr newpc);
1.1       root      221: #else
                    222: #define m68k_setpc_fast m68k_setpc
                    223: #define m68k_setpc_bcc  m68k_setpc
                    224: #define m68k_setpc_rte  m68k_setpc
                    225: #endif
                    226: 
1.1.1.7   root      227: STATIC_INLINE void m68k_setstopped (int stop)
1.1       root      228: {
                    229:     regs.stopped = stop;
                    230:     if (stop)
                    231:        regs.spcflags |= SPCFLAG_STOP;
                    232: }
                    233: 
1.1.1.5   root      234: extern uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp);
                    235: extern uae_u32 get_disp_ea_000 (uae_u32 base, uae_u32 dp);
1.1       root      236: 
1.1.1.9   root      237: extern uae_s32 ShowEA (FILE *, int reg, amodes mode, wordsizes size, char *buf);
1.1.1.2   root      238: 
1.1.1.4   root      239: extern void MakeSR (void);
                    240: extern void MakeFromSR (void);
                    241: extern void Exception (int, uaecptr);
                    242: extern void dump_counts (void);
1.1.1.8   root      243: extern int m68k_move2c (int, uae_u32 *);
                    244: extern int m68k_movec2 (int, uae_u32 *);
1.1.1.3   root      245: extern void m68k_divl (uae_u32, uae_u32, uae_u16, uaecptr);
                    246: extern void m68k_mull (uae_u32, uae_u32, uae_u16);
1.1       root      247: extern void init_m68k (void);
1.1.1.4   root      248: extern void m68k_go (int);
1.1.1.9   root      249: extern void m68k_dumpstate (FILE *, uaecptr *);
                    250: extern void m68k_disasm (FILE *, uaecptr, uaecptr *, int);
1.1.1.4   root      251: extern void m68k_reset (void);
1.1.1.2   root      252: 
1.1.1.3   root      253: extern void mmu_op (uae_u32, uae_u16);
1.1.1.2   root      254: 
1.1.1.3   root      255: extern void fpp_opp (uae_u32, uae_u16);
                    256: extern void fdbcc_opp (uae_u32, uae_u16);
                    257: extern void fscc_opp (uae_u32, uae_u16);
                    258: extern void ftrapcc_opp (uae_u32,uaecptr);
                    259: extern void fbcc_opp (uae_u32, uaecptr, uae_u32);
                    260: extern void fsave_opp (uae_u32);
                    261: extern void frestore_opp (uae_u32);
                    262: 
                    263: /* Opcode of faulting instruction */
                    264: extern uae_u16 last_op_for_exception_3;
                    265: /* PC at fault time */
                    266: extern uaecptr last_addr_for_exception_3;
                    267: /* Address that generated the exception */
                    268: extern uaecptr last_fault_for_exception_3;
1.1       root      269: 
1.1.1.2   root      270: #define CPU_OP_NAME(a) op ## a
                    271: 
1.1.1.10  root      272: /* 68040 */
                    273: extern struct cputbl op_smalltbl_0_ff[];
1.1.1.3   root      274: /* 68020 + 68881 */
1.1.1.10  root      275: extern struct cputbl op_smalltbl_1_ff[];
1.1.1.3   root      276: /* 68020 */
1.1.1.10  root      277: extern struct cputbl op_smalltbl_2_ff[];
1.1.1.3   root      278: /* 68010 */
1.1.1.10  root      279: extern struct cputbl op_smalltbl_3_ff[];
1.1.1.3   root      280: /* 68000 */
1.1.1.10  root      281: extern struct cputbl op_smalltbl_4_ff[];
1.1.1.3   root      282: /* 68000 slow but compatible.  */
1.1.1.10  root      283: extern struct cputbl op_smalltbl_5_ff[];
1.1.1.3   root      284: 
                    285: extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl");
1.1.1.2   root      286: 
1.1.1.11! root      287: #ifdef JIT
        !           288: #else
        !           289: #define flush_icache(X) do {} while (0)
        !           290: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.