Hello,
I've joined two source files that highlight a compilation bug.
I put here the first one:
bug1.c :
#include <stdio.h>
int i=0;
int j=1;
main()
{
printf("i=%d j=%d\n", i, j);
if (i < j) puts("i<j"); else puts("i>=j");
}
The output is:
i=0 j=1
i>=j
The assembly generated for the test:
;bug1.c:9: if (i < j) puts("i<j"); else puts("i>=j");
ld hl, #_j
ld iy, #_i
ld a, 0 (iy)
sub a, (hl)
ld a, 1 (iy)
inc hl
sbc a, (hl)
jp PO, 00110$
xor a, #0x80
00110$:
jp P, 00102$
(00102$ is the else clause)
If I'm not mistaken, a parity test is made on the high order byte of the result and as it is set, the sign bit is inverted, which distorts the result.
Here the second case
Well, I was completly mistaken, the code is correct. it was of am emulator bug. Sorry for the disturbance.