michaelcmartin/Ophis

Fix illegal branches during instruction selection

Closed this issue · 1 comments

Ophis already includes an instruction selection pass that will map between Zero Page and Absolute addressing modes as appropriate, shifting to whatever is legal as necessary.

However, if you try to branch more than 127 bytes (or 128 backwards), you instead get an assemble-time error. The instruction selector should notice that the code is trying to do this and generate multiple instructions (a reversed branch and a jump) to make sure it's legal. This might be a warning at verbosities above 1.

Implemented in commit f8bc917. I decided to make warnings appear at verbosity 1 - this should normally be very rare and might mean a programming error.