More AVR stuff
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 20 Mar 2000 00:30:42 +0000 (00:30 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 20 Mar 2000 00:30:42 +0000 (00:30 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@192 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCC.y
src/SDCCast.c
src/SDCCglue.c
src/SDCCicode.c
src/SDCCsymt.c
src/SDCCval.c
src/avr/main.c
src/avr/ralloc.c
src/mcs51/main.c
src/port.h
src/z80/main.c

index 66140dcc5b63846ecd3ba2c6a98fcee926171b84..6d10f0fe4ac07ad130f2587fa1dfe7a9f917182d 100644 (file)
@@ -31,6 +31,7 @@
 #include "SDCCval.h"
 #include "SDCCmem.h"
 #include "SDCCast.h"
+
 extern int yyerror (char *);
 extern FILE    *yyin;
 extern char srcLstFname[];
index f2321e04ddaab8f19f540773619aca83a806af1e..a67b3ba104fedf84584348735d15ee4e327048a3 100644 (file)
@@ -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)
index e512b0ed1f61e9912e83ba25c750f9c3dcb9568b..43ab6992ef71c2d559500e4a2b40de2a357274be 100644 (file)
@@ -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)
index 93d84027af5c7e777d4b0efb0fee3a7a88ba3daa..1c8b65863ea075287f50252a06f1e778cfaee12d 100644 (file)
@@ -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)) 
index a1965efae840ba43d33259c74ebe2e36e767a36c..a6b711b8efbe0af35f105fb647699be75294a676 100644 (file)
@@ -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);
     
index c1dff7198a18a9aeaf2581cb8c2cbf812c849d50..daf3f930f4c6497b6ea7bbbde5a9056370864bc7 100644 (file)
@@ -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)
index eb7eb3c648bbd2cdd52a4b5addadb0902a69d78e..4ec5e617919b72840d40c0d01bf38545623383b2 100644 (file)
@@ -165,6 +165,7 @@ PORT avr_port = {
        "GSFINAL (CODE)",
        NULL,
        NULL,
+       0,
     },
     { 
        -1, 1, 4, 1, 1
index ba73c2c085e4e9ff357a56120af5921274c4efaf..f206c96cd6d7b53cbee626dbef226b08a0920a8f 100644 (file)
@@ -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 */
index 42a8c397d44335c139aca5dedd98ddb86f54eceb..cc8b1bc578fa8d52d6bc621e3e939207cdb54138 100644 (file)
@@ -221,7 +221,8 @@ PORT mcs51_port = {
        "OSEG    (OVR,DATA)",
        "GSFINAL (CODE)",
        NULL,
-       NULL
+       NULL,
+       1
     },
     { 
        +1, 1, 4, 1, 1
index 18fd7660cb91b9701610166e7156d0c522370770..65d4ba2b6d340d67d5dfa50711724f0d0653c820 100644 (file)
@@ -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 */
index e8f4a968b98c938582e108fc6717fa8c2205057d..bad1c014aa8aec75353aa60881854e915f4d9d30 100644 (file)
@@ -121,7 +121,8 @@ PORT z80_port = {
        "_OVERLAY",
        "_GSFINAL",
        NULL,
-       NULL
+       NULL,
+       1
     },
     { 
        -1, 0, 0, 8, 0