-
Notifications
You must be signed in to change notification settings - Fork 34
resource: Implement decodeSZSNxAsm64_
#196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Do we allow assembly in the project? I am referring to this to be exact https://botw.link/about#how-can-i-help
|
That's for BotW, not sead. We don't have a clear policy on this for sead Personally I think that it's a bit iffy but we're already doing the same thing for Wii U... |
Also I'm not sure if this should be inline assembly or a separate .s file. If we can't get regalloc to work the same I think that suggests it's not inline asm |
For Wii U, it's definitely inline assembly for several reasons, like the double |
I'm a bit suspicious of that "mov #1000", followed by "sub #1" - even IDA displayed that as "mov #FFF" straight-away, so I don't see how the compiler would miss this optimization opportunity if not explicitly listed in the assembly, but I'll do some testing later. |
Next to the argument already listed above, here's another one: |
While I agree that this definitely smells like handwritten assembly, that argument is not quite true! Compilers can make mistakes too and/or UB can cause compilers to generate dumb code. |
It's assembly |
I mean, yeah, it's literally in the function name. The debate is whether it's a separate text file or inline assembly (I'm certain of the latter). |
I tried writing it as nice as possible, using templates for the usages of |
Any more comments on this, or should this be merged? |
Based on the name, this function just contains a bunch of assembly - so I didn't even bother trying to re-implement it in C++, but just copied the output of the disassembler here straight-away.
The labels are defined using just
[number]:
to avoid creating actual labels in the executable for them. This also means that references to them must be suffixed with eitherb
for backwards-search orf
for forwards-search, which is why some of those jump targets look weird.Additionally, I tried properly defining inputs/outputs of the assembly block. The auto-allocation for
src
anddst
works fine here, buterror
doesn't want to pick the actual targetw2
- either it picksw0
and generates conflicts withdst
inx0
(=> mismatch), or when marking it as clobbering variable (=&r
), it decides to pickw8
instead, which is also not our target - so I manually assigned it tow2
to match the code here.At label
6
, two more instructions are auto-generated (mov w0, w2 ; ret
), thanks to the setup of the assembly block.This change is