Kuribo64
Views: 19,992,922 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
04-19-24 03:56 AM
Guest:

0 users reading Introducing: Nintendo Coding! | 1 bot

Main - NSMB2 hacking - Introducing: Nintendo Coding! Hide post layouts | New reply


shibboleet
Posted on 10-23-16 03:39 AM (rev. 5 of 10-23-16 01:21 PM) 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

Arisotura
Posted on 10-23-16 12:32 PM (rev. 2 of 10-23-16 12:34 PM) 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
melonDS the most fruity DS emulator there is

zafkflzdasd

MC708
(post deleted) #79068

Arisotura
Posted on 10-23-16 12:37 PM (rev. 2 of 10-23-16 12:38 PM) 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
melonDS the most fruity DS emulator there is

zafkflzdasd

MC708
Posted on 10-23-16 12:40 PM (rev. 3 of 10-23-16 12:44 PM) 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 01:23 PM (rev. 2 of 10-23-16 01:23 PM) 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 01:24 PM 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 03:56 PM Link | #79079

CMP R0, #0
MOVEQ R0, #0

yea, this surely does a lot.

____________________
GitHub - YouTube - NSMBHD


Main - NSMB2 hacking - Introducing: Nintendo Coding! Hide post layouts | New reply

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