Annotation of uae/src/md-amd64-gcc/m68k.h, revision 1.1.1.1

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: struct flag_struct {
                     10:     unsigned int cznv;
                     11:     unsigned int x;
                     12: };
                     13: 
                     14: #define FLAGVAL_Z 0x40
                     15: #define FLAGVAL_N 0x80
                     16: 
                     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)
                     30: #define GET_CZNV (regflags.cznv)
                     31: #define IOR_CZNV(X) (regflags.cznv |= (X))
                     32: #define SET_CZNV(X) (regflags.cznv = (X))
                     33: 
                     34: #define COPY_CARRY (regflags.x = regflags.cznv)
                     35: 
                     36: 
                     37: extern struct flag_struct regflags __asm__ ("regflags");
                     38: 
                     39: static __inline__ int cctrue(int cc)
                     40: {
                     41:     uae_u32 cznv = regflags.cznv;
                     42:     switch(cc){
                     43:      case 0: return 1;                       /* T */
                     44:      case 1: return 0;                       /* F */
                     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 */
                     63:     }
                     64:     abort();
                     65:     return 0;
                     66: }
                     67: 
                     68: #define optflag_testl(v) \
                     69:   __asm__ __volatile__ ("testl %1,%1\n\t" \
                     70:                        "pushfl\n\t" \
                     71:                        "popl %0\n\t" \
                     72:                        : "=r" (regflags.cznv) : "r" (v) : "cc")
                     73: 
                     74: #define optflag_testw(v) \
                     75:   __asm__ __volatile__ ("testw %w1,%w1\n\t" \
                     76:                        "pushfl\n\t" \
                     77:                        "popl %0\n\t" \
                     78:                        : "=r" (regflags.cznv) : "r" (v) : "cc")
                     79: 
                     80: #define optflag_testb(v) \
                     81:   __asm__ __volatile__ ("testb %b1,%b1\n\t" \
                     82:                        "pushfl\n\t" \
                     83:                        "popl %0\n\t" \
                     84:                        : "=r" (regflags.cznv) : "q" (v) : "cc")
                     85: 
                     86: #define optflag_addl(v, s, d) do { \
                     87:   __asm__ __volatile__ ("addl %k2,%k1\n\t" \
                     88:                        "pushfl\n\t" \
                     89:                        "popl %0\n\t" \
                     90:                        : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \
                     91:     COPY_CARRY; \
                     92:     } while (0)
                     93: #define optflag_addw(v, s, d) do { \
                     94:   __asm__ __volatile__ ("addw %w2,%w1\n\t" \
                     95:                        "pushfl\n\t" \
                     96:                        "popl %0\n\t" \
                     97:                        : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \
                     98:     COPY_CARRY; \
                     99:     } while (0)
                    100: 
                    101: #define optflag_addb(v, s, d) do { \
                    102:   __asm__ __volatile__ ("addb %b2,%b1\n\t" \
                    103:                        "pushfl\n\t" \
                    104:                        "popl %0\n\t" \
                    105:                        : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \
                    106:     COPY_CARRY; \
                    107:     } while (0)
                    108: 
                    109: #define optflag_subl(v, s, d) do { \
                    110:   __asm__ __volatile__ ("subl %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: 
                    117: #define optflag_subw(v, s, d) do { \
                    118:   __asm__ __volatile__ ("subw %w2,%w1\n\t" \
                    119:                        "pushfl\n\t" \
                    120:                        "popl %0\n\t" \
                    121:                        : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \
                    122:     COPY_CARRY; \
                    123:     } while (0)
                    124: 
                    125: #define optflag_subb(v, s, d) do { \
                    126:   __asm__ __volatile__ ("subb %b2,%b1\n\t" \
                    127:                        "pushfl\n\t" \
                    128:                        "popl %0\n\t" \
                    129:                        : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \
                    130:     COPY_CARRY; \
                    131:     } while (0)
                    132: 
                    133: #define optflag_cmpl(s, d) \
                    134:   __asm__ __volatile__ ("cmpl %k1,%k2\n\t" \
                    135:                        "pushfl\n\t" \
                    136:                        "popl %0\n\t" \
                    137:                        : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc")
                    138: 
                    139: #define optflag_cmpw(s, d) \
                    140:   __asm__ __volatile__ ("cmpw %w1,%w2\n\t" \
                    141:                        "pushfl\n\t" \
                    142:                        "popl %0\n\t" \
                    143:                        : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc")
                    144: 
                    145: #define optflag_cmpb(s, d) \
                    146:   __asm__ __volatile__ ("cmpb %b1,%b2\n\t" \
                    147:                        "pushfl\n\t" \
                    148:                        "popl %0\n\t" \
                    149:                        : "=r" (regflags.cznv) : "qmi" (s), "q" (d) : "cc")
                    150: 

unix.superglobalmegacorp.com

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