totalspectrum/spin2cpp

Enabling listing changes binary output

Wuerfel21 opened this issue · 3 comments

Compiling usb_to_vga.spin2 with -l and without -l produces a different binary. The -l enabled binary is broken, but I've had inexplicable breakage without it, too. I think it's something to do with the conditional ASM else?

list_bug.zip

Also, the built-in ZIP tool failed. Will another open issue for that.

Oddly enough this doesn't seem to be a problem in the conditional assembly. It's the peephole optimizer -- when -l is enabled some comments are inserted into the generated IR, and this causes the peephole optimizer to stop working because the patterns don't match (comments are not ignored). The generated code should be OK in either case, but obviously it would be nice to have the peephole optimizer run when -l is enabled.

Hmm, but that doesn't explain why everrything turns into 44 44 44 with -l. I guess if the peephole issue is fixed we would see any further discrepancy

There was another problem too, namely that if a file didn't end in a newline then its last comment line (intended for the listing file) also didn't have a newline, which caused it to eat the next line of assembly -- in this case, some of the data. That is fixed now, as is the peephole problem.