Thread: ASM Problem
View Single Post
Old 02-02-2007, 06:01 PM   #6
Gideon Zhi
Senior Member
 
Join Date: Jul 1999
Posts: 499
Default Re: ASM Problem

> It's a JSL => RTL thing. Basically I'm trying to throw a couple event commands in the middle of a normal routine, something to do with the menu loading and unloading. So yeah in the midst of the event executions there's some stack pushing and pulling I'm pretty sure, they're pretty invoved routines. I'm guessing what your saying is that the return locations are stored in the stack, so what I'd need to do is go through and account for whatever is taken off or put on the stack during the subroutine. Or I'm wrong.

This is very likely a stack fault. I (accidentally) do it all the time - push something, then forget to pull it later. Make sure that the stack pointer remains the same on the first op in your routine as it is on the last (your RTL); if it's different at RTL than it is when it first lands in the routine, you have a stack fault. At this point, you need to make sure that you don't pull without pushing first, and that you haven't pushed anything that didn't get pulled at some point.

The other possibility is that your code is mismatching with the M or X flags on the status register. If you're trying to LDA #$0000 when M is set, the game will only LDA #$00 and then you've got an extra byte dangling there which can really, really mess things up. Go through and make sure that you're obeying the flags set on the status register as well.

These are absolutely the two most common mistakes I make when writing 65816, and believe me, I write a lot of 65816.

<P ID="signature"><hr><center>http://agtp.romhack.net<img src=http://agtp.romhack.net/linkage.gif></a>
Aeon Genesis ~ Aiyah! Thank you for the always and always.</center></P>
Gideon Zhi is offline   Reply With Quote