Annotation of MiNT/src/inline.h, revision 1.1.1.4

1.1       root        1: /*
                      2: 
1.1.1.2   root        3: Copyright 1992 Eric R. Smith.
                      4: 
1.1.1.3   root        5: Copyright 1993 Atari Corporation.
                      6: 
1.1.1.2   root        7: All rights reserved.
1.1       root        8: 
                      9:  */
                     10: 
                     11: 
                     12: 
                     13: /*
                     14: 
                     15:  * inlining of various utility functions, for speed
                     16: 
                     17:  * NOTE: ALL functions in this file must also have
                     18: 
                     19:  * "normal" equivalents in the .c or .s files;
                     20: 
                     21:  * don't put a function just into here!
                     22: 
                     23:  */
                     24: 
                     25: 
                     26: 
                     27: #ifdef __GNUC__
                     28: 
                     29: 
                     30: 
                     31: #define spl7()                 \
                     32: 
                     33: ({  register short retvalue;   \
                     34: 
                     35:     __asm__ volatile("         \
                     36: 
                     37:        movew sr,%0;            \
                     38: 
                     39:        oriw  #0x0700,sr "      \
                     40: 
1.1.1.2   root       41:     : "=d"(retvalue)           \
1.1       root       42: 
                     43:     ); retvalue; })
                     44: 
                     45: 
                     46: 
                     47: #define spl(N)                 \
                     48: 
                     49: ({                             \
                     50: 
                     51:     __asm__ volatile("         \
                     52: 
                     53:        movew %0,sr "           \
                     54: 
                     55:     :                          \
                     56: 
1.1.1.2   root       57:     : "d"(N) ); })
1.1       root       58: 
                     59: 
                     60: 
                     61: 
                     62: 
                     63: /*
                     64: 
                     65:  * note that we must save some registers ourselves,
                     66: 
                     67:  * or else gcc will run out of reggies to use
                     68: 
                     69:  * and complain
                     70: 
                     71:  */
                     72: 
                     73: 
                     74: 
1.1.1.4 ! root       75: /* On TOS 1.04, when calling Bconout(2,'\a') the VDI jumps directly
        !            76: 
        !            77:    back to the BIOS which expects the register A5 to be set to zero.
        !            78: 
        !            79:    (Specifying the register as clobbered does not work.) */
        !            80: 
        !            81: 
        !            82: 
1.1       root       83: #define callout1(func, a)                      \
                     84: 
                     85: ({                                             \
                     86: 
                     87:        register long retvalue __asm__("d0");   \
                     88: 
                     89:        long _f = func;                         \
                     90: 
                     91:        short _a = (short)(a);                  \
                     92: 
                     93:                                                \
                     94: 
                     95:        __asm__ volatile                        \
                     96: 
                     97:        ("  moveml d5-d7/a4-a6,sp@-;            \
                     98: 
                     99:            movew %2,sp@-;                      \
                    100: 
1.1.1.4 ! root      101:            movel %1,a0;                        \
        !           102: 
        !           103:            subal a5,a5;                        \
        !           104: 
        !           105:            jsr a0@;                            \
1.1       root      106: 
                    107:            addqw #2,sp;                        \
                    108: 
                    109:            moveml sp@+,d5-d7/a4-a6 "           \
                    110: 
                    111:        : "=r"(retvalue)        /* outputs */   \
                    112: 
1.1.1.4 ! root      113:        : "r"(_f), "r"(_a)      /* inputs */    \
1.1       root      114: 
                    115:        : "d0", "d1", "d2", "d3", "d4",         \
                    116: 
                    117:          "a0", "a1", "a2", "a3" /* clobbered regs */ \
                    118: 
                    119:        );                                      \
                    120: 
                    121:        retvalue;                               \
                    122: 
                    123: })
                    124: 
                    125: 
                    126: 
1.1.1.4 ! root      127: 
        !           128: 
1.1       root      129: #define callout2(func, a, b)                   \
                    130: 
                    131: ({                                             \
                    132: 
                    133:        register long retvalue __asm__("d0");   \
                    134: 
                    135:        long _f = func;                         \
                    136: 
                    137:        short _a = (short)(a);                  \
                    138: 
                    139:        short _b = (short)(b);                  \
                    140: 
                    141:                                                \
                    142: 
                    143:        __asm__ volatile                        \
                    144: 
                    145:        ("  moveml d5-d7/a4-a6,sp@-;            \
                    146: 
                    147:            movew %3,sp@-;                      \
                    148: 
                    149:            movew %2,sp@-;                      \
                    150: 
1.1.1.4 ! root      151:            movel %1,a0;
        !           152: 
        !           153:            subal a5,a5;                        \
        !           154: 
        !           155:            jsr a0@;                            \
1.1       root      156: 
                    157:            addqw #4,sp;                        \
                    158: 
                    159:            moveml sp@+,d5-d7/a4-a6 "           \
                    160: 
                    161:        : "=r"(retvalue)        /* outputs */   \
                    162: 
1.1.1.4 ! root      163:        : "r"(_f), "r"(_a), "r"(_b) /* inputs */ \
1.1       root      164: 
                    165:        : "d0", "d1", "d2", "d3", "d4",         \
                    166: 
                    167:          "a0", "a1", "a2", "a3" /* clobbered regs */ \
                    168: 
                    169:        );                                      \
                    170: 
                    171:        retvalue;                               \
                    172: 
                    173: })
                    174: 
                    175: 
                    176: 
1.1.1.3   root      177: #define flush_pmmu() __asm__ volatile("pflusha");
                    178: 
1.1       root      179: #endif
                    180: 
                    181: 
                    182: 
                    183: #ifdef LATTICE
                    184: 
                    185: #pragma inline d0=spl7()       {"40c0007c0700";}
                    186: 
                    187: #pragma inline d0=spl(d0)      {"46c0";}
                    188: 
                    189: #endif
                    190: 

unix.superglobalmegacorp.com

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