esaulenka / ghidra_v850

Ghidra support for Renesas V850 MCUs
MIT License
66 stars 26 forks source link

New G4MH core #37

Open ikuyas opened 4 months ago

ikuyas commented 4 months ago

I'm using "Ghidra processor module for Renesas v850" on RH850/U2A code. It couldn't disassemble the following binary codes. 0019e018 e9 77 20 10 ldsr param_4,Sr142,2 I made a patch for v850e3.sinc, then it could dissassemble as the above. But "Sr142" is a temporary name, it should be "PLMR". According to the "RH850/U2A-EVA Group User’s Manual: Hardware", many system registers were extended in U2A. Could you please fix them?

ikuyas commented 4 months ago

In G4MH, the following instructions were extended from G3KH, at least LD.B,LD.BU,LD.H,LD.HU,LD.W,ST.B,ST.H,ST.W I am using a heuristic way to find the differences, as I cannot find the official documentation where the differences are listed.

esaulenka commented 4 months ago

Hi!

many system registers were extended

did you find the full list? In the 'RH850/U2A-EVA Group User’s Manual: Hardware' I see only a few mentions of PLMR, and it's easy to miss some other registers.

I am using a heuristic way

For the RH850 I looked into gcc sources (in particular, objdump). It's much harder to read than official spec (and it has no any explanations what is the purpose of the instruction), but if you will find such gcc branch, it will help a lot.

ikuyas commented 4 months ago

The added system register I found is as follows

selID = 2
Sr14   PLMR
Sr18   RBIP

selID = 5
Sr12   MCI
Sr16   MPIDX
Sr24   MPID0
Sr25   MPID1
Sr26   MPID2
Sr27   MPID3
Sr28   MPID4
Sr29   MPID5
Sr30   MPID6
Sr31   MPID7

selID = 11, 14, 15
P317 in RH850/U2A-EVA Group User’s Manual: Hardware Rev.1.40 Aug. 2023
3.2.3.8 Count Function Registers

The added instructions are:

(3) LD.B [reg1]+, reg3 
(4) LD.B [reg1]−, reg3

(3) LD.BU [reg1]+, reg3 
(4) LD.BU [reg1]−, reg3 

(3) LD.H [reg1]+, reg3 
(4) LD.H [reg1]−, reg3 

(3) LD.HU [reg1]+, reg3
(4) LD.HU [reg1]−, reg3

(3) LD.W [reg1]+ , reg3 
(4) LD.W [reg1]– , reg3

(3) ST.B reg3, [reg1]+ 
(4) ST.B reg3, [reg1]−

(3) ST.H reg3, [reg1]+ 
(4) ST.H reg3, [reg1]−

(3) ST.W reg3, [reg1]+ 
(4) ST.W reg3, [reg1]−