ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

HCS12 Decompiler Jargon

Open Zephurah opened this issue 3 years ago • 1 comments

Describe the bug Decompiler for HCS12 processors adds unnecessary local variables to the decompiler window when analyzing functions. Not sure where the - 34 info is coming from, nowhere in the instructions is there a subtraction that's relevant to those registers / variables.

To Reproduce Steps to reproduce the behavior: 1.Load given binary 2.Apply either HCS12 or HC12 processor languages 3.Go to memory location 0xd6fc 4.See error

Expected behavior Decompiler window should show a simple line of code that should be as following:

if(NEO_Interrupt_Counter < 35) {
   break;
} else {
   NEO_Interrupt_Counter = 0;

Screenshots image image image image

Attachments Example issue.zip

Environment (please complete the following information):

  • OS: Windows 10
  • Java Version: "18.0.2" 2022-07-19
  • Ghidra Version: 10.1.4
  • Ghidra Origin: GitHub

Zephurah avatar Aug 01 '22 21:08 Zephurah

The subtraction is from CMPB. I don't know anything about HCS12 but cmp instructions in most processors is an unstored subtraction. I'm not saying I'd implement it in sleigh that way, I'd actually avoid it for exactly this reason, but it looks like it has been implemented with subtraction.

astrelsky avatar Aug 02 '22 11:08 astrelsky