2
0
mirror of https://frontier.innolan.net/github/amigaos-cross-toolchain6.git synced 2024-10-19 10:29:55 +00:00

@N added first test

This commit is contained in:
bebbo
2017-05-26 23:06:54 +02:00
parent b9c71793d2
commit 0fa6714650
6 changed files with 286 additions and 0 deletions

3
test/runtests Normal file
View File

@ -0,0 +1,3 @@
for t in test* ; do
[ -d $t ] && (pushd $t; ./cc || exit 1; popd)
done

5
test/test1/cc Executable file
View File

@ -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

73
test/test1/golden.s Executable file
View File

@ -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

59
test/test1/test.c Executable file
View File

@ -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;
}
}
}

73
test/test1/test.s Normal file
View File

@ -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

73
test/test1/testno.s Normal file
View File

@ -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