|
|
1.1.1.5 ! root 1: /* 1.1 root 2: * UAE - The Un*x Amiga Emulator 1.1.1.5 ! root 3: * 1.1 root 4: * MC68000 emulation - machine dependent bits 5: * 6: * Copyright 1996 Bernd Schmidt 7: */ 8: 1.1.1.5 ! root 9: #if 0 1.1 root 10: struct flag_struct { 11: unsigned int c:1; /* first byte */ 12: int :5; 13: unsigned int z:1; 14: unsigned int n:1; 15: int :3; /* second, third & fourth byte */ 1.1.1.5 ! root 16: unsigned int v:1; 1.1 root 17: int :20; 18: unsigned int x:1; /* fifth */ 19: int :31; 20: }; 21: 22: #define ZFLG (regflags.z) 23: #define NFLG (regflags.n) 24: #define CFLG (regflags.c) 25: #define VFLG (regflags.v) 26: #define XFLG (regflags.x) 27: 1.1.1.3 root 28: #else 29: 30: struct flag_struct { 31: unsigned int cznv; 32: unsigned int x; 33: }; 34: 1.1.1.4 root 35: #define FLAGVAL_Z 0x40 36: #define FLAGVAL_N 0x80 37: 1.1.1.3 root 38: #define SET_ZFLG(y) (regflags.cznv = (regflags.cznv & ~0x40) | (((y) & 1) << 6)) 39: #define SET_CFLG(y) (regflags.cznv = (regflags.cznv & ~1) | ((y) & 1)) 40: #define SET_VFLG(y) (regflags.cznv = (regflags.cznv & ~0x800) | (((y) & 1) << 11)) 41: #define SET_NFLG(y) (regflags.cznv = (regflags.cznv & ~0x80) | (((y) & 1) << 7)) 42: #define SET_XFLG(y) (regflags.x = (y)) 43: 44: #define GET_ZFLG ((regflags.cznv >> 6) & 1) 45: #define GET_CFLG (regflags.cznv & 1) 46: #define GET_VFLG ((regflags.cznv >> 11) & 1) 47: #define GET_NFLG ((regflags.cznv >> 7) & 1) 48: #define GET_XFLG (regflags.x & 1) 49: 50: #define CLEAR_CZNV (regflags.cznv = 0) 1.1.1.4 root 51: #define GET_CZNV (regflags.cznv) 52: #define IOR_CZNV(X) (regflags.cznv |= (X)) 53: #define SET_CZNV(X) (regflags.cznv = (X)) 54: 1.1.1.3 root 55: #define COPY_CARRY (regflags.x = regflags.cznv) 56: 1.1.1.4 root 57: 1.1.1.3 root 58: #endif 59: 60: extern struct flag_struct regflags __asm__ ("regflags"); 61: 62: static __inline__ int cctrue(int cc) 1.1 root 63: { 1.1.1.3 root 64: uae_u32 cznv = regflags.cznv; 1.1 root 65: switch(cc){ 66: case 0: return 1; /* T */ 67: case 1: return 0; /* F */ 1.1.1.3 root 68: case 2: return (cznv & 0x41) == 0; /* !GET_CFLG && !GET_ZFLG; HI */ 69: case 3: return (cznv & 0x41) != 0; /* GET_CFLG || GET_ZFLG; LS */ 70: case 4: return (cznv & 1) == 0; /* !GET_CFLG; CC */ 71: case 5: return (cznv & 1) != 0; /* GET_CFLG; CS */ 72: case 6: return (cznv & 0x40) == 0; /* !GET_ZFLG; NE */ 73: case 7: return (cznv & 0x40) != 0; /* GET_ZFLG; EQ */ 74: case 8: return (cznv & 0x800) == 0;/* !GET_VFLG; VC */ 75: case 9: return (cznv & 0x800) != 0;/* GET_VFLG; VS */ 76: case 10:return (cznv & 0x80) == 0; /* !GET_NFLG; PL */ 77: case 11:return (cznv & 0x80) != 0; /* GET_NFLG; MI */ 78: case 12:return (((cznv << 4) ^ cznv) & 0x800) == 0; /* GET_NFLG == GET_VFLG; GE */ 79: case 13:return (((cznv << 4) ^ cznv) & 0x800) != 0;/* GET_NFLG != GET_VFLG; LT */ 80: case 14: 81: cznv &= 0x8c0; 82: return (((cznv << 4) ^ cznv) & 0x840) == 0; /* !GET_ZFLG && (GET_NFLG == GET_VFLG); GT */ 83: case 15: 84: cznv &= 0x8c0; 85: return (((cznv << 4) ^ cznv) & 0x840) != 0; /* GET_ZFLG || (GET_NFLG != GET_VFLG); LE */ 1.1 root 86: } 87: abort(); 88: return 0; 89: } 90: 1.1.1.4 root 91: #define optflag_testl(v) \ 1.1.1.2 root 92: __asm__ __volatile__ ("testl %1,%1\n\t" \ 93: "pushfl\n\t" \ 94: "popl %0\n\t" \ 1.1.1.3 root 95: : "=r" (regflags.cznv) : "r" (v) : "cc") 1.1.1.2 root 96: 1.1.1.4 root 97: #define optflag_testw(v) \ 1.1.1.2 root 98: __asm__ __volatile__ ("testw %w1,%w1\n\t" \ 99: "pushfl\n\t" \ 100: "popl %0\n\t" \ 1.1.1.3 root 101: : "=r" (regflags.cznv) : "r" (v) : "cc") 1.1.1.2 root 102: 1.1.1.4 root 103: #define optflag_testb(v) \ 1.1.1.2 root 104: __asm__ __volatile__ ("testb %b1,%b1\n\t" \ 105: "pushfl\n\t" \ 106: "popl %0\n\t" \ 1.1.1.3 root 107: : "=r" (regflags.cznv) : "q" (v) : "cc") 1.1.1.2 root 108: 1.1.1.4 root 109: #define optflag_addl(v, s, d) do { \ 1.1.1.2 root 110: __asm__ __volatile__ ("addl %k2,%k1\n\t" \ 111: "pushfl\n\t" \ 112: "popl %0\n\t" \ 1.1.1.3 root 113: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ 114: COPY_CARRY; \ 115: } while (0) 1.1.1.4 root 116: #define optflag_addw(v, s, d) do { \ 1.1.1.2 root 117: __asm__ __volatile__ ("addw %w2,%w1\n\t" \ 118: "pushfl\n\t" \ 119: "popl %0\n\t" \ 1.1.1.3 root 120: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ 121: COPY_CARRY; \ 122: } while (0) 1.1.1.2 root 123: 1.1.1.4 root 124: #define optflag_addb(v, s, d) do { \ 1.1.1.2 root 125: __asm__ __volatile__ ("addb %b2,%b1\n\t" \ 126: "pushfl\n\t" \ 127: "popl %0\n\t" \ 1.1.1.3 root 128: : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \ 129: COPY_CARRY; \ 130: } while (0) 1.1.1.2 root 131: 1.1.1.4 root 132: #define optflag_subl(v, s, d) do { \ 1.1.1.2 root 133: __asm__ __volatile__ ("subl %k2,%k1\n\t" \ 134: "pushfl\n\t" \ 135: "popl %0\n\t" \ 1.1.1.3 root 136: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ 137: COPY_CARRY; \ 138: } while (0) 1.1.1.2 root 139: 1.1.1.4 root 140: #define optflag_subw(v, s, d) do { \ 1.1.1.2 root 141: __asm__ __volatile__ ("subw %w2,%w1\n\t" \ 142: "pushfl\n\t" \ 143: "popl %0\n\t" \ 1.1.1.3 root 144: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ 145: COPY_CARRY; \ 146: } while (0) 1.1.1.2 root 147: 1.1.1.4 root 148: #define optflag_subb(v, s, d) do { \ 1.1.1.2 root 149: __asm__ __volatile__ ("subb %b2,%b1\n\t" \ 150: "pushfl\n\t" \ 151: "popl %0\n\t" \ 1.1.1.3 root 152: : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \ 153: COPY_CARRY; \ 154: } while (0) 1.1.1.2 root 155: 1.1.1.4 root 156: #define optflag_cmpl(s, d) \ 1.1.1.2 root 157: __asm__ __volatile__ ("cmpl %k1,%k2\n\t" \ 158: "pushfl\n\t" \ 159: "popl %0\n\t" \ 1.1.1.3 root 160: : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc") 1.1.1.2 root 161: 1.1.1.4 root 162: #define optflag_cmpw(s, d) \ 1.1.1.2 root 163: __asm__ __volatile__ ("cmpw %w1,%w2\n\t" \ 164: "pushfl\n\t" \ 165: "popl %0\n\t" \ 1.1.1.3 root 166: : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc") 1.1.1.2 root 167: 1.1.1.4 root 168: #define optflag_cmpb(s, d) \ 1.1.1.2 root 169: __asm__ __volatile__ ("cmpb %b1,%b2\n\t" \ 170: "pushfl\n\t" \ 171: "popl %0\n\t" \ 1.1.1.3 root 172: : "=r" (regflags.cznv) : "qmi" (s), "q" (d) : "cc") 1.1.1.2 root 173:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.