test for regression that occured after #2262

This commit is contained in:
mrdudz 2023-12-10 22:16:30 +01:00
parent 9634cc4d1e
commit b31a1c7c0c
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
// optimizer bug that occured after PR #2262, fixed by PR #2295
#include <stdio.h>
unsigned char n;
unsigned long fp1;
int failures = 0;
void test1(void)
{
asm("lda _n");
asm("jeq %g", L0004);
asm("lda #$3F");
asm("sta sreg+1");
asm("lda #$C0");
asm("sta sreg");
asm("lda #$00");
asm("ldx #$00");
asm("jmp %g", L0005);
L0004:
asm("lda #$3F");
asm("sta sreg+1");
asm("lda #$00");
asm("sta sreg");
asm("lda #$00");
asm("ldx #$00");
L0005:
asm("sta _fp1");
asm("stx _fp1+1");
asm("ldy sreg");
asm("sty _fp1+2");
asm("ldy sreg+1");
asm("sty _fp1+3");
}
int main(void)
{
n = 0;
test1();
printf("fp1:%08lx\n", fp1);
if (fp1 != 0x3f000000) failures++;
n = 0xff;
test1();
printf("fp1:%08lx\n", fp1);
if (fp1 != 0x3fc00000) failures++;
printf("failures:%d\n", failures);
return failures;
}