Closed zu2 closed 4 weeks ago
It doesn't appear to have been fixed. The following program demonstrates the problem:
/*
* char array
*/
int main(int argc, char *argv[])
{
char a[1];
a[0]=0;
return 0;
}
It compiles like this:
.setcpu 6800
.code
.export _main
.code
_main:
des
;make local ptr off 0, rlim 254 noff 0
tsx
clr 1,x
clr 0,x
;
clra
clrb
;
L0_r:
ins
jmp __cleanup4
There's an extra clr 1,x and the stack gets corrupted.
./emu6800 -d 6800 tests/9016-chararray tests/9016-chararray.map
0100 : ----I- 00|00 0000 0000 | LDS #7FFF
0103 : ----I- 00|00 0000 7FFF | CLRB
0104 : --Z-I- 00|00 0000 7FFF | CLRA
0105 : --Z-I- 00|00 0000 7FFF | STAB 03 [00]
0107 : --Z-I- 00|00 0000 7FFF | STAA 02 [00]
0109 : --Z-I- 00|00 0000 7FFF | INCB
010A : ----I- 00|01 0000 7FFF | STAB 04 [01]
010C : ----I- 00|01 0000 7FFF | STAA 03 [00]
010E : --Z-I- 00|01 0000 7FFF | PSHA
010F : --Z-I- 00|01 0000 7FFE | PSHB
0110 : --Z-I- 00|01 0000 7FFD | PSHA
0111 : --Z-I- 00|01 0000 7FFC | PSHB
0112 : --Z-I- 00|01 0000 7FFB | JSR 012B
012B : --Z-I- 00|01 0000 7FF9 | DES
012C : --Z-I- 00|01 0000 7FF8 | TSX
012D : --Z-I- 00|01 7FF9 7FF8 | CLR 01,X [01]
012F : --Z-I- 00|01 7FF9 7FF8 | CLR 00,X [00]
0131 : --Z-I- 00|01 7FF9 7FF8 | CLRA
0132 : --Z-I- 00|01 7FF9 7FF8 | CLRB
0133 : --Z-I- 00|00 7FF9 7FF8 | INS
0134 : --Z-I- 00|00 7FF9 7FF9 | JMP 015F
015F : --Z-I- 00|00 7FF9 7FF9 | TSX
0160 : --Z-I- 00|00 7FFA 7FF9 | LDX 00,X [0015]
0162 : ----I- 00|00 0015 7FF9 | INS
0163 : ----I- 00|00 0015 7FFA | INS
0164 : ----I- 00|00 0015 7FFB | INS
0165 : ----I- 00|00 0015 7FFC | INS
0166 : ----I- 00|00 0015 7FFD | INS
0167 : ----I- 00|00 0015 7FFE | INS
0168 : ----I- 00|00 0015 7FFF | JMP 00,X
0015 : ----I- 00|00 0015 7FFF | <ILLEGAL 00>
illegal instruction 00 at 0015
1
Applied properly this time sorry