From 4e5860a07055d3dbc2e2c8b5c52e395db67fc963 Mon Sep 17 00:00:00 2001 From: sandeep Date: Mon, 20 Mar 2000 00:30:42 +0000 Subject: [PATCH] More AVR stuff git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@192 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCC.y | 1 + src/SDCCast.c | 2 +- src/SDCCglue.c | 2 +- src/SDCCicode.c | 6 +++--- src/SDCCsymt.c | 11 +++++++---- src/SDCCval.c | 4 ++-- src/avr/main.c | 1 + src/avr/ralloc.c | 3 +++ src/mcs51/main.c | 3 ++- src/port.h | 1 + src/z80/main.c | 3 ++- 11 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/SDCC.y b/src/SDCC.y index 66140dcc..6d10f0fe 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -31,6 +31,7 @@ #include "SDCCval.h" #include "SDCCmem.h" #include "SDCCast.h" + extern int yyerror (char *); extern FILE *yyin; extern char srcLstFname[]; diff --git a/src/SDCCast.c b/src/SDCCast.c index f2321e04..a67b3ba1 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1756,7 +1756,7 @@ ast *decorateType (ast *tree) } if (SPEC_SCLS(tree->left->etype) == S_CODE) { DCL_TYPE(p) = CPOINTER ; - DCL_PTR_CONST(p) = 1; + DCL_PTR_CONST(p) = port->mem.code_ro; } else if (SPEC_SCLS(tree->left->etype) == S_XDATA) diff --git a/src/SDCCglue.c b/src/SDCCglue.c index e512b0ed..43ab6992 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -214,7 +214,7 @@ value *initPointer (initList *ilist) val->type = newLink(); if (SPEC_SCLS(expr->left->etype) == S_CODE) { DCL_TYPE(val->type) = CPOINTER ; - DCL_PTR_CONST(val->type) = 1; + DCL_PTR_CONST(val->type) = port->mem.code_ro; } else if (SPEC_SCLS(expr->left->etype) == S_XDATA) diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 93d84027..1c8b6586 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1653,7 +1653,7 @@ link *aggrToPtr ( link *type, bool force) ptype->next = type; /* if the output class is generic */ if ((DCL_TYPE(ptype) = PTR_TYPE(SPEC_OCLS(etype))) == CPOINTER) - DCL_PTR_CONST(ptype) = 1; + DCL_PTR_CONST(ptype) = port->mem.code_ro; /* if the variable was declared a constant */ /* then the pointer points to a constant */ @@ -1676,7 +1676,7 @@ operand *geniCodeArray2Ptr (operand *op) /* set the pointer depending on the storage class */ if ((DCL_TYPE(optype) = PTR_TYPE(SPEC_OCLS(opetype))) == CPOINTER) - DCL_PTR_CONST(optype) = 1; + DCL_PTR_CONST(optype) = port->mem.code_ro; /* if the variable was declared a constant */ @@ -1943,7 +1943,7 @@ operand *geniCodeAddressOf (operand *op) /* set the pointer depending on the storage class */ if ((DCL_TYPE(p) = PTR_TYPE(SPEC_OCLS(opetype))) == CPOINTER) - DCL_PTR_CONST(p) = 1; + DCL_PTR_CONST(p) = port->mem.code_ro; /* make sure we preserve the const & volatile */ if (IS_CONSTANT(opetype)) diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index a1965efa..a6b711b8 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -293,7 +293,7 @@ void pointerTypes (link *ptr, link *type) DCL_TYPE(ptr) = POINTER ; break; case S_CODE: - DCL_PTR_CONST(ptr) = 1; + DCL_PTR_CONST(ptr) = port->mem.code_ro; DCL_TYPE(ptr) = CPOINTER ; break; case S_EEPROM: @@ -930,13 +930,15 @@ static void checkSClass ( symbol *sym ) /* global variables declared const put into code */ if (sym->level == 0 && - SPEC_SCLS(sym->etype) == S_CONSTANT) + SPEC_SCLS(sym->etype) == S_CONSTANT) { SPEC_SCLS(sym->etype) = S_CODE ; - + SPEC_CONST(sym->etype) = 1; + } /* global variable in code space is a constant */ if (sym->level == 0 && - SPEC_SCLS(sym->etype) == S_CODE) + SPEC_SCLS(sym->etype) == S_CODE && + port->mem.code_ro ) SPEC_CONST(sym->etype) = 1; @@ -1003,6 +1005,7 @@ static void checkSClass ( symbol *sym ) if (SPEC_SCLS(sym->etype) == S_CODE && sym->ival == NULL && !sym->level && + port->mem.code_ro && !IS_EXTERN(sym->etype)) werror(E_CODE_NO_INIT,sym->name); diff --git a/src/SDCCval.c b/src/SDCCval.c index c1dff719..daf3f930 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -1201,7 +1201,7 @@ value *valForArray (ast *arrExpr) val->type = newLink(); if (SPEC_SCLS(arrExpr->left->etype) == S_CODE) { DCL_TYPE(val->type) = CPOINTER ; - DCL_PTR_CONST(val->type) = 1; + DCL_PTR_CONST(val->type) = port->mem.code_ro; } else if (SPEC_SCLS(arrExpr->left->etype) == S_XDATA) @@ -1270,7 +1270,7 @@ value *valForStructElem(ast *structT, ast *elemT) val->type = newLink(); if (SPEC_SCLS(structT->etype) == S_CODE) { DCL_TYPE(val->type) = CPOINTER ; - DCL_PTR_CONST(val->type) = 1; + DCL_PTR_CONST(val->type) = port->mem.code_ro; } else if (SPEC_SCLS(structT->etype) == S_XDATA) diff --git a/src/avr/main.c b/src/avr/main.c index eb7eb3c6..4ec5e617 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -165,6 +165,7 @@ PORT avr_port = { "GSFINAL (CODE)", NULL, NULL, + 0, }, { -1, 1, 4, 1, 1 diff --git a/src/avr/ralloc.c b/src/avr/ralloc.c index ba73c2c0..f206c96c 100644 --- a/src/avr/ralloc.c +++ b/src/avr/ralloc.c @@ -1486,6 +1486,9 @@ static int packRegsForAssign (iCode *ic,eBBlock *ebp) return 0; } pack: + /* if in far space & tru symbol then don't */ + if ((IS_TRUE_SYM(IC_RESULT(ic))) && isOperandInFarSpace(IC_RESULT(ic))) + return 0; /* found the definition */ /* replace the result with the result of */ /* this assignment and remove this assignment */ diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 42a8c397..cc8b1bc5 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -221,7 +221,8 @@ PORT mcs51_port = { "OSEG (OVR,DATA)", "GSFINAL (CODE)", NULL, - NULL + NULL, + 1 }, { +1, 1, 4, 1, 1 diff --git a/src/port.h b/src/port.h index 18fd7660..65d4ba2b 100644 --- a/src/port.h +++ b/src/port.h @@ -72,6 +72,7 @@ typedef struct { const char *post_static_name; struct memmap *default_local_map ; /* default location for auto vars */ struct memmap *default_globl_map ; /* default location for globl vars*/ + int code_ro; /* code space read-only 1=yes */ } mem; /* stack related information */ diff --git a/src/z80/main.c b/src/z80/main.c index e8f4a968..bad1c014 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -121,7 +121,8 @@ PORT z80_port = { "_OVERLAY", "_GSFINAL", NULL, - NULL + NULL, + 1 }, { -1, 0, 0, 8, 0 -- 2.30.2