From: sandeep Date: Sun, 25 Jun 2000 02:26:46 +0000 (+0000) Subject: added "banked" for z80 port X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b8e8474afefb777794937a1acc5f49ba71019a58;p=fw%2Fsdcc added "banked" for z80 port git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@286 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCC.lex b/src/SDCC.lex index cd19d787..babc6261 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -117,6 +117,7 @@ struct options save_options ; "if" { count(); return(IF); } "int" { count(); return(INT); } "interrupt" { count(); return(INTERRUPT);} +"banked" { count(); TKEYWORD(BANKED);} "long" { count(); return(LONG); } "near" { count(); TKEYWORD(DATA);} "pdata" { count(); TKEYWORD(PDATA); } diff --git a/src/SDCC.y b/src/SDCC.y index 6d10f0fe..1d547ce8 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -77,7 +77,7 @@ value *cenum = NULL ; /* current enumeration type chain*/ %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN %token XOR_ASSIGN OR_ASSIGN %token TYPEDEF EXTERN STATIC AUTO REGISTER CODE EEPROM INTERRUPT SFR AT SBIT -%token REENTRANT USING XDATA DATA IDATA PDATA VAR_ARGS CRITICAL +%token REENTRANT USING XDATA DATA IDATA PDATA VAR_ARGS CRITICAL BANKED %token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID BIT %token STRUCT UNION ENUM ELIPSIS RANGE FAR _XDATA _CODE _GENERIC _NEAR _PDATA _IDATA _EEPROM %token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN @@ -165,6 +165,10 @@ using_reentrant_interrupt $$->class = SPECIFIER ; SPEC_CRTCL($$) = 1; } + | BANKED {$$ = newLink (); + $$->class = SPECIFIER ; + SPEC_BANKED($$) = 1; + } | Interrupt_storage { $$ = newLink () ; diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 437624a0..0c666cba 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -420,6 +420,7 @@ link *mergeSpec ( link *dest, link *src ) SPEC_BLEN(dest) |= SPEC_BLEN(src); SPEC_BSTR(dest) |= SPEC_BSTR(src); SPEC_TYPEDEF(dest) |= SPEC_TYPEDEF(src); + SPEC_BANKED(dest) |= SPEC_BANKED(src); if ( IS_STRUCT(dest) && SPEC_STRUCT(dest) == NULL ) SPEC_STRUCT(dest) = SPEC_STRUCT(src); diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 517c49e7..504609c6 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -101,6 +101,7 @@ typedef struct specifier { unsigned _typedef :1 ; /* is typedefed */ unsigned _isregparm:1 ; /* is the first parameter */ unsigned _isenum :1 ; /* is an enumerated type */ + unsigned banked :1 ; /* function has banked attribute */ unsigned _IntNo ; /* 1=Interrupt svc routine */ short _regbank ; /* register bank 2b used */ unsigned _addr ; /* address of symbol */ @@ -278,6 +279,7 @@ typedef struct symbol { #define SPEC_STRUCT(x) x->select.s.v_struct #define SPEC_TYPEDEF(x) x->select.s._typedef #define SPEC_REGPARM(x) x->select.s._isregparm +#define SPEC_BANKED(x) x->select.s.banked /* type check macros */ #define IS_DECL(x) ( x && x->class == DECLARATOR ) @@ -324,6 +326,7 @@ typedef struct symbol { #define IS_LITERAL(x) (IS_SPEC(x) && x->select.s.sclass == S_LITERAL) #define IS_ISR(x) (IS_SPEC(x) && SPEC_INTRTN(x)) #define IS_REGPARM(x) (IS_SPEC(x) && SPEC_REGPARM(x)) +#define IS_BANKED(x) (IS_SPEC(x) && SPEC_BANKED(x)) /* forward declaration for the global vars */ extern bucket *SymbolTab[] ; diff --git a/src/z80/gen.c b/src/z80/gen.c index e283cfe4..c0701734 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -1756,6 +1756,8 @@ static void emitCall(iCode *ic, bool ispcall) /*-----------------------------------------------------------------*/ static void genCall (iCode *ic) { + link *detype = getSpec(operandType(IC_LEFT(ic))); + if (IS_BANKED(detype)) emit2("; call to a banked function"); emitCall(ic, FALSE); } @@ -1798,12 +1800,13 @@ static void genFunction (iCode *ic) /* PENDING: portability. */ emit2("__%s_start:", sym->rname); emit2("!functionlabeldef", sym->rname); - + fetype = getSpec(operandType(IC_LEFT(ic))); - + /* if critical function then turn interrupts off */ if (SPEC_CRTCL(fetype)) emit2("!di"); + if (SPEC_BANKED(fetype)) emit2("; Iam banked"); /* if this is an interrupt service routine then save acc, b, dpl, dph */ diff --git a/src/z80/main.c b/src/z80/main.c index ee4fe7fc..24f8b2b9 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -20,6 +20,7 @@ static struct { static char *_keywords[] = { "sfr", + "banked", NULL };