tinco Posted August 7, 2023 Share Posted August 7, 2023 (edited) I just recently got the bug to do some 2600 programming for fun. I'm seeing some odd and inconsistently occurring behavior launching builds in stella, and wonder if anyone else has seen anything similar. Sometimes, the binary loads and runs fine, sometimes it'll cause an "invalid instruction" error to pop up in the debugger during execution. When this happens, the debugger doesn't seem to understand the list file even though the console output says the lst file was loaded and can't display symbols correctly, even though I can set the program counter field in the editor to the start of cartridge memory and see that the instructions look correct in rom. If I build and debug stella from code in visual studio, when things go sideways it looks like subroutine return instructions aren't being handled correctly, with a corrupted or incorrect return address stored on the stack. This isn't all the time, but it happens some times when loading the binary. When it DOES work, everything is fine, code runs as expected, symbols look correct in debugger view in stella. Running the same binary in z64k seems to always work just fine. I'm building and running on a windows machine, latest stella code (7.0). I haven't spent a ton of time on this yet, and not a ton of time stepping through what stella is doing, but I can see that sometimes PC. Code is minimal, and attached here for reference. I've cut this back to a small piece of code in the attached file; probably could reduce more, but this is a pretty small file and doesn't do much other than draw some playfield colors. I'll poke around some more at some point, but in case anyone has any thoughts on this, I thought I'd post here. minimaltest.asm Edited August 7, 2023 by tinco editing for clarity Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 7, 2023 Share Posted August 7, 2023 (edited) Your code is missing the stack initialization. If the randomly initialized stack pointer points below $80, that causes a crash of the ROM (not Stella) when returning from a subroutine. Edited August 7, 2023 by Thomas Jentzsch 2 Quote Link to comment Share on other sites More sharing options...
tinco Posted August 7, 2023 Author Share Posted August 7, 2023 doh, thanks! Appreciate you taking a look! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.