Conversation
7a90ba8 to
feac6dc
Compare
feac6dc to
cb336ae
Compare
|
Obviously there's loads more to go. I'm planning to do one commit per instruction so we can leave out any deemed too unstable |
|
Very nice!
Does the real Nmos6502 terminate at an illegal opcode? If so, I agree that we should add a new variant. If not it would be more accurate to keep the illegal opcodes in the existing variant in my opinion. |
Nmos6502 executes the illegal opcode so no need for a new variant. https://github.com/mlund/mos6502/tree/illegal |
The illegal opcodes implementation caused README doc tests to hang: 1. First example used 0xff as program terminator - Previously 0xff was unimplemented (returned None), stopping execution - Now 0xff is ISC (INC+SBC) AbsoluteX, causing infinite loop - Fix: Use 0x02 (JAM) which explicitly halts the CPU 2. Second example loads euclid.bin which uses BRK (0x00) to terminate - BRK jumps to IRQ vector at $FFFE/$FFFF - Uninitialized memory contains 0x00, jumping to address $0000 - This causes infinite loop executing whatever is in low memory - Fix: Mark as no_run since it depends on external file anyway
- Replace BRK with JAM ($02) to halt CPU after illegal opcodes impl - Fix assembly label structure (algo/algo_ were dead infinite loops) - Simplify linker.cfg to output raw binary at $0010 (was 64KB image) - Enable README doc test (remove no_run marker) The old linker config produced a 64KB memory image with code at $0400, but README loaded at $0010 causing address mismatch. New config outputs only the code segment at the correct load address.
|
This PR now incorporates everything mlund did. I'll be marking it as ready for review. |
|
@mre should I go ahead and merge this? |
|
Sorry for the late reply. I got sidetracked with so many other things. Will take a look quick. |
There was a problem hiding this comment.
LGTM. Thanks for the contribution @mlund and @omarandlorraine. 🫶
There was a problem hiding this comment.
I haven't tested this, but it seems reasonable.
I'm working my way through a list I found of illegal opcodes.
I'm adding these to the NMOS variant, but I'm not feeling settled about that. I think it ought to go in another variant, so that the
Nmos6502will terminate if it hits a bad opcode. Is that the correct approach?As I recall @mre mentioned a timing related test which can't be enabled yet because it also exercises illegal opcodes. Will this test also do to make sure that the illegal opcodes work in the expected ways?
I'm planning to leave out some of the Real Weirdos, like the addressing mode which mixes immediate and absolute-indexed
closes #125