From: bernhardheld Date: Mon, 13 Jan 2003 14:38:14 +0000 (+0000) Subject: * src/ds390/peeph.def: fix #123; add 14 rules by Fiorenzo D. Ramaglia * src/mcs51/peeph.def: fix #123; add 14 rules by Fiorenzo * src/mcs51/gen.c (genFunction): emit r0 instead of ar0 by Fiorenzo * as/mcs51/lkmem (summary): better fix for sp problem * src/SDCCglue.c (glue): __start_stack - 1, saves 1 byte! * src/ds390/main.c (_ds390_finaliseOptions, _tininative_finaliseOptions): stack_loc = 0x400008 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2151 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 68194eaf..4153b7ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-01-13 Bernhard Held + + * src/ds390/peeph.def: fix #123; add 14 rules by Fiorenzo D. Ramaglia + * src/mcs51/peeph.def: fix #123; add 14 rules by Fiorenzo + * src/mcs51/gen.c (genFunction): emit r0 instead of ar0 by Fiorenzo + * as/mcs51/lkmem (summary): better fix for sp problem + * src/SDCCglue.c (glue): __start_stack - 1, saves 1 byte! + * src/ds390/main.c (_ds390_finaliseOptions, _tininative_finaliseOptions): stack_loc = 0x400008 + 2003-01-12 Bernhard Held * src/SDCCmain.c (main): port->finaliseOptions() moved for z80 linking diff --git a/as/mcs51/lkmem.c b/as/mcs51/lkmem.c index ae09af3f..9ff0c161 100644 --- a/as/mcs51/lkmem.c +++ b/as/mcs51/lkmem.c @@ -251,46 +251,45 @@ int summary(struct area * areap) } /*Report the position of the begining of the stack*/ - fprintf(of, "\nStack starts at: 0x%02lx", Stack.Start); + /* TODO find flag for DS390 */ + fprintf(of, "\n%stack starts at: 0x%02lx (sp set to 0x%02lx)", + 0 ? "16 bit mode initial s" : "S", Stack.Start, Stack.Start-1); /*Check that the stack pointer is landing in a safe place:*/ - // if (!flat24Mode) TODO: bypass stack check for ds390 + if( (dram[Stack.Start] & 0x8000) == 0x8000 ) { - if( (dram[Stack.Start] & 0x8000) == 0x8000 ) - { - fprintf(of, ".\n"); - sprintf(buff, "Stack set to unavailable memory.\n"); - REPORT_ERROR(buff, 1); - } - else if(dram[Stack.Start+1]) + fprintf(of, ".\n"); + sprintf(buff, "Stack set to unavailable memory.\n"); + REPORT_ERROR(buff, 1); + } + else if(dram[Stack.Start]) + { + fprintf(of, ".\n"); + sprintf(buff, "Stack overlaps area "); + REPORT_ERROR(buff, 1); + for(j=0; j<7; j++) { - fprintf(of, ".\n"); - sprintf(buff, "Stack overlaps area "); - REPORT_ERROR(buff, 1); - for(j=0; j<7; j++) + if(dram[Stack.Start]&Ram[j].flag) { - if(dram[Stack.Start+1]&Ram[j].flag) - { - sprintf(buff, "'%s'\n", Ram[j].Name); - break; - } + sprintf(buff, "'%s'\n", Ram[j].Name); + break; } - if(dram[Stack.Start]&IRam.flag) - { - sprintf(buff, "'%s'\n", IRam.Name); - } - REPORT_ERROR(buff, 0); } - else + if(dram[Stack.Start]&IRam.flag) { - for(j=Stack.Start, k=0; (j<(int)iram_size)&&(dram[j]==0); j++, k++); - fprintf(of, " with %d bytes available\n", k); - if (k + +replace { + add a,ar%1 +} by { + ; Peephole 236a + add a,r%1 +} + +replace { + addc a,ar%1 +} by { + ; Peephole 236b + addc a,r%1 +} + +replace { + anl a,ar%1 +} by { + ; Peephole 236c + anl a,r%1 +} + +replace { + dec ar%1 +} by { + ; Peephole 236d + dec r%1 +} + +replace { + djnz ar%1,%2 +} by { + ; Peephole 236e + djnz r%1,%2 +} + +replace { + inc ar%1 +} by { + ; Peephole 236f + inc r%1 +} + +replace { + mov a,ar%1 +} by { + ; Peephole 236g + mov a,r%1 +} + +replace { + mov ar%1,#%2 +} by { + ; Peephole 236h + mov r%1,#%2 +} + +replace { + mov ar%1,a +} by { + ; Peephole 236i + mov r%1,a +} + +replace { + mov ar%1,ar%2 +} by { + ; Peephole 236j + mov r%1,ar%2 +} + +replace { + orl a,ar%1 +} by { + ; Peephole 236k + orl a,r%1 +} + +replace { + subb a,ar%1 +} by { + ; Peephole 236l + subb a,r%1 +} + +replace { + xch a,ar%1 +} by { + ; Peephole 236m + xch a,r%1 +} + +replace { + xrl a,ar%1 +} by { + ; Peephole 236n + xrl a,r%1 +} + diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 55094e63..8b816f10 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -2521,12 +2521,12 @@ genFunction (iCode * ic) } else { - /* not callee-saves, we can clobber ar0 */ - emitcode ("mov", "ar0,a"); + /* not callee-saves, we can clobber r0 */ + emitcode ("mov", "r0,a"); emitcode ("mov", "a,sp"); emitcode ("add", "a,#0x%02x", ((char) sym->stack & 0xff)); emitcode ("mov", "sp,a"); - emitcode ("mov", "a,ar0"); + emitcode ("mov", "a,r0"); } } else diff --git a/src/mcs51/peeph.def b/src/mcs51/peeph.def index 87592d92..e850afb7 100644 --- a/src/mcs51/peeph.def +++ b/src/mcs51/peeph.def @@ -1969,3 +1969,103 @@ replace { ret } +// 14 rules by Fiorenzo D. Ramaglia + +replace { + add a,ar%1 +} by { + ; Peephole 236a + add a,r%1 +} + +replace { + addc a,ar%1 +} by { + ; Peephole 236b + addc a,r%1 +} + +replace { + anl a,ar%1 +} by { + ; Peephole 236c + anl a,r%1 +} + +replace { + dec ar%1 +} by { + ; Peephole 236d + dec r%1 +} + +replace { + djnz ar%1,%2 +} by { + ; Peephole 236e + djnz r%1,%2 +} + +replace { + inc ar%1 +} by { + ; Peephole 236f + inc r%1 +} + +replace { + mov a,ar%1 +} by { + ; Peephole 236g + mov a,r%1 +} + +replace { + mov ar%1,#%2 +} by { + ; Peephole 236h + mov r%1,#%2 +} + +replace { + mov ar%1,a +} by { + ; Peephole 236i + mov r%1,a +} + +replace { + mov ar%1,ar%2 +} by { + ; Peephole 236j + mov r%1,ar%2 +} + +replace { + orl a,ar%1 +} by { + ; Peephole 236k + orl a,r%1 +} + +replace { + subb a,ar%1 +} by { + ; Peephole 236l + subb a,r%1 +} + +replace { + xch a,ar%1 +} by { + ; Peephole 236m + xch a,r%1 +} + +replace { + xrl a,ar%1 +} by { + ; Peephole 236n + xrl a,r%1 +} +