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