SCC = $(TOPDIR)/bin/sdcc -mz80 -v
SAS = as-z80
-OBJ = div.o mul.o putchar.o string.o printf.o
+OBJ = div.o mul.o putchar.o string.o printf.o asm_strings.o
LIB = z80.lib
CC = $(SCC)
AS = $(SAS)
ld e,8(ix)
ld d,9(ix)
- push de
+ push hl
1$:
ld a,(de)
ld (hl),a
pop de
ret
+; void *memcpy(void *dest, const void *source, int count)
+_memcpy::
+ push de
+ push bc
+ push ix
+ ld ix,#0
+ add ix,sp
+ ld l,8(ix)
+ ld h,9(ix)
+ ld e,10(ix)
+ ld d,11(ix)
+ ld c,12(ix)
+ ld b,13(ix)
+
+ inc b
+ inc c
+ push hl
+
+ jr 2$
+1$:
+ ld a,(de)
+ ld (hl),a
+ inc de
+ inc hl
+2$:
+ dec c
+ jr nz,1$
+ dec b
+ jr nz,1$
+
+ pop hl
+ pop ix
+ pop bc
+ pop de
+ ret
+
+; int strcmp(const char *s1, const char *s2)
+_strcmp::
+ push de
+ push ix
+ ld ix,#0
+ add ix,sp
+ ld e,6(ix)
+ ld d,7(ix)
+ ld l,8(ix)
+ ld h,9(ix)
+
+ jr 1$
+2$:
+ ld a,(de)
+ sub (hl)
+ jr nz,4$
+ ;; A == 0
+ cp (hl)
+ jr z,3$
+1$:
+ inc de
+ inc hl
+ jr 2$
+
+3$:
+ ld hl,#0
+ jr 5$
+4$:
+ ld hl,#1
+ jr nc,5$
+ ld hl,#-1
+5$:
+ pop ix
+ pop de
+ ret
\ No newline at end of file
/* Dumb strings stub.
Wanted a quick hack for now - will use the libc version later.
*/
+#if 0
char *strcpy(char *dest, const char *source)
{
char *ret = dest;
while (*dest++ = *source++);
return ret;
}
+#endif
+#if 0
void *memcpy(void *dest, const void *source, int count)
{
char *d = dest;
return dest;
}
+#endif
-int strcmp(const char *s1, const char *s2)
+int __strcmp(const char *s1, const char *s2)
{
int ret = 0;
return 1;
return 0;
}
+
void printf(const char *format, ...);
void exit(int val);
+unsigned clock(void);
/*#define DPRINTF(_a) printf _a*/
#define DPRINTF(_a)
Str_30 Str_2_Loc;
REG int Run_Index;
REG int Number_Of_Runs;
+ unsigned endTime;
printf("[dhry]\n");
/* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
/* overflow may occur for this array element. */
- Number_Of_Runs = 5000;
+ Number_Of_Runs = 32000;
+ clock();
/* Main test loop */
for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) {
printf("Run_Index = %d\n", Run_Index);
+ endTime = clock();
+
printf ("Execution ends\n");
printf ("\n");
printf ("Final values of the variables used in the benchmark:\n");
printf ("Str_2_Loc: %s\n", Str_2_Loc);
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);
}
void Proc_1 (REG Rec_Pointer Ptr_Val_Par)