From 3a22c145d5dc80d4fe4cb2f60de8d0fae7721287 Mon Sep 17 00:00:00 2001 From: michaelh Date: Sat, 19 Feb 2000 05:08:06 +0000 Subject: [PATCH] * Added iCodeSE patch * Fixed genPointerGet, genPCall. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@111 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/lib/gbz80/printf.c | 5 +---- src/SDCCicode.c | 3 ++- src/z80/gen.c | 32 +++++++++++++++++--------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/device/lib/gbz80/printf.c b/device/lib/gbz80/printf.c index 40a57ecc..33d7050e 100644 --- a/device/lib/gbz80/printf.c +++ b/device/lib/gbz80/printf.c @@ -37,8 +37,6 @@ static void _printn(unsigned u, unsigned base, char issigned, EMIT *emitter, voi static void _printf(const char *format, EMIT *emitter, void *pData, va_list va) { while (*format) { - putchar(*format); -#if 0 if (*format == '%') { switch (*++format) { case 'c': { @@ -59,7 +57,7 @@ static void _printf(const char *format, EMIT *emitter, void *pData, va_list va) break; } case 'x': - { + { unsigned u = va_arg(va, unsigned); _printn(u, 16, 0, emitter, pData); break; @@ -77,7 +75,6 @@ static void _printf(const char *format, EMIT *emitter, void *pData, va_list va) else { (*emitter)(*format, pData); } -#endif format++; } } diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 23bc6c5d..f42e063e 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2416,7 +2416,8 @@ operand *geniCodeCall (operand *left, ast *parms) /* take care of parameters with side-effecting function calls in them, this is required to take care of overlaying function parameters */ - geniCodeSEParms ( parms ); + if (!options.stackAuto) + geniCodeSEParms ( parms ); /* first the parameters */ geniCodeParms ( parms , &stack , getSpec(operandType(left))); diff --git a/src/z80/gen.c b/src/z80/gen.c index 0782a420..c03c0a22 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -1165,8 +1165,6 @@ static void genIpop (iCode *ic) */ static void emitCall (iCode *ic, bool ispcall) { - int isPrintf = 0; - /* if caller saves & we have not saved then */ if (!ic->regsSaved) { /* PENDING */ @@ -1199,14 +1197,15 @@ static void emitCall (iCode *ic, bool ispcall) emitcode("ld", "hl,#" LABEL_STR, (rlbl->key+100)); emitcode("push", "hl"); + _pushed += 2; aopOp(IC_LEFT(ic),ic,FALSE); - emitcode("ld", "l,%s", aopGet(AOP(IC_LEFT(ic)), 0,FALSE)); - emitcode("ld", "h,%s", aopGet(AOP(IC_LEFT(ic)), 1,FALSE)); + fetchHL(AOP(IC_LEFT(ic))); freeAsmop(IC_LEFT(ic),NULL,ic); emitcode("jp", "(hl)"); emitcode("","%05d$:",(rlbl->key+100)); + _pushed -= 2; } else { /* make the call */ @@ -1214,9 +1213,6 @@ static void emitCall (iCode *ic, bool ispcall) OP_SYMBOL(IC_LEFT(ic))->rname : OP_SYMBOL(IC_LEFT(ic))->name; emitcode("call", "%s", name); - if (!strcmp(name, "__printf")) - isPrintf = 1; - } /* if we need assign a result value */ @@ -1237,9 +1233,6 @@ static void emitCall (iCode *ic, bool ispcall) /* adjust the stack for parameters if required */ if (IC_LEFT(ic)->parmBytes) { int i = IC_LEFT(ic)->parmBytes; - emitcode("", ";parmBytes = %u\n", i); - if (isPrintf) - i+=2; _pushed -= i; if (i>6) { emitcode("ld", "hl,#%d", i); @@ -3291,6 +3284,10 @@ static void genGenPointerGet (operand *left, { int size, offset ; link *retype = getSpec(operandType(result)); + const char *ptr = "hl"; + + if (IS_GB) + ptr = "de"; aopOp(left,ic,FALSE); aopOp(result,ic,FALSE); @@ -3306,9 +3303,14 @@ static void genGenPointerGet (operand *left, /* For now we always load into IY */ /* if this is remateriazable */ if (AOP_TYPE(left) == AOP_IMMD) - emitcode("ld","hl,%s",aopGet(AOP(left),0,TRUE)); + emitcode("ld","%s,%s", ptr, aopGet(AOP(left),0,TRUE)); else { /* we need to get it byte by byte */ - fetchHL(AOP(left)); + if (IS_GB) { + emitcode("ld", "e,%s", aopGet(AOP(left), 0, FALSE)); + emitcode("ld", "d,%s", aopGet(AOP(left), 1, FALSE)); + } + else + fetchHL(AOP(left)); } /* so iy now contains the address */ freeAsmop(left,NULL,ic); @@ -3323,15 +3325,15 @@ static void genGenPointerGet (operand *left, while (size--) { /* PENDING: make this better */ - if (AOP(result)->type == AOP_REG) { + if (!IS_GB && AOP(result)->type == AOP_REG) { aopPut(AOP(result),"(hl)",offset++); } else { - emitcode("ld", "a,(hl)", offset); + emitcode("ld", "a,(%s)", ptr, offset); aopPut(AOP(result),"a",offset++); } if (size) { - emitcode("inc", "hl"); + emitcode("inc", "%s", ptr); } } } -- 2.47.2