6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 01, 2024 12:01 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Nov 03, 2003 3:37 pm 
Offline

Joined: Mon Nov 03, 2003 3:25 pm
Posts: 3
I'm trying to write a 6502 emulator in MIPS assembly code and then hopefully in the future, I can implement it with some games. I have the core working, but I'm having trouble with my branch instructions. Is there anyone familiar with MIPS?


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 03, 2003 3:40 pm 
Offline

Joined: Mon Nov 03, 2003 3:25 pm
Posts: 3
I can provide the source code if anyone wants to check it out.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 04, 2003 12:52 pm 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 333
I do more MIPS than is good for me. What problem are you having with the branches? Don't forget that most of them (the ones without the l "likely" suffix) will always execute the following instruction.


Top
 Profile  
Reply with quote  
 Post subject: From Jerod
PostPosted: Tue Nov 04, 2003 2:08 pm 
Offline

Joined: Mon Nov 03, 2003 3:25 pm
Posts: 3
Would you like to see the source code? I've found people have a better time understanding my problems with source code if they see it. It's also because I'm terrible at explaining my problems. In any case, I'm having a hard time conceptualizing how the branch instructions are to be implemented. I thought that it might be a simple matter of just using a move pseudoinstruction but that doesn't seem to work. I think it's little more involved than that(of course!). Maybe I have to have a couple subroutines or whatever you call them in MIPS.


Top
 Profile  
Reply with quote  
 Post subject: Re: From Jerod
PostPosted: Tue Nov 04, 2003 10:04 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
jerod79 wrote:
Would you like to see the source code? I've found people have a better time understanding my problems with source code if they see it. It's also because I'm terrible at explaining my problems. In any case, I'm having a hard time conceptualizing how the branch instructions are to be implemented. I thought that it might be a simple matter of just using a move pseudoinstruction but that doesn't seem to work. I think it's little more involved than that(of course!). Maybe I have to have a couple subroutines or whatever you call them in MIPS.


It helps if you actually tell us, or even give us a hint of, what your problem actually is. :) You're proposing possible solutions above, but without any detail about where your confusion is coming from.

I'm assuming you're refering to how the 6502's branch instructions work. Basically, the operand to a branch instruction is an 8-bit, 2's-compliment signed offset from the address following the branch instruction.

What this means is, if the condition tested by that branch instruction is true, it will add the sign-extended offset operand to the current value of the program counter (remember: after fetching the offset byte, it points immediately after the branch instruction; therefore, if the branch instruction sits at $C000, the PC will point to $C002). Program execution will then resume at the new location. Otherwise, if the tested condition is false, it will continue execution immediately following the instruction ($C002 in my makeshift example above).

Does this help any?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


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: