Skip to content

Fix HCS12X instruction decodings and add missing registers - #3176

Merged
Rot127 merged 2 commits into
capstone-engine:nextfrom
ecom-de:fix-hcs12x
Nov 26, 2026
Merged

Rot127 merged 2 commits into
capstone-engine:nextfrom
ecom-de:fix-hcs12x

Conversation

@JoelLinn

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
    I think the added registers might fall under this?
  • I've added tests that prove my fix is effective or that my feature works (if possible)
    Sequences are taken from Assembler for HC12 V-5.0.32 Build 15249, Sep 7 2015 output with -CPUHCS12XE flag.

Detailed description

  • Some instructions were decoded wrong (CPU12 SUBA/SUBB and friends). Looks like a copy/paste error.
  • Fixed S12X instructions with wrong intermediate formats/ reg involvement and R/W props.
  • Add a bunch of new registers to be able to fully decode TXR and EXG, e.g. loading the condition code register.
    This also adds cpu internal TMP registers but some are already present so I figured it should be fine.
    Note on TMP1: while this exists in CPU12, I think it is unreachable. Only HCS12X added TFR/EXG encodings can reach it. Therefore it is commented as HCS12X.

Test plan

Added tests for new and fixed instructions. Most test changes are HCS12X specific.

Closing issues

@JoelLinn

Copy link
Copy Markdown
Contributor Author

@historicattle If you don't mind please check if this is compliant with your use.

@historicattle

Copy link
Copy Markdown
Contributor

Hi, I added hcs12x support only because it was missing from capstone. Ill take a look at the changes, thanks :)

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (next@8ccbf7e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
arch/M680X/M680XDisassembler.c 81.81% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3176   +/-   ##
=======================================
  Coverage        ?   61.87%           
=======================================
  Files           ?      243           
  Lines           ?    56934           
  Branches        ?    10133           
=======================================
  Hits            ?    35228           
  Misses          ?    16500           
  Partials        ?     5206           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rot127 Rot127 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm. Just check these two comments please.
If you rebase the CI will be green again

Comment thread tests/details/m680x.yaml Resolved
Comment thread tests/details/m680x.yaml Resolved
Signed-off-by: Joel Linn <j.linn@ecom.de>
- Allows full decoding of TXR and EXG for HCS12X.

Signed-off-by: Joel Linn <j.linn@ecom.de>
@Rot127

Rot127 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

@historicattle Do you still want to take a look?

@historicattle

Copy link
Copy Markdown
Contributor

Yes, ill have a look at it right now

@historicattle historicattle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@Rot127 Rot127 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!
Especially for getting all the contributions requirements right from the beginning :) Appreciate it!

@Rot127
Rot127 merged commit 1c22fc0 into capstone-engine:next Nov 26, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants