Views: 19,992,781 |
Home
| Forums
| Uploader
| Wiki
| Object databases
| IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search |
04-19-24 03:07 AM |
Guest: |
0 users reading Introducing: Nintendo Coding! | 1 bot |
Main - NSMB2 hacking - Introducing: Nintendo Coding! | Hide post layouts | New reply |
shibboleet |
| ||
Fire Mario DROP TABLE users; Level: 123 Posts: 4255/4661 EXP: 20875283 Next: 355983 Since: 07-07-12 Last post: 1342 days ago Last view: 355 days ago |
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 |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 6857/9019 EXP: 56218843 Next: 268801 Since: 07-03-12 From: in a box Last post: 7 days ago Last view: 2 days ago |
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.
____________________ NSMBHD - Kafuka - Jul melonDS the most fruity DS emulator there is zafkflzdasd |
MC708 |
|
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 6858/9019 EXP: 56218843 Next: 268801 Since: 07-03-12 From: in a box Last post: 7 days ago Last view: 2 days ago |
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 |
| ||
Cheep-cheep Normal user Level: 29 Posts: 88/188 EXP: 140416 Next: 7469 Since: 03-04-16 From: Ireland Last post: 2309 days ago Last view: 1054 days ago |
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...
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 |
| ||
Fire Mario DROP TABLE users; Level: 123 Posts: 4256/4661 EXP: 20875283 Next: 355983 Since: 07-07-12 Last post: 1342 days ago Last view: 355 days ago |
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 |
| ||
Cheep-cheep Normal user Level: 29 Posts: 89/188 EXP: 140416 Next: 7469 Since: 03-04-16 From: Ireland Last post: 2309 days ago Last view: 1054 days ago |
Posted by MrRean 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 |
| ||
Administrator Level: 45 Posts: 216/466 EXP: 653740 Next: 6424 Since: 09-25-12 From: Germany Last post: 1016 days ago Last view: 170 days ago |
Main - NSMB2 hacking - Introducing: Nintendo Coding! | Hide post layouts | New reply |
Page rendered in 0.037 seconds. (2048KB of memory used) MySQL - queries: 26, rows: 206/206, time: 0.013 seconds. Acmlmboard 2.064 (2018-07-20) © 2005-2008 Acmlm, Xkeeper, blackhole89 et al. |