Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in Relative16 addressing? #102

Open
binary1230 opened this issue Mar 26, 2024 · 1 comment
Open

error in Relative16 addressing? #102

binary1230 opened this issue Mar 26, 2024 · 1 comment

Comments

@binary1230
Copy link
Collaborator

binary1230 commented Mar 26, 2024

image

The highlighted cell magenta should (I think) be one byte after it.

the instruction "PER $0003" is using Relative16 addressing, and I think we're going wrong somewhere in CPU65816.cs GetIntermediateAddress():

            case Cpu65C816Constants.AddressMode.Relative16:
            {
                // something may be wrong here with the "PER" instruction (opcode 0x62).
                
                programCounter = data.ConvertPCtoSnes(offset + 3);
                bank = programCounter >> 16;
                var romByte = data.GetRomWord(offset + 1);
                if (!romByte.HasValue)
                    return -1;
                    
                return (bank << 16) | ((programCounter + (short)romByte) & 0xFFFF);
            }

can't track it down at the moment

@gizaha
Copy link

gizaha commented Sep 29, 2024

It's correct. When you ask for RTS it returns one byte after the return address in stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants