diff --git a/test/runtests b/test/runtests new file mode 100644 index 0000000..4331c70 --- /dev/null +++ b/test/runtests @@ -0,0 +1,3 @@ +for t in test* ; do + [ -d $t ] && (pushd $t; ./cc || exit 1; popd) +done \ No newline at end of file diff --git a/test/test1/cc b/test/test1/cc new file mode 100755 index 0000000..8ad27dd --- /dev/null +++ b/test/test1/cc @@ -0,0 +1,5 @@ +m68k-amigaos-gcc -S -Ofast test.c -fomit-frame-pointer -noixemul -mcpu=68000 -m68000 -mregparm=2 || exit 1 +m68k-amigaos-gcc -S -Ofast test.c -fomit-frame-pointer -noixemul -mcpu=68000 -m68000 -mregparm=2 -otestno.s || exit 1 +r="$(diff golden.s test.s)" +[ "$r" == "" ] || echo $r +[ "$r" == "" ] || exit 1 diff --git a/test/test1/golden.s b/test/test1/golden.s new file mode 100755 index 0000000..6c93414 --- /dev/null +++ b/test/test1/golden.s @@ -0,0 +1,73 @@ +#NO_APP + .text + .align 2 + .globl _strcpy +_strcpy: + move.l a2,-(sp) + move.l a0,d0 + move.l a0,a2 +.L2: + move.b (a1)+,(a2)+ + jne .L2 + move.l (sp)+,a2 + rts +.LC0: + .ascii "A NEW HIGH SCORE!!!\0" +.LC1: + .ascii "YOU ARE ON THE SCORE BOARD!\0" + .align 2 + .globl _hiscore_addScore +_hiscore_addScore: + move.l a2,-(sp) + move.l d2,-(sp) + lea _hiscore+72,a2 + moveq #9,d2 + cmp.l (a2),d0 + jcs .L7 +.L26: + tst.l d2 + jeq .L8 + lea (4,a2),a1 + lea (-4,a2),a0 +.L9: + move.b (a0)+,(a1)+ + jne .L9 + subq.l #1,d2 + subq.l #8,a2 + cmp.l (a2),d0 + jcc .L26 +.L7: + cmp.w #9,d2 + jne .L27 +.L6: + move.l (sp)+,d2 + move.l (sp)+,a2 + rts +.L27: + lea .LC1,a0 + jsr _hiscore_prompt + lsl.l #3,d2 + move.l d2,a0 + add.l #_hiscore+12,a0 + move.l d0,a1 +.L13: + move.b (a1)+,(a0)+ + jeq .L6 + move.b (a1)+,(a0)+ + jne .L13 + jra .L6 +.L8: + lea .LC0,a0 + jsr _hiscore_prompt + lea _hiscore+4,a0 + move.l d0,a1 +.L11: + move.b (a1)+,(a0)+ + jne .L11 + move.l a1,d0 + move.l (sp)+,d2 + move.l (sp)+,a2 + rts +.lcomm _hiscore,80 +.comm _game_over,4 +.comm _game_collisions,4 diff --git a/test/test1/test.c b/test/test1/test.c new file mode 100755 index 0000000..6ebf191 --- /dev/null +++ b/test/test1/test.c @@ -0,0 +1,59 @@ +#define HISCORE_NUM_SCORES 10 + +typedef short int int16_t; +typedef unsigned long uint32_t; + +typedef struct { + uint32_t score; + char name[4]; +} hiscore_t; + +typedef struct { + hiscore_t scores[HISCORE_NUM_SCORES]; +} hiscore_buffer_t; + +extern char* hiscore_prompt(char* buffer); +extern void hiscore_saveData(int); +extern void popup(char* popup, void (*callback)(void)); +extern uint32_t game_score; + +uint32_t game_collisions, game_over; +static hiscore_buffer_t hiscore; + + +char * +strcpy(char *dest, const char *src) +{ + char *s = dest; + while ((*s++ = *src++) != 0); + return dest; +} + + +__attribute__((externally_visible)) +void +hiscore_addScore(uint32_t score) +{ + int16_t i; + char* name; + + for (i = HISCORE_NUM_SCORES-1; i >= 0; i--) { + + if (score >= hiscore.scores[i].score) { + if (i > 0) { + strcpy(hiscore.scores[i].name, hiscore.scores[i-1].name); + } else if (i == 0) { + name = hiscore_prompt("A NEW HIGH SCORE!!!"); + strcpy(hiscore.scores[i].name, name); + } + } else + + { + if (i < HISCORE_NUM_SCORES-1) { + name = hiscore_prompt("YOU ARE ON THE SCORE BOARD!"); + strcpy(hiscore.scores[i+1].name, name); + } + break; + } + } +} diff --git a/test/test1/test.s b/test/test1/test.s new file mode 100644 index 0000000..6c93414 --- /dev/null +++ b/test/test1/test.s @@ -0,0 +1,73 @@ +#NO_APP + .text + .align 2 + .globl _strcpy +_strcpy: + move.l a2,-(sp) + move.l a0,d0 + move.l a0,a2 +.L2: + move.b (a1)+,(a2)+ + jne .L2 + move.l (sp)+,a2 + rts +.LC0: + .ascii "A NEW HIGH SCORE!!!\0" +.LC1: + .ascii "YOU ARE ON THE SCORE BOARD!\0" + .align 2 + .globl _hiscore_addScore +_hiscore_addScore: + move.l a2,-(sp) + move.l d2,-(sp) + lea _hiscore+72,a2 + moveq #9,d2 + cmp.l (a2),d0 + jcs .L7 +.L26: + tst.l d2 + jeq .L8 + lea (4,a2),a1 + lea (-4,a2),a0 +.L9: + move.b (a0)+,(a1)+ + jne .L9 + subq.l #1,d2 + subq.l #8,a2 + cmp.l (a2),d0 + jcc .L26 +.L7: + cmp.w #9,d2 + jne .L27 +.L6: + move.l (sp)+,d2 + move.l (sp)+,a2 + rts +.L27: + lea .LC1,a0 + jsr _hiscore_prompt + lsl.l #3,d2 + move.l d2,a0 + add.l #_hiscore+12,a0 + move.l d0,a1 +.L13: + move.b (a1)+,(a0)+ + jeq .L6 + move.b (a1)+,(a0)+ + jne .L13 + jra .L6 +.L8: + lea .LC0,a0 + jsr _hiscore_prompt + lea _hiscore+4,a0 + move.l d0,a1 +.L11: + move.b (a1)+,(a0)+ + jne .L11 + move.l a1,d0 + move.l (sp)+,d2 + move.l (sp)+,a2 + rts +.lcomm _hiscore,80 +.comm _game_over,4 +.comm _game_collisions,4 diff --git a/test/test1/testno.s b/test/test1/testno.s new file mode 100644 index 0000000..6c93414 --- /dev/null +++ b/test/test1/testno.s @@ -0,0 +1,73 @@ +#NO_APP + .text + .align 2 + .globl _strcpy +_strcpy: + move.l a2,-(sp) + move.l a0,d0 + move.l a0,a2 +.L2: + move.b (a1)+,(a2)+ + jne .L2 + move.l (sp)+,a2 + rts +.LC0: + .ascii "A NEW HIGH SCORE!!!\0" +.LC1: + .ascii "YOU ARE ON THE SCORE BOARD!\0" + .align 2 + .globl _hiscore_addScore +_hiscore_addScore: + move.l a2,-(sp) + move.l d2,-(sp) + lea _hiscore+72,a2 + moveq #9,d2 + cmp.l (a2),d0 + jcs .L7 +.L26: + tst.l d2 + jeq .L8 + lea (4,a2),a1 + lea (-4,a2),a0 +.L9: + move.b (a0)+,(a1)+ + jne .L9 + subq.l #1,d2 + subq.l #8,a2 + cmp.l (a2),d0 + jcc .L26 +.L7: + cmp.w #9,d2 + jne .L27 +.L6: + move.l (sp)+,d2 + move.l (sp)+,a2 + rts +.L27: + lea .LC1,a0 + jsr _hiscore_prompt + lsl.l #3,d2 + move.l d2,a0 + add.l #_hiscore+12,a0 + move.l d0,a1 +.L13: + move.b (a1)+,(a0)+ + jeq .L6 + move.b (a1)+,(a0)+ + jne .L13 + jra .L6 +.L8: + lea .LC0,a0 + jsr _hiscore_prompt + lea _hiscore+4,a0 + move.l d0,a1 +.L11: + move.b (a1)+,(a0)+ + jne .L11 + move.l a1,d0 + move.l (sp)+,d2 + move.l (sp)+,a2 + rts +.lcomm _hiscore,80 +.comm _game_over,4 +.comm _game_collisions,4