6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 10, 2024 9:48 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Strange JMP's
PostPosted: Tue Aug 19, 2014 5:53 pm 
Offline

Joined: Sat Aug 09, 2014 9:45 pm
Posts: 5
Note: This question is not likely NES specific, but I have not yet seen this happen elsewhere

So I have been looking in FCEUX Debugger (NES) just for fun and came across this stange thing inside, so far, 3 different games.
This example is not from any of the games, but just an illustration of the exact same procedure.

Code:
(start of a subroutine)

F4EF:jmp $f4f2 ;jump to.. next line.
F4F2:foobar code


What purpose could this jump possibly have? If this is residual code from development, why not 3 NOP's instead?
Any reason to do this sort of thing :?:


Top
 Profile  
Reply with quote  
 Post subject: Re: Strange JMP's
PostPosted: Tue Aug 19, 2014 7:49 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
JMP absolute is the easiest way to burn three bytes and three cycles with the same instruction. Maybe that's what they were trying to do?

Mike


Top
 Profile  
Reply with quote  
 Post subject: Re: Strange JMP's
PostPosted: Tue Aug 19, 2014 10:39 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 410
Location: Minnesota
The last line of a macro expansion? Ie., the source code doesn't show it looking like that, but that's what the object code looks like.


Top
 Profile  
Reply with quote  
 Post subject: Re: Strange JMP's
PostPosted: Tue Aug 19, 2014 11:26 pm 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
Could F4F2 be the end of an If type statement with several Elses?


Top
 Profile  
Reply with quote  
 Post subject: Re: Strange JMP's
PostPosted: Wed Aug 20, 2014 1:04 am 
Offline

Joined: Sun Jul 28, 2013 12:59 am
Posts: 235
Another possibility is that it's a "generic" code sequence used in the common part of a bankswitch ROM, and the subsequent part is different in every other code bank. It could be an artifact of whatever development toolset they are using linking multiple files together. As Mike suggested, it could be to burn a specific number of cycles, as certain effects on the NES require fairly precise timing with respect to the raster position. A final possibility is incompetance (never discount this possibility, there is some spectacularly bad code in some of the NES games out there).


Top
 Profile  
Reply with quote  
 Post subject: Re: Strange JMP's
PostPosted: Wed Aug 20, 2014 9:15 am 
Offline
User avatar

Joined: Mon Dec 08, 2008 6:32 pm
Posts: 143
Location: Brighton, England
It could be an output from a compiler for an IF-THEN-ELSE statement, after the THEN section jumping over a non-existant ELSE section. Some compilers are quite good at this sort of unnecessary code.

_________________
Shift to the left,
Shift to the right,
Mask in, Mask Out,
BYTE! BYTE! BYTE!


Top
 Profile  
Reply with quote  
 Post subject: Re: Strange JMP's
PostPosted: Wed Aug 20, 2014 5:26 pm 
Offline

Joined: Sat Aug 09, 2014 9:45 pm
Posts: 5
I too belive this was made by a compiler or by mistake in the source. Like a macro or a IF-THEN.. loop. Also, all of your suggestions could be more or less true as this routine is present in 3 differently specified ROM's. Anyways, off for some practise assembler coding. Thanks alot!


Top
 Profile  
Reply with quote  
 Post subject: Re: Strange JMP's
PostPosted: Thu Aug 21, 2014 8:20 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Another possibility is that the code was written using a relocatable assember and the JMP transfers execution between two routines written in different code modules but which have been linked into consecutive memory locations.

For other Nintendo platforms the Intelligent Systems development suites were the officially recommended toolset (see http://www.intsys.co.jp/english/tools/index.html). These look like relocatable assemblers and C compilers to me.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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: