Annotation of gforth/arch/386/machine.h, revision 1.9

1.1       anton       1: /*
                      2:   This is the machine-specific part for Intel 386 compatible processors
                      3: 
1.5       anton       4:   Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
1.1       anton       5: 
                      6:   This file is part of Gforth.
                      7: 
                      8:   Gforth is free software; you can redistribute it and/or
                      9:   modify it under the terms of the GNU General Public License
                     10:   as published by the Free Software Foundation; either version 2
                     11:   of the License, or (at your option) any later version.
                     12: 
                     13:   This program is distributed in the hope that it will be useful,
                     14:   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     15:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     16:   GNU General Public License for more details.
                     17: 
                     18:   You should have received a copy of the GNU General Public License
                     19:   along with this program; if not, write to the Free Software
                     20:   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     21: */
                     22: 
1.4       pazsan     23: #ifdef HAVE_LIBKERNEL32
                     24: #ifdef i386
                     25: #define SYSCALL     __attribute__ ((stdcall))
                     26: #endif
                     27: #endif
                     28: 
1.6       anton      29: #ifndef THREADING_SCHEME
                     30: #define THREADING_SCHEME 8
                     31: #endif
1.7       anton      32: 
1.9     ! pazsan     33: #if ((__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__>=95) || (__GNUC__>2))
1.8       pazsan     34: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
                     35: #define USE_TOS
1.9     ! pazsan     36: #endif
        !            37: #endif
1.8       pazsan     38: #define MEMCMP_AS_SUBROUTINE 1
                     39: 
1.7       anton      40: #include "../generic/machine.h"
1.6       anton      41: 
                     42: /* indirect threading is faster on the Pentium, on the 486 direct
                     43:    threading is faster. Therefore we leave defining
1.1       anton      44:    DIRECT_THREADED to configure */
                     45: 
                     46: /* define this if the processor cannot exploit instruction-level
                     47:    parallelism (no pipelining or too few registers) */
                     48: #define CISC_NEXT
                     49: 
                     50: /* 386 and below have no cache, 486 has a shared cache, and the
                     51:    Pentium probably employs hardware cache consistency, so
                     52:    flush-icache is a noop */
                     53: #define FLUSH_ICACHE(addr,size)
                     54: 
                     55: #ifdef DIRECT_THREADED
                     56: 
                     57: #define CALL 0xe8 /* call */
                     58: #define JMP  0xe9 /* jmp  */
                     59: #define GETCFA(reg)  ({ asm("popl %0" : "=r" (reg)); (int)reg -= 5;});
                     60: 
                     61: /* PFA gives the parameter field address corresponding to a cfa */
                     62: #define PFA(cfa)       (((Cell *)cfa)+2)
                     63: /* PFA1 is a special version for use just after a NEXT1 */
                     64: #define PFA1(cfa)      PFA(cfa)
                     65: /* CODE_ADDRESS is the address of the code jumped to through the code field */
                     66: #define CODE_ADDRESS(cfa) \
                     67:     ({long _cfa = (long)(cfa); (Label)(_cfa+*((long *)(_cfa+1))+5);})
                     68: /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
                     69: #define MAKE_CF(cfa,ca)        ({long _cfa = (long)(cfa); \
                     70:                           long _ca  = (long)(ca); \
                     71:                          *(char *)_cfa = CALL; \
                     72:                          *(long *)(_cfa+1) = _ca-(_cfa+5);})
                     73: 
                     74: /* this is the point where the does code starts if label points to the
                     75:  * jump dodoes */
                     76: #define DOES_CODE(xt) \
                     77: ({ long _xt = (long)(xt); \
                     78:    long _ca = (long)(CODE_ADDRESS(_xt)); \
                     79:    ((((*(unsigned char *)_xt) == CALL) \
                     80:      && ((*(unsigned char *)_ca) == JMP) \
                     81:      && ((long)(CODE_ADDRESS(_ca)) == (long)&&dodoes)) \
                     82:     ? _ca+DOES_HANDLER_SIZE : 0L); })
                     83: 
                     84: /* this is a special version of DOES_CODE for use in dodoes */
                     85: #define DOES_CODE1(label)      (CODE_ADDRESS(label)+DOES_HANDLER_SIZE)
                     86: 
                     87: /* this stores a jump dodoes at addr */
                     88: #define MAKE_DOES_CF(addr,doesp)       ({long _addr = (long)(addr); \
                     89:                           long _doesp  = (long)(doesp)-8; \
                     90:                          *(char *)_addr = CALL; \
                     91:                          *(long *)(_addr+1) = _doesp-(_addr+5);})
                     92: 
                     93: #define MAKE_DOES_HANDLER(addr)        ({long _addr = (long)(addr); \
                     94:                           long _dodo  = (long)symbols[DODOES]; \
                     95:                          *(char *)_addr = JMP; \
                     96:                          *(long *)(_addr+1) = _dodo-(_addr+5);})
                     97: #endif
                     98: 
                     99: #ifdef FORCE_REG
                    100: #if (__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__==5)
                    101: /* i.e. gcc-2.5.x */
                    102: /* this works with 2.5.7; nothing works with 2.5.8 */
                    103: #define IPREG asm("%esi")
                    104: #define SPREG asm("%edi")
                    105: #ifdef USE_TOS
                    106: #define CFAREG asm("%ecx")
                    107: #else
                    108: #define CFAREG asm("%edx")
                    109: #endif
                    110: #else /* gcc-version */
                    111: /* this works with 2.6.3 (and quite well, too) */
                    112: /* since this is not very demanding, it's the default for other gcc versions */
                    113: #if defined(USE_TOS) && !defined(CFA_NEXT)
1.8       pazsan    114: #if ((__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__>=95) || (__GNUC__>2))
                    115:      /* gcc 2.95 has a better register allocater */
                    116: #define SPREG asm("%esi")
                    117: #define RPREG asm("%edi")
                    118: #define TOSREG asm("%ebx")
                    119: #else
1.1       anton     120: #define IPREG asm("%ebx")
1.8       pazsan    121: #endif
1.1       anton     122: #else
1.9     ! pazsan    123: #if ((__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__>=95) || (__GNUC__>2))
        !           124: #define SPREG asm("%esi")
        !           125: #define RPREG asm("%edi")
        !           126: #else
1.1       anton     127: #define SPREG asm("%ebx")
1.9     ! pazsan    128: #endif
1.1       anton     129: #endif /* USE_TOS && !CFA_NEXT */
                    130: #endif /* gcc-version */
                    131: #endif /* FORCE_REG */
1.2       pazsan    132: 
                    133: /* #define ALIGNMENT_CHECK 1 */

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