Annotation of gforth/386.h, revision 1.10

1.1       anton       1: /*
                      2:   Copyright 1992 by the ANSI figForth Development Group
                      3: 
                      4:   This is the machine-specific part for Intel 386 compatible processors
                      5: */
                      6: 
1.7       anton       7: #include "32bit.h"
1.1       anton       8: 
1.7       anton       9: /* indirect threading is faster on the 486, on the 386 direct
                     10:    threading is probably faster. Therefore we leave defining
                     11:    DIRECT_THREADED to configure */
1.1       anton      12: 
1.3       anton      13: /* define this if the processor cannot exploit instruction-level
1.4       anton      14:    parallelism (no pipelining or too few registers) */
1.3       anton      15: #define CISC_NEXT
                     16: 
1.9       anton      17: /* 386 and below have no cache, 486 has a shared cache, and the
                     18:    Pentium probably employs hardware cache consistency, so
                     19:    flush-icache is a noop */
1.10    ! pazsan     20: #define FLUSH_ICACHE(addr,size)
1.9       anton      21: 
1.1       anton      22: #ifdef DIRECT_THREADED
1.10    ! pazsan     23: 
        !            24: #define CALL 0xe8 /* call */
        !            25: #define JMP  0xe9 /* jmp  */
        !            26: #define GETCFA(reg)  ({ asm("popl %0" : "=r" (reg)); (int)reg -= 5;});
        !            27: 
1.1       anton      28: /* PFA gives the parameter field address corresponding to a cfa */
                     29: #define PFA(cfa)       (((Cell *)cfa)+2)
                     30: /* PFA1 is a special version for use just after a NEXT1 */
                     31: #define PFA1(cfa)      PFA(cfa)
                     32: /* CODE_ADDRESS is the address of the code jumped to through the code field */
1.2       pazsan     33: #define CODE_ADDRESS(cfa) \
1.5       anton      34:     ({long _cfa = (long)(cfa); (Label)(_cfa+*((long *)(_cfa+1))+5);})
1.1       anton      35: /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
1.2       pazsan     36: #define MAKE_CF(cfa,ca)        ({long _cfa = (long)(cfa); \
                     37:                           long _ca  = (long)(ca); \
1.10    ! pazsan     38:                          *(char *)_cfa = CALL; \
1.2       pazsan     39:                          *(long *)(_cfa+1) = _ca-(_cfa+5);})
1.1       anton      40: 
                     41: /* this is the point where the does code starts if label points to the
                     42:  * jump dodoes */
1.2       pazsan     43: #define DOES_HANDLER_SIZE       8
                     44: #define DOES_CODE(label)       ((Xt *)(CODE_ADDRESS(label)+DOES_HANDLER_SIZE))
1.1       anton      45: 
                     46: /* this is a special version of DOES_CODE for use in dodoes */
                     47: #define DOES_CODE1(label)      DOES_CODE(label)
                     48: 
                     49: /* this stores a jump dodoes at addr */
1.10    ! pazsan     50: #define MAKE_DOES_CF(addr,doesp)       ({long _addr = (long)(addr); \
        !            51:                           long _doesp  = (long)(doesp)-8; \
        !            52:                          *(char *)_addr = CALL; \
        !            53:                          *(long *)(_addr+1) = _doesp-(_addr+5);})
        !            54: 
        !            55: #define MAKE_DOES_HANDLER(addr)        ({long _addr = (long)(addr); \
        !            56:                           long _dodo  = (long)symbols[DODOES]; \
        !            57:                          *(char *)_addr = JMP; \
        !            58:                          *(long *)(_addr+1) = _dodo-(_addr+5);})
1.1       anton      59: #endif
1.4       anton      60: 
                     61: #ifdef FORCE_REG
1.8       anton      62: #if (__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__==5)
                     63: /* i.e. gcc-2.5.x */
                     64: /* this works with 2.5.7; nothing works with 2.5.8 */
1.4       anton      65: #define IPREG asm("%esi")
                     66: #define SPREG asm("%edi")
                     67: #ifdef USE_TOS
                     68: #define CFAREG asm("%ecx")
                     69: #else
                     70: #define CFAREG asm("%edx")
                     71: #endif
1.8       anton      72: #else /* gcc-version */
                     73: /* this works with 2.6.3 (and quite well, too) */
                     74: /* since this is not very demanding, it's the default for other gcc versions */
1.10    ! pazsan     75: #if defined(USE_TOS) && !defined(CFA_NEXT)
        !            76: #define IPREG asm("%ebx")
        !            77: #else
1.8       anton      78: #define SPREG asm("%ebx")
1.10    ! pazsan     79: #endif /* USE_TOS && !CFA_NEXT */
1.8       anton      80: #endif /* gcc-version */
1.4       anton      81: #endif /* FORCE_REG */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>