|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * MC68000 emulation - machine dependent bits ! 5: * ! 6: * Copyright 1996 Bernd Schmidt ! 7: */ ! 8: ! 9: #if 0 ! 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 */ ! 16: unsigned int v:1; ! 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: ! 28: #else ! 29: ! 30: struct flag_struct { ! 31: unsigned int cznv; ! 32: unsigned int x; ! 33: }; ! 34: ! 35: #define FLAGVAL_Z 0x40 ! 36: #define FLAGVAL_N 0x80 ! 37: ! 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) ! 51: #define GET_CZNV (regflags.cznv) ! 52: #define IOR_CZNV(X) (regflags.cznv |= (X)) ! 53: #define SET_CZNV(X) (regflags.cznv = (X)) ! 54: ! 55: #define COPY_CARRY (regflags.x = regflags.cznv) ! 56: ! 57: ! 58: #endif ! 59: ! 60: extern struct flag_struct regflags __asm__ ("regflags"); ! 61: ! 62: static __inline__ int cctrue(int cc) ! 63: { ! 64: uae_u32 cznv = regflags.cznv; ! 65: switch(cc){ ! 66: case 0: return 1; /* T */ ! 67: case 1: return 0; /* F */ ! 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 */ ! 86: } ! 87: abort(); ! 88: return 0; ! 89: } ! 90: ! 91: #define optflag_testl(v) \ ! 92: __asm__ __volatile__ ("testl %1,%1\n\t" \ ! 93: "pushfl\n\t" \ ! 94: "popl %0\n\t" \ ! 95: : "=r" (regflags.cznv) : "r" (v) : "cc") ! 96: ! 97: #define optflag_testw(v) \ ! 98: __asm__ __volatile__ ("testw %w1,%w1\n\t" \ ! 99: "pushfl\n\t" \ ! 100: "popl %0\n\t" \ ! 101: : "=r" (regflags.cznv) : "r" (v) : "cc") ! 102: ! 103: #define optflag_testb(v) \ ! 104: __asm__ __volatile__ ("testb %b1,%b1\n\t" \ ! 105: "pushfl\n\t" \ ! 106: "popl %0\n\t" \ ! 107: : "=r" (regflags.cznv) : "q" (v) : "cc") ! 108: ! 109: #define optflag_addl(v, s, d) do { \ ! 110: __asm__ __volatile__ ("addl %k2,%k1\n\t" \ ! 111: "pushfl\n\t" \ ! 112: "popl %0\n\t" \ ! 113: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ ! 114: COPY_CARRY; \ ! 115: } while (0) ! 116: #define optflag_addw(v, s, d) do { \ ! 117: __asm__ __volatile__ ("addw %w2,%w1\n\t" \ ! 118: "pushfl\n\t" \ ! 119: "popl %0\n\t" \ ! 120: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ ! 121: COPY_CARRY; \ ! 122: } while (0) ! 123: ! 124: #define optflag_addb(v, s, d) do { \ ! 125: __asm__ __volatile__ ("addb %b2,%b1\n\t" \ ! 126: "pushfl\n\t" \ ! 127: "popl %0\n\t" \ ! 128: : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \ ! 129: COPY_CARRY; \ ! 130: } while (0) ! 131: ! 132: #define optflag_subl(v, s, d) do { \ ! 133: __asm__ __volatile__ ("subl %k2,%k1\n\t" \ ! 134: "pushfl\n\t" \ ! 135: "popl %0\n\t" \ ! 136: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ ! 137: COPY_CARRY; \ ! 138: } while (0) ! 139: ! 140: #define optflag_subw(v, s, d) do { \ ! 141: __asm__ __volatile__ ("subw %w2,%w1\n\t" \ ! 142: "pushfl\n\t" \ ! 143: "popl %0\n\t" \ ! 144: : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \ ! 145: COPY_CARRY; \ ! 146: } while (0) ! 147: ! 148: #define optflag_subb(v, s, d) do { \ ! 149: __asm__ __volatile__ ("subb %b2,%b1\n\t" \ ! 150: "pushfl\n\t" \ ! 151: "popl %0\n\t" \ ! 152: : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \ ! 153: COPY_CARRY; \ ! 154: } while (0) ! 155: ! 156: #define optflag_cmpl(s, d) \ ! 157: __asm__ __volatile__ ("cmpl %k1,%k2\n\t" \ ! 158: "pushfl\n\t" \ ! 159: "popl %0\n\t" \ ! 160: : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc") ! 161: ! 162: #define optflag_cmpw(s, d) \ ! 163: __asm__ __volatile__ ("cmpw %w1,%w2\n\t" \ ! 164: "pushfl\n\t" \ ! 165: "popl %0\n\t" \ ! 166: : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc") ! 167: ! 168: #define optflag_cmpb(s, d) \ ! 169: __asm__ __volatile__ ("cmpb %b1,%b2\n\t" \ ! 170: "pushfl\n\t" \ ! 171: "popl %0\n\t" \ ! 172: : "=r" (regflags.cznv) : "qmi" (s), "q" (d) : "cc") ! 173:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.