From e5c0243133d2ce207020e4817b1ea86b3c1057d8 Mon Sep 17 00:00:00 2001 From: michaelh Date: Wed, 19 Apr 2000 02:56:55 +0000 Subject: [PATCH] * Re-added .dw for words, but now port dependent. * Fixed interesting load bug git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@237 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCglue.c | 18 ++++++++++++------ src/avr/main.c | 3 ++- src/mcs51/main.c | 3 ++- src/port.h | 5 ++++- src/z80/gen.c | 33 +++++++++++++++++---------------- src/z80/main.c | 10 ++++++---- 6 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 8d7b1f9d..7d032076 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -515,13 +515,16 @@ void printIvalFuncPtr (link * type, initList * ilist, FILE * oFile) /* now generate the name */ if (!val->sym) { - if (IS_LITERAL (val->etype)) - fprintf(oFile, "\t.byte %s,%s\n", aopLiteral(val, 0),aopLiteral(val, 1)); - else + if (port->use_dw_for_init) + tfprintf(oFile, "\t!dw %s\n", val->name); + else fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->name,val->name); } - else - fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->sym->rname,val->sym->rname); + else + if (port->use_dw_for_init) + tfprintf(oFile, "\t!dws\n", val->sym->rname); + else + fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->sym->rname,val->sym->rname); return; } @@ -546,7 +549,10 @@ int printIvalCharPtr (symbol * sym, link * type, value * val, FILE * oFile) "\t!dbs\n", val->name) ; break; case 2: - tfprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->name, val->name); + if (port->use_dw_for_init) + tfprintf(oFile, "\t!dws\n", val->name); + else + fprintf(oFile, "\t.byte %s,(%s >> 8)\n", val->name, val->name); break; /* PENDING: probably just 3 */ default: diff --git a/src/avr/main.c b/src/avr/main.c index 9b8b8d3c..dd194986 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -190,6 +190,7 @@ PORT avr_port = { _avr_genAssemblerPreamble, _avr_genIVT, _avr_reset_regparm, - _avr_regparm + _avr_regparm, + FALSE }; diff --git a/src/mcs51/main.c b/src/mcs51/main.c index cab02da9..e480975e 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -248,6 +248,7 @@ PORT mcs51_port = { _mcs51_genIVT , _mcs51_reset_regparm, _mcs51_regparm, - NULL + NULL, + FALSE }; diff --git a/src/port.h b/src/port.h index e380441a..fb2bc1b7 100644 --- a/src/port.h +++ b/src/port.h @@ -140,7 +140,10 @@ typedef struct { processed, 1 otherwise. May be NULL. */ int (*process_pragma)(const char *sz); - + + /** If TRUE, then tprintf and !dw will be used for some initalisers + */ + bool use_dw_for_init; } PORT; extern PORT *port; diff --git a/src/z80/gen.c b/src/z80/gen.c index 13a85e80..c73d1ae2 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -344,6 +344,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool requires_a) /* Assign depending on the storage class */ if (sym->onStack || sym->iaccess) { + emitcode("", "; AOP_STK for %s", sym->rname); sym->aop = aop = newAsmop(AOP_STK); aop->size = getSize(sym->type); aop->aopu.aop_stk = sym->stack; @@ -361,7 +362,6 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool requires_a) if (IS_GB) { /* if it is in direct space */ - printf("sname %s: regsp %u\n", space->sname, space->regsp); if (IN_REGSP(space) && !requires_a) { sym->aop = aop = newAsmop (AOP_SFR); aop->aopu.aop_dir = sym->rname ; @@ -374,6 +374,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool requires_a) /* only remaining is far space */ /* in which case DPTR gets the address */ if (IS_GB) { + emitcode("", "; AOP_HL for %s", sym->rname); sym->aop = aop = newAsmop(AOP_HL); } else { @@ -777,13 +778,15 @@ static void fetchLitPair(PAIR_ID pairId, asmop *left, int offset) if (isPtr(pair)) { if (pairId == PAIR_HL || pairId == PAIR_IY) { - if (_G.pairs[pairId].lit && !strcmp(_G.pairs[pairId].lit, l)) { - if (pairId == PAIR_HL && abs(_G.pairs[pairId].offset - offset) < 3) { - adjustPair(pair, &_G.pairs[pairId].offset, offset); - return; - } - if (pairId == PAIR_IY && abs(offset)<127) { - return; + if (_G.pairs[pairId].last_type == left->type) { + if (_G.pairs[pairId].lit && !strcmp(_G.pairs[pairId].lit, l)) { + if (pairId == PAIR_HL && abs(_G.pairs[pairId].offset - offset) < 3) { + adjustPair(pair, &_G.pairs[pairId].offset, offset); + return; + } + if (pairId == PAIR_IY && abs(offset)<127) { + return; + } } } } @@ -1811,16 +1814,14 @@ static bool genPlusIncr (iCode *ic) ) { int offset = 0; symbol *tlbl = NULL; + tlbl = newiTempLabel(NULL); while (size--) { - if (offset) { - emitIntLabel(tlbl->key+100); - } emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)), offset++, FALSE)); if (size) { - tlbl = newiTempLabel(NULL); emit2("!shortjp nz,!tlabel", tlbl->key+100); } } + emitLabel(tlbl->key+100); return TRUE; } @@ -2830,9 +2831,9 @@ static void genAnd (iCode *ic, iCode *ifx) if (AOP_TYPE(left) == AOP_ACC) emitcode("and","a,%s",aopGet(AOP(right),offset,FALSE)); else { - MOVA(aopGet(AOP(right),offset,FALSE)); + MOVA(aopGet(AOP(left),offset,FALSE)); emitcode("and","a,%s", - aopGet(AOP(left),offset,FALSE)); + aopGet(AOP(right),offset,FALSE)); } aopPut(AOP(result),"a",offset); } @@ -2950,9 +2951,9 @@ static void genOr (iCode *ic, iCode *ifx) if (AOP_TYPE(left) == AOP_ACC) emitcode("or","a,%s",aopGet(AOP(right),offset,FALSE)); else { - MOVA(aopGet(AOP(right),offset,FALSE)); + MOVA(aopGet(AOP(left),offset,FALSE)); emitcode("or","a,%s", - aopGet(AOP(left),offset,FALSE)); + aopGet(AOP(right),offset,FALSE)); } aopPut(AOP(result),"a",offset); /* PENDING: something weird is going on here. Add exception. */ diff --git a/src/z80/main.c b/src/z80/main.c index b44921cb..b5d1849d 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -92,12 +92,12 @@ static bool _parseOptions(int *pargc, char **argv, int *i) switch (argv[*i][2]) { case 'o': /* ROM bank */ - sprintf(buffer, "_CODE_%u", bank); + sprintf(buffer, "CODE_%u", bank); gbz80_port.mem.code_name = gc_strdup(buffer); return TRUE; case 'a': /* RAM bank */ - sprintf(buffer, "_DATA_%u", bank); + sprintf(buffer, "DATA_%u", bank); gbz80_port.mem.data_name = gc_strdup(buffer); return TRUE; } @@ -245,7 +245,8 @@ PORT z80_port = { 0, /* no assembler preamble */ 0, /* no local IVT generation code */ _reset_regparm, - _reg_parm + _reg_parm, + TRUE }; /* Globals */ @@ -305,5 +306,6 @@ PORT gbz80_port = { 0, /* no local IVT generation code */ _reset_regparm, _reg_parm, - _process_pragma + _process_pragma, + TRUE }; -- 2.39.5