Skip to content
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

Add ADD (zx imm12), NOP, MOV (rs), LDA, TBB, TBH, MOV (zx imm16) and CLZ thumb instructions #3683

Merged
merged 2 commits into from Sep 10, 2022

Conversation

gdkchan
Copy link
Member

@gdkchan gdkchan commented Sep 8, 2022

Implements the following T32 instructions:

  • ADD (zero-extended 12-bit immediate variant)
  • NOP
  • MOV (register shifted by register variant)
  • MOV (zero-extended 16-bit immediate variant)
  • TBB/TBH (Table Branch Byte/Halfword, those only exists on T32)
  • LDA (Load Acquire)
  • CLZ (Count Leading Zeros)

Additionally fixes some existing implementations:

  • Fix T16 BLX using Blx rather than Blxr. It was causing InvalidCastException because Blx expects an immediate address, not a register.
  • Fix T16 CBZ/CBNZ instructions control flow. IsAarch32UncoditionalBranch was returning true for those instructions, which would cause the code immediately following it (branch not taken path) to be skipped and was silently generating incorrect code.
  • Fix T32 LDRD/STRD encoding. It was overlapping with LDA/STL in the OpCodeTable.
  • Fix T32 LDRD/STRD immediate decoding. It was not being multiplied by 4.
  • Fix T32 LDRD/STRD Rt2 register. Unlike the A32 variant, on Thumb the Rt2 register can be explicitly specified on the instruction, instead of being the register immediately after Rt. The InstEmit function and OpCode interfaces were changed to account for this.

This allows Vita2HOS to launch again, it goes as far as the old version that did not use as many Thumb instructions. I planned to get more work done here, but since this contains some important fixes, I decided to PR it sooner rather than later.

@gdkchan gdkchan added cpu Related to ARMeilleure fix Fix something labels Sep 8, 2022
Copy link
Member

@riperiperi riperiperi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

…zx imm16) and CLZ thumb instructions, fix LDRD, STRD, CBZ, CBNZ and BLX (reg)
@gdkchan gdkchan force-pushed the fix-thumb branch 2 times, most recently from f8c38f3 to 11eae60 Compare September 10, 2022 00:51
@gdkchan gdkchan merged commit c64524a into Ryujinx:master Sep 10, 2022
@gdkchan gdkchan deleted the fix-thumb branch September 10, 2022 01:09
@xerpi
Copy link

xerpi commented Sep 10, 2022

Thank you very much for the PR, much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpu Related to ARMeilleure fix Fix something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants