Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Properly create BLX instruction #1266

Merged
merged 1 commit into from
Jun 29, 2019
Merged

Properly create BLX instruction #1266

merged 1 commit into from
Jun 29, 2019

Conversation

luigoalma
Copy link
Contributor

Sorry I'm coming with a commit post release, but looking at that patch function I made made me think about the maths that were being done.
And this a correction of them.
Better than leaving it uncorrected.
A bit shall never be set on a THUMB -> ARM BLX op, and this bit was what messed with me the first time i made this code but didn't knew about it. Hence now that added & ~(1<<16).
So, the op jump distance math was incorrect because i never fixed that bit, but instead changed the maths of the op distance, originally.
Old code was basically doing (Destination_offset - blx_op_offset+4) / 2 instead of +2, which worked as mentioned on commit message, by sheer luck of offsets.
But now this new code is correct.

Rethinked and revised this function.
This previous one worked by "accident".
More a sheer luck of offsets on current firmware (as of writing)
But now, this is more mathematically correct way of creating a
THUMB -> ARM BLX instruction.
Also setting the new op in a set of 2 u16,
because patching code is in thumb.
@TuxSH TuxSH merged commit 6ed93a1 into LumaTeam:master Jun 29, 2019
@TuxSH
Copy link
Member

TuxSH commented Jun 29, 2019

Release hotfixed with this PR merged, thanks!

Sahlo97 pushed a commit to Sahlo97/Luma3DS that referenced this pull request Dec 9, 2021
Properly create BLX instruction
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants