Closed Sasszem closed 4 years ago
Oh damn it. I've been searching for the problem for nearly a week. Ten minutes after opening an issue & I found it randomly...
The problem was that for some reason I've written .data
instead of .byte
. It crashed the compiler and generated false errors, so I mainly looked at my code. It was an annoying typo, and the compiler certainly couldn't handle it.
It would be nice if you could better describe the problem where xa crashed, and maybe even provide a test case, e.g. two lines one with .byte and one with .data with the same parameters where it crashes on .data. That would help us in fixing this problem, and if that does not work, at lease print an appropriate error message. Thanks
Reopening because a bug that is not fixed is not fixed...
Here's the simplest code I've came up with, by removing instructions from my actual code:
mainloop:
ldx #255;
waitx:
ldy #255;
waity:
dey;
bne waity;
dex;
bne waitx;
joy:
right:
lda #8;
bit $dc00;
bne left;
;there were some code
left:
lda #4;
bit $dc00;
bne up;
;there too
up:
;lda #2;
;bit $dc00;
bne mainloop;
;and there
jmp mainloop;
.data 0,0,0,0;
Remove the .data
line and it compiles without any error. Removing any more instructions will prevent the compiler from crashing, but gives illegal pointer arithmetic error
s. It makes no sense...
Could you replicate the problem?
sorry for the late reply. Still crashes with 2.3.9
Ok, the problem here really is that ".data" is not something to insert data into to the binary, but to switch to the data segment when building a relocating file. So the "0,0,0,0" are completely ignored - use ".byte" or ".word" for that, depending on what width of the data items you need.
As for the crash, there was a bug in xa that did not reset the segment (either "data", "bss", ...) to its initial value between pass1 and pass2 - it just assumed you would not end in a different segment, or the first statement basically would set the right segment. See the "issue-3" branch for a fix, if you could try that out? here's the diff for the fix: https://github.com/fachat/xa65/commit/003f35f45b5b2ac98ef3089003344ba45f5dbcfc
That also explained the "illegal pointer arithmetic on the forward branches - they could only be resolved in pass2 (as they are forward not backward branches), but in pass2 the segment was incorrectly set to "data", while in the first pass it was "abs" (=no relocation), and pointer arithmetic (basically PC+/-branch offset) does not work across different segments.
As for ".data" not giving a warning when the assembler is not used in relocation mode.... that is another issue I guess.
I'll forward this to Cameron to have it put into the next proper xa version.
I've just started a project with
xa
, but after some time I've ran into the compiler crashing on my code. It also foundillegal pointer arithmetic
errors in the code which compiled without a problem previous day. I have no idea what could cause this, as some random test code I wrote compiled without a problem. Here's the backtrace, but I don't think this would be useful.PS: I've tried updating
xa
, reinstalling, and updating from this repo, with no success.