It is currently Thu May 23, 2019 2:27 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: JSR and RTS
PostPosted: Thu Dec 13, 2018 11:53 am 
Offline
User avatar

Joined: Fri Mar 16, 2018 1:52 pm
Posts: 81
Location: Finland
rainwarrior wrote:
What reason would you have not to implement this feature of JMP if you are aware of it? It's literally only a couple of extra characters on the line of code that would otherwise implement the address fetch.


Technically there is no reason not to if I was making a full emulator, but since I'm making a NSF player, which is partially emulator as someone here mentioned, I just didn't feel like it was needed.

I'm not sure how you would implement this in a couple of extra characters, but I believe the following should still work:
Code:
    public ushort AM_Indirect()
    {
        ushort temp = cv.memory[cv.PC + 2];     //Get the address from byte array after JMP
        temp = (ushort)(temp << 8);
        temp += cv.memory[cv.PC + 1];

        ushort result;

        if((temp & 0x00FF) == 0xFF)       //Test if lower byte of the address is 0xFF
        {
            result = cv.memory[temp - 0xFF];    //Get MSB from start of the page
        }
        else
        {
            result = cv.memory[temp + 1];
        }

        result = (ushort)(result << 8);
        result += cv.memory[temp];     //Get LSB

        return result;
    }


Then the next question:
Is the +1 CPU cycle on page cross defined if the added X or Y register value causes the 16-bit address to go to a new page?


Top
 Profile  
 
 Post subject: Re: JSR and RTS
PostPosted: Thu Dec 13, 2018 12:17 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4076
Location: A world gone mad
Re: couple extra characters: this is commonly accomplished using an increment and modulus, i.e. ((value+1) % 0x0100), to handle the lack of page wrapping bug. If you want an example I can show you one, but that's literally the answer.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group