wiz-lang / wiz

A high-level assembly language for writing homebrew software and games on retro console platforms.
http://wiz-lang.org/
Other
409 stars 40 forks source link

Fix branching on bit-indexing of indirected hl/ix/iy on Z80 and GB. #107

Closed Bananattack closed 3 years ago

Bananattack commented 3 years ago

There is a small bug affecting the Z80 and GB backend in how we handle generating branches on bit-tests that restricts it to only registers. However bit instructions exist for indirected-hl as well as the same operand for typical ix/iy-indexed operands.

Here's a reference showing the relevant bit instructions: http://z80-heaven.wikidot.com/instructions-set:bit

Here is the code in question on Z80, linking the latest commit at the time of this writing: https://github.com/wiz-lang/wiz/blob/3dbe8c5f6cec735eddc9e5adbd185629fea49801/src/wiz/platform/z80_platform.cpp#L1100-L1117

Similar code issue in the gb_platform.cpp file, although it is only missing indirected hl to consider.

In both platforms, the bit instrinsics exist but the test-and-branch generation doesn't look for them if the operand isn't a register.