From 4e79b2da27fb08fb0952fc1cc0dc0b5f1fa0b623 Mon Sep 17 00:00:00 2001 From: michaelh Date: Tue, 8 Feb 2000 03:21:27 +0000 Subject: [PATCH] * Changed timing support to work directly of ConsoleZ80's tick count * Mild cleaning of dhry.c * Improved iPush in gen.c, benchmarked git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@85 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/lib/z80/crt0.s | 37 +++-------------- device/lib/z80/putchar.s | 3 +- src/z80/gen.c | 71 ++++++++++++++++++-------------- src/z80/main.c | 10 ++--- support/tests/dhrystone/Makefile | 4 +- support/tests/dhrystone/dhry.c | 11 +++-- 6 files changed, 61 insertions(+), 75 deletions(-) diff --git a/device/lib/z80/crt0.s b/device/lib/z80/crt0.s index 56fade76..9e2a08c5 100644 --- a/device/lib/z80/crt0.s +++ b/device/lib/z80/crt0.s @@ -19,18 +19,13 @@ .org 0x30 reti .org 0x38 - jp __int + reti .org 0x150 init: ;; Stack at the top of memory. ld sp,#0xffff - ld a,#0x01 - out (0x09),a - ld a,#0xEF - out (0x07),a - ;; Use _main instead of main to bypass sdcc's intelligence ei call __main @@ -40,29 +35,9 @@ init: .area _CODE .area _DATA -__ticks: - .ds 2 - .area _CODE -__int: - push af - push hl - ld hl,#__ticks - inc (hl) - jr nz,1$ - inc hl - inc (hl) -1$: - pop hl - pop af - ei - ret - -_clock:: - ld hl,#__ticks - ld a,(hl) - inc hl - ld h,(hl) - ld l,a +__clock:: + ld a,#2 + out (0xff),a ret _getsp:: @@ -72,8 +47,8 @@ _getsp:: _exit:: ;; Exit - special code to the emulator - ld a,#0 - out (1),a + ld a,#1 + out (0xff),a 1$: halt jr 1$ diff --git a/device/lib/z80/putchar.s b/device/lib/z80/putchar.s index 2b8fa688..07ebeccf 100644 --- a/device/lib/z80/putchar.s +++ b/device/lib/z80/putchar.s @@ -4,7 +4,8 @@ _putchar:: ld ix,#0 add ix,sp - ld a,4(ix) + ld l,4(ix) + ld a,#0 out (0xff),a pop ix diff --git a/src/z80/gen.c b/src/z80/gen.c index 013aa719..4a1d9737 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -1,26 +1,40 @@ /*------------------------------------------------------------------------- - SDCCgen51.c - source file for code generation for 8051 + gen.c - Z80 specific code generator. + + Benchmarks on dhry.c 2.1 with 32766 loops and a 10ms clock: + ticks dhry size + Base with asm strcpy / strcmp / memcpy: 23198 141 1A14 + Improved WORD push 22784 144 19AE + With label1 on 22694 144 197E + With label2 on 22743 144 198A + With label3 on 22776 144 1999 + With label4 on 22776 144 1999 + With all 'label' on 22661 144 196F + With loopInvariant on 20919 156 19AB + With loopInduction on Breaks 198B + With all working on 20796 158 196C + + Michael Hope 2000 + Based on the mcs51 generator - Sandeep Dutta . sandeep.dutta@usa.net (1998) + and - Jean-Louis VERN.jlvern@writeme.com (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. - Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) - and - Jean-Louis VERN.jlvern@writeme.com (1999) + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - In other words, you are welcome to use, share and improve this program. - You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ @@ -1030,8 +1044,14 @@ static void genIpush (iCode *ic) if (s) { emitcode("ld", "hl,%s", s); emitcode("push", "hl"); - goto release; } + else { + /* Optimise here - load into HL then push HL */ + emitcode("ld", "l,%s", aopGet(AOP(IC_LEFT(ic)), 0, FALSE)); + emitcode("ld", "h,%s", aopGet(AOP(IC_LEFT(ic)), 1, FALSE)); + emitcode("push", "hl"); + } + goto release; } offset = size; while (size--) { @@ -1142,15 +1162,6 @@ static void emitCall (iCode *ic, bool ispcall) freeAsmop(IC_RESULT(ic),NULL, ic); } - /* PENDING: mega hack */ - { - char *s = OP_SYMBOL(IC_LEFT(ic))->rname[0] ? - OP_SYMBOL(IC_LEFT(ic))->rname : - OP_SYMBOL(IC_LEFT(ic))->name; - if (!strcmp(s, "__mulsint") || - !strcmp(s, "__divsint")) - IC_LEFT(ic)->parmBytes = 4; - } /* adjust the stack for parameters if required */ if (IC_LEFT(ic)->parmBytes) { int i = IC_LEFT(ic)->parmBytes; diff --git a/src/z80/main.c b/src/z80/main.c index 5378f7be..f076c45e 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -25,11 +25,11 @@ static void _z80_setDefaultOptions(void) options.intlong_rent = 1; optimize.global_cse = 0; - optimize.label1 = 0; - optimize.label2 = 0; - optimize.label3 = 0; - optimize.label4 = 0; - optimize.loopInvariant = 0; + optimize.label1 = 1; + optimize.label2 = 1; + optimize.label3 = 1; + optimize.label4 = 1; + optimize.loopInvariant = 1; optimize.loopInduction = 0; } diff --git a/support/tests/dhrystone/Makefile b/support/tests/dhrystone/Makefile index fe342a9f..778c8c46 100644 --- a/support/tests/dhrystone/Makefile +++ b/support/tests/dhrystone/Makefile @@ -12,8 +12,8 @@ OBJ = dhry.o all: dhry dhry: $(OBJ) - $(LD) -n -- -i -j -k$(LIBDIR) -lz80.lib \ - -b_CODE=0x200 -b_DATA=0xc000 dhry.ihx $(LIBDIR)crt0.o $(OBJ) + $(LD) -n -- -i -m -k$(LIBDIR) -lz80.lib \ + -b_CODE=0x200 dhry.ihx $(LIBDIR)crt0.o $(OBJ) cat dhry.ihx | ../../makebin/makebin > dhry.rom native: diff --git a/support/tests/dhrystone/dhry.c b/support/tests/dhrystone/dhry.c index 67ba7e52..e17c6f6b 100644 --- a/support/tests/dhrystone/dhry.c +++ b/support/tests/dhrystone/dhry.c @@ -71,7 +71,7 @@ Boolean Func_3 (Enumeration Enum_Par_Val); void printf(const char *format, ...); void exit(int val); -unsigned clock(void); +unsigned _clock(void); /*#define DPRINTF(_a) printf _a*/ #define DPRINTF(_a) @@ -115,8 +115,7 @@ int main(void) /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */ /* overflow may occur for this array element. */ - Number_Of_Runs = 32000; - clock(); + Number_Of_Runs = 32766; /* Main test loop */ for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) { @@ -188,7 +187,7 @@ int main(void) printf("Run_Index = %d\n", Run_Index); - endTime = clock(); + endTime = _clock(); printf ("Execution ends\n"); printf ("\n"); @@ -243,8 +242,8 @@ int main(void) printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n"); printf ("\n"); - printf("Time: %u secs\n", endTime); - printf("Dhrystones/tick = %u\n", Number_Of_Runs / endTime); + printf("Time: %u ticks\n", endTime); + printf("Dhrystones/tick = %u\n", Number_Of_Runs / (endTime/100)); } void Proc_1 (REG Rec_Pointer Ptr_Val_Par) -- 2.47.2