From c9e40278469aa9b26090f1c3f03422d19161b669 Mon Sep 17 00:00:00 2001 From: michaelh Date: Sun, 3 Sep 2000 02:17:21 +0000 Subject: [PATCH] Fixed up z80 port so that it works again git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@345 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCsymt.c | 22 +--------------------- src/altlex.c | 8 ++++++++ src/avr/main.c | 2 +- src/ds390/main.c | 2 +- src/mcs51/main.c | 2 +- src/port.h | 4 ++++ src/z80/gen.c | 26 ++++++++++++++++++++++---- src/z80/main.c | 6 +++--- 8 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 40aa386b..438863d7 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -23,8 +23,6 @@ #include "common.h" -#define ENABLE_MICHAELH_REGPARM_HACK 0 - bucket *SymbolTab [256] ; /* the symbol table */ bucket *StructTab [256] ; /* the structure table */ bucket *TypedefTab[256] ; /* the typedef table */ @@ -1429,20 +1427,6 @@ void processFuncArgs (symbol *func, int ignoreName) (*port->reg_parm)(val->type)) { SPEC_REGPARM(val->etype) = 1; } - -#if ENABLE_MICHAELH_REGPARM_HACK - /* HACK: pull out later */ - if ( - ( - !strcmp(func->name, "memcpy") || - !strcmp(func->name, "strcpy") || - !strcmp(func->name, "strcmp") || - 0 - ) && - port->reg_parm(val->type)) { - SPEC_REGPARM(val->etype) = 1; - } -#endif if ( IS_AGGREGATE(val->type)) { /* if this is a structure */ @@ -1896,7 +1880,6 @@ symbol *__conv[2][3][2]; link *floatType; -#if ENABLE_MICHAELH_REGPARM_HACK static void _makeRegParam(symbol *sym) { value *val ; @@ -1911,7 +1894,6 @@ static void _makeRegParam(symbol *sym) val = val->next ; } } -#endif /*-----------------------------------------------------------------*/ /* initCSupport - create functions for C support routines */ @@ -1987,10 +1969,8 @@ void initCSupport () sbwd[bwd]); __muldiv[muldivmod][bwd][su] = funcOfType(buffer, __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent); SPEC_NONBANKED(__muldiv[muldivmod][bwd][su]->etype) = 1; -#if ENABLE_MICHAELH_REGPARM_HACK - if (bwd < 2) + if (bwd < port->muldiv.force_reg_param_below) _makeRegParam(__muldiv[muldivmod][bwd][su]); -#endif } } } diff --git a/src/altlex.c b/src/altlex.c index 816b2fad..6572164e 100644 --- a/src/altlex.c +++ b/src/altlex.c @@ -458,6 +458,14 @@ static int _yylex(void) *p++ = c; c = GETC(); } + if (c == 'U' || c == 'u' || c == 'L' || c == 'l') { + *p++ = c; + c = GETC(); + } + if (c == 'U' || c == 'u' || c == 'L' || c == 'l') { + *p++ = c; + c = GETC(); + } *p = '\0'; UNGETC(c); yylval.val = constVal(line); diff --git a/src/avr/main.c b/src/avr/main.c index 45be337b..ebd04b14 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -183,7 +183,7 @@ PORT avr_port = { }, /* avr has an 8 bit mul */ { - 1 + 1, 0 }, "_", _avr_init, diff --git a/src/ds390/main.c b/src/ds390/main.c index 8920d737..88d91e00 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -242,7 +242,7 @@ PORT ds390_port = { }, /* ds390 has an 8 bit mul */ { - 1 + 1, 0 }, "_", _ds390_init, diff --git a/src/mcs51/main.c b/src/mcs51/main.c index eded0bfe..991fb055 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -240,7 +240,7 @@ PORT mcs51_port = { }, /* mcs51 has an 8 bit mul */ { - 1 + 1, 0 }, "_", _mcs51_init, diff --git a/src/port.h b/src/port.h index 65cfc29d..8a3e6401 100644 --- a/src/port.h +++ b/src/port.h @@ -107,6 +107,10 @@ typedef struct { mul/div operation the processor can do nativley Eg if the processor has an 8 bit mul, nativebelow is 2 */ int native_below; + /** The mul/div/mod functions will be made to use regparams + for sizeof(param) < log2(force_reg) + i.e. Use 2 for WORD and BYTE, 0 for none. */ + int force_reg_param_below; } muldiv; /** Prefix to add to a C function (eg "_") */ diff --git a/src/z80/gen.c b/src/z80/gen.c index 003f5946..2bdd7f38 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -17,6 +17,7 @@ Better reg packing, first peephole 20038 163 1873 With assign packing 19281 165 1849 5/3/00 17741 185 17B6 + With reg params for mul and div 16234 202 162D Michael Hope 2000 Based on the mcs51 generator - @@ -1035,7 +1036,9 @@ static char *aopGet(asmop *aop, int offset, bool bit16) tsprintf(s, "!*hl"); } else { - tsprintf(s,"!*ixx", aop->aopu.aop_stk+offset); + if (aop->aopu.aop_stk >= 0) + offset += _G.stack.param_offset; + tsprintf(s,"!*ixx ; x", aop->aopu.aop_stk+offset); } ALLOC_ATOMIC(rs,strlen(s)+1); strcpy(rs,s); @@ -1171,6 +1174,8 @@ static void aopPut (asmop *aop, const char *s, int offset) emit2("ld !*hl,%s", s); } else { + if (aop->aopu.aop_stk >= 0) + offset += _G.stack.param_offset; if (!canAssignToPtr(s)) { emit2("ld a,%s", s); emit2("ld !*ixx,a", aop->aopu.aop_stk+offset); @@ -2625,7 +2630,7 @@ static void genIfxJump (iCode *ic, char *jval) ic->generated = 1; } -const char *getPairIdName(PAIR_ID id) +static const char *_getPairIdName(PAIR_ID id) { return _pairs[id].name; } @@ -2668,9 +2673,11 @@ static void genCmp (operand *left,operand *right, Load -lit into HL, add to right via, check sense. */ if (size == 2 && (AOP_TYPE(right) == AOP_LIT || AOP_TYPE(left) == AOP_LIT)) { + PAIR_ID id = PAIR_DE; asmop *lit = AOP(right); asmop *op = AOP(left); swap_sense = TRUE; + if (AOP_TYPE(left) == AOP_LIT) { swap_sense = FALSE; lit = AOP(left); @@ -2682,8 +2689,16 @@ static void genCmp (operand *left,operand *right, emit2("xor a,!immedbyte", 0x80); emit2("ld d,a"); } + else { + id = getPairId(op); + if (id == PAIR_INVALID) { + fetchPair(PAIR_DE, op); + id = PAIR_DE; + } + } + spillPair(PAIR_HL); emit2("ld hl,%s", fetchLitSpecial(lit, TRUE, sign)); - emit2("add hl,de"); + emit2("add hl,%s", _getPairIdName(id)); goto release; } if(AOP_TYPE(right) == AOP_LIT) { @@ -4404,7 +4419,10 @@ static void genAddrOf (iCode *ic) spillCached(); if (sym->onStack) { /* if it has an offset then we need to compute it */ - emitcode("ld", "hl,#%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset); + if (sym->stack > 0) + emitcode("ld", "hl,#%d+%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset, _G.stack.param_offset); + else + emitcode("ld", "hl,#%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset); emitcode("add", "hl,sp"); } else { diff --git a/src/z80/main.c b/src/z80/main.c index 53f09786..e48ed3e2 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -260,7 +260,7 @@ static const char *_z80_linkCmd[] = { }; static const char *_z80_asmCmd[] = { - "as-z80", "-plosgff", "$1.asm", NULL + "as-z80", "-plosgff", "$1.o", "$1.asm", NULL }; /** $1 is always the basename. @@ -325,7 +325,7 @@ PORT z80_port = { }, /* Z80 has no native mul/div commands */ { - 0 + 0, 2 }, "_", _z80_init, @@ -392,7 +392,7 @@ PORT gbz80_port = { }, /* gbZ80 has no native mul/div commands */ { - 0 + 0, 2 }, "_", _gbz80_init, -- 2.39.5