Kuribo64
Views: 8,769,595 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
09-25-18 10:44 PM
Guest:

0 users reading Introducing: Nintendo Coding! | 1 bot

Main - NSMB2 hacking - Introducing: Nintendo Coding! New reply


shibboleet
Posted on 10-22-16 11:39 PM (rev. 5 of 10-23-16 09:21 AM) Link | #79056
I've presented "dumb assembly" code before, but turns out it actually had a use.

here, no. not even close. It sets up the stack and shit, which is pretty much any function. but what's in the function is what's stupid.

If moves 1 into r0. Okay, normal. But now, it compares r0 to 1. Then if it isn't equal, it makes it 1. If you're confused, here's the C++ code for it:

void StupidFunction1()
{
r0 = 1;

if (r0 != 1)
{
r0 = 1; // this is never ran
}
}

And here's the actual function in assembly:
RAM:004573BC StupidFunction1 ; CODE XREF: sub_47EB10+4p
RAM:004573BC STMFD SP!, {R4,LR}
RAM:004573C0 MOV R0, #1
RAM:004573C4 CMP R0, #0
RAM:004573C8 MOVNE R0, #1
RAM:004573CC LDMFD SP!, {R4,PC}
RAM:004573CC
RAM:004573CC ; End of function StupidFunction1

oh look, another one!

void someFunction(u32 shit)
{
if (shit != 0)
{
shit = 1;
}
}


RAM:0047EB10 StupidFunction2 ; DATA XREF: RAM:00599590o
RAM:0047EB10 ; RAM:005A3C1Co
RAM:0047EB10 ; RAM:005A7600o
RAM:0047EB10 ; RAM:005C5ABCo
RAM:0047EB10 STMFD SP!, {R4,LR}
RAM:0047EB14 BL StupidFunction1
RAM:0047EB14
RAM:0047EB18 CMP R0, #0
RAM:0047EB1C MOVNE R0, #1
RAM:0047EB20 LDMFD SP!, {R4,PC}
RAM:0047EB20
RAM:0047EB20 ; End of function StupidFunction2


____________________
a

StapleButter
Posted on 10-23-16 08:32 AM (rev. 2 of 10-23-16 08:34 AM) Link | #79067
There are a ton of those examples in their code. We should collect them and put them up somewhere. It's like they don't know how to configure a compiler.


Anyway, the second example is wrong.

if (shit != 0) shit = 1;


____________________
NSMBHD - Kafuka - Jul

communism

MC708
(post deleted) #79068

StapleButter
Posted on 10-23-16 08:37 AM (rev. 2 of 10-23-16 08:38 AM) Link | #79069
Compiled code doesn't include function or variable names. Those names were entered in IDA. -- line irrelevant because derpster deleted his post


Also, I didn't notice that StupidFunction2 calls StupidFunction1. A decent optimization pass would eliminate the call entirely and just return 1 directly. Less smart optimization would leave the call but atleast make StupidFunction1 return 1 directly. This is like they, uh, applied no optimization at all.

____________________
NSMBHD - Kafuka - Jul

communism

MC708
Posted on 10-23-16 08:40 AM (rev. 3 of 10-23-16 08:44 AM) Link | #79072
Wait, so if I'm correct, they changed a variable (or whatever it is after its compiled) to 1, and then checked if its 1? But it's guaranteed to be 1! What a waste of data...

Just like EnCryptiX.

Also I deleted the post because it was a stupid question, I realised that Nintendo wouldn't randomly call it stupid in their code.

____________________

Sorry for the maintenance -- we'll be back soon!

shibboleet
Posted on 10-23-16 09:23 AM (rev. 2 of 10-23-16 09:23 AM) Link | #79074
i literally explain it in the first post.

also, you don't get assigned "variables", just whatever the coder names it gets trashed. The only things that are kept through a compiler are symbols

____________________
a

MC708
Posted on 10-23-16 09:24 AM Link | #79075
Posted by MrRean
i literally explain it in the first post.

I was just checking if I had correctly understood what you said in your first post, sorry

____________________

Sorry for the maintenance -- we'll be back soon!

RicBent
Posted on 10-23-16 11:56 AM Link | #79079

CMP R0, #0
MOVEQ R0, #0

yea, this surely does a lot.

____________________
GitHub - YouTube - NSMBHD


Main - NSMB2 hacking - Introducing: Nintendo Coding! New reply

Page rendered in 0.019 seconds. (2048KB of memory used)
MySQL - queries: 26, rows: 204/204, time: 0.013 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.