Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
1 user currently in Rom Hacking: hukka | 2 guests
Acmlm's Board - I2 Archive - Rom Hacking - Sanity check - disassembled code | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
neviksti

Goomba
Level: 8

Posts: 21/25
EXP: 1510
For next: 677

Since: 06-09-05

Since last post: 36 days
Last activity: 30 days
Posted on 07-15-05 11:31 AM Link | Quote
While looking in the XBand ROM I have seen lots of strange code as a result of the C compiler they used. Some of the stranger situations require several double takes before I can figure out what happenned.

However this time it is strange enough that I'm afraid I'm just having a brain fart and misunderstanding. Can someone confirm for me that yes indeed the code block I marked as "NEVER EXECUTED" will indeed always be skipped here?

C4/CE20:	A26D01  	LDX #$016D
C4/CE23: 224000E0 JSR $E00040 ; ?? routine $016D ??
C4/CE27: C90000 CMP #$0000
C4/CE2A: 9003 BCC $CE2F ; how can NotBorrow ever be clear when comparing to 0?
C4/CE2C: 820C00 BRL $CE3B
; { NEVER EXECUTED ??
C4/CE2F: A27C01 LDX #$017C
C4/CE32: 224000E0 JSR $E00040 ; ?? routine $017C ??
C4/CE36: 8501 STA $01
C4/CE38: 826404 BRL $D29F ; return
; }


If I am not insane, and it always skips it ... what the heck c code would compile to that?
The best guess I have is something like
if ( 0 > Routine016D(...) )
{
return Routine017C();
}

where Routine016D returns an unsigned int. But then what did the programmer mean for the code to accomplish?

Hopefully I am just missing something obvious.
MathOnNapkins

Math n' Hacks
Level: 67

Posts: 2059/2189
EXP: 2495887
For next: 96985

Since: 03-18-04
From: Base Tourian

Since last post: 1 hour
Last activity: 32 min.
Posted on 07-15-05 11:43 AM Link | Quote
I believe you are correct, and I had to go back to my own docs to check. CMP does unsigned subtraction: A - operand -> result. If(result < 0) clearcarry( );

This clearly will never happen if I understand this correctly. Could it be that the state of the carry flag before the CMP occurs has some bearing? For example, if you do ADC #$0000, if the carry flag is set it will add one to the result. But I really don't think that is the case for CMP. I will have to consult some other docs.

Edit: If you are right... then the compiler they wrote erroneously used BCC when it should have used BMI.


(edited by MathOnNapkins on 07-15-05 02:46 AM)
Omega45889

Panser
Level: 30

Posts: 289/335
EXP: 148978
For next: 16891

Since: 03-22-04
From: Vancouver Canada

Since last post: 5 days
Last activity: 6 hours
Posted on 07-15-05 12:26 PM Link | Quote
Im not sure, i only have experience with x86 assembly. I could easily figure it out given notes, but i have great confidence in MoN. Im sure hes right.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 5770/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 07-15-05 03:41 PM Link | Quote
The code may not be executed from there, but maybe a jump further back in the routine could jump to it? Or maybe this code has just been 'disabled' for some reason, like Super Mario World's debugging functions (still intact, but never executed).
Violent J

Melon Bug
Level: 41

Posts: 482/749
EXP: 479154
For next: 991

Since: 05-05-04
From: The Lotus Pod

Since last post: 8 hours
Last activity: 8 hours
Posted on 07-17-05 10:26 PM Link | Quote
On the topic of XBand, I got from a friend Doom95, and in it was a really odd file...XBand.ID...Anything it has to do with the same XBand we're talking about?
neviksti

Goomba
Level: 8

Posts: 22/25
EXP: 1510
For next: 677

Since: 06-09-05

Since last post: 36 days
Last activity: 30 days
Posted on 07-18-05 04:46 AM Link | Quote
I believe there was a PC version of the "XBand" as well. I'm not sure what that file is, and I'm not sure how the PC version fit in with the other versions. (I think by then it was owned by MPlayer or something. So maybe it was completely different?)
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Rom Hacking - Sanity check - disassembled code | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.013 seconds.