Replies: 5 comments 6 replies
-
I'm not familiar with the processor, but the description in the software manual looks pretty straight-forward. I think the description here is incorrect.
This constructor here doesn't look right at all. CBR is based on the carry of the complete operation, but somehow it's being added at the end of the instruction. It should probably work better if you replaced the last line with Here's how I would re-write the operation:
|
Beta Was this translation helpful? Give feedback.
-
Hi, thanks, much appreciated, I gave it a go, the decompiler output is different, but unfortunately still messy... diassembly:
decompiler:
An sh4 example looks like this... disassembly:
decomplier:
Could it have something to do with the way the flag is defined? In m32r it's like this...
In superH4 it's like this...
...and...
(I tried duplicating the 5 calculation steps above in the M32R file, but got the same messy decomplier output) Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Honestly don't recall ever seeing a carry instruction in any of the day to day RE I do, just from implementing SLEIGH, so I don't know how bad that really looks in terms of the PCODE output from an instruction, or if the high pcode/decompiler cleans up a lot. I have sometimes wondered if the |
Beta Was this translation helpful? Give feedback.
-
@rimwall Your code looks like it doesn't know what the input carry flag is. Perhaps the decompiler could do some simplification if it knew that it was 0 or 1 coming in. If it's just testing if the lowest bit was set, the carry flag should be set to 1 here? |
Beta Was this translation helpful? Give feedback.
-
As a follow up, I have figured out the following:
I have tried to implement this in the M32R language based on the following example from the language docs. However, I can't seem to get it to work: Example from the language docs:
The changes I have made to the m32r.sinc file are as follows. I had to introduce a "_B" series of alternate fields so that the equality Rdest_B=Rsrc_B was within the same token - it would not compile if the equality acted on two tokens on either side of a concatenation operator (;).
Updated files here: https://github.com/rimwall/ghidra-m32r The above changes compile ok. However, Ghidra is unable to disassemble the instruction. The example below with a value of 0x00 0x90 should disassemble to TST31 R0. But Ghidra doesn't recognise the bit pattern. What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
-
Context:
The M32R *.sinc definition is:
The Ghidra disassembler is clean...
...but the decompiler output is messy...
Any help greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions