]> git.gag.com Git - fw/sdcc/commitdiff
* Changed timing support to work directly of ConsoleZ80's tick count
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 8 Feb 2000 03:21:27 +0000 (03:21 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 8 Feb 2000 03:21:27 +0000 (03:21 +0000)
* 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
device/lib/z80/putchar.s
src/z80/gen.c
src/z80/main.c
support/tests/dhrystone/Makefile
support/tests/dhrystone/dhry.c

index 56fade760693b17629e7fe05c4ab5d6f0903444d..9e2a08c55ec4b6befc4e8e48843f94ac673aede4 100644 (file)
        .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$
index 2b8fa688a2c02355481acac666212224bae34f7a..07ebeccf4f24170d003f3dc20995dff7cb9ff6f0 100644 (file)
@@ -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
index 013aa719eff89bdc909a83116f713a7e70b8626e..4a1d97379dea1d6b00b8db9e72f351033de082cd 100644 (file)
@@ -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 <michaelh@earthling.net>        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;
index 5378f7be295affd8cf5a7548f97677881a534c0d..f076c45e940f6b3d3546b4097bf2d1dc2b6e8315 100644 (file)
@@ -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;
 }
 
index fe342a9f72b09ed6259fa962ab64b0799f2e6cce..778c8c46ffe54f476a9c0b6f9fc9fb5c6104c158 100644 (file)
@@ -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:
index 67ba7e5288193e4714ad61571d4806fe33c44f66..e17c6f6bab4341c33b23bec06c431ef2c3587f75 100644 (file)
@@ -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)