From e8151da0fcb2f99249be15bea95d8922b5866c1f Mon Sep 17 00:00:00 2001 From: ghidorahrex Date: Tue, 13 Jun 2023 16:52:05 +0000 Subject: [PATCH] GP-3181: Fixed HC05 ldefs and calling conventions for HC05/HCS08 --- .../Processors/HCS08/certification.manifest | 1 + .../HCS08/data/languages/HC05-M68HC05TB.pspec | 30 ++++----- .../HCS08/data/languages/HC05.cspec | 38 ++++++++++++ .../HCS08/data/languages/HC05.ldefs | 8 +-- .../HCS08/data/languages/HC05.pspec | 12 ++-- .../HCS08/data/languages/HCS08.cspec | 61 ++++++++----------- .../HCS08/data/languages/HCS_HC.sinc | 26 +++----- 7 files changed, 99 insertions(+), 77 deletions(-) create mode 100644 Ghidra/Processors/HCS08/data/languages/HC05.cspec diff --git a/Ghidra/Processors/HCS08/certification.manifest b/Ghidra/Processors/HCS08/certification.manifest index 2a2f7ef95a..7da80ef97b 100644 --- a/Ghidra/Processors/HCS08/certification.manifest +++ b/Ghidra/Processors/HCS08/certification.manifest @@ -1,6 +1,7 @@ ##VERSION: 2.0 Module.manifest||GHIDRA||||END| data/languages/HC05-M68HC05TB.pspec||GHIDRA||||END| +data/languages/HC05.cspec||GHIDRA||||END| data/languages/HC05.ldefs||GHIDRA||||END| data/languages/HC05.pspec||GHIDRA||||END| data/languages/HC05.slaspec||GHIDRA||||END| diff --git a/Ghidra/Processors/HCS08/data/languages/HC05-M68HC05TB.pspec b/Ghidra/Processors/HCS08/data/languages/HC05-M68HC05TB.pspec index ba3c607c46..333cbc4bf8 100644 --- a/Ghidra/Processors/HCS08/data/languages/HC05-M68HC05TB.pspec +++ b/Ghidra/Processors/HCS08/data/languages/HC05-M68HC05TB.pspec @@ -6,6 +6,7 @@ + @@ -40,21 +41,22 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - + + + diff --git a/Ghidra/Processors/HCS08/data/languages/HC05.cspec b/Ghidra/Processors/HCS08/data/languages/HC05.cspec new file mode 100644 index 0000000000..002e896f20 --- /dev/null +++ b/Ghidra/Processors/HCS08/data/languages/HC05.cspec @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ghidra/Processors/HCS08/data/languages/HC05.ldefs b/Ghidra/Processors/HCS08/data/languages/HC05.ldefs index 4caea38800..e0c26671f9 100644 --- a/Ghidra/Processors/HCS08/data/languages/HC05.ldefs +++ b/Ghidra/Processors/HCS08/data/languages/HC05.ldefs @@ -6,23 +6,23 @@ size="16" variant="default" version="1.0" - slafile="HC08.sla" + slafile="HC05.sla" processorspec="HC05.pspec" manualindexfile="../manuals/HC05.idx" id="HC05:BE:16:default"> HC05 (6805) Microcontroller Family - + HC05 (6805) Microcontroller Family - M68HC05TB - + diff --git a/Ghidra/Processors/HCS08/data/languages/HC05.pspec b/Ghidra/Processors/HCS08/data/languages/HC05.pspec index 1b96212e9a..60c42e87ba 100644 --- a/Ghidra/Processors/HCS08/data/languages/HC05.pspec +++ b/Ghidra/Processors/HCS08/data/languages/HC05.pspec @@ -19,12 +19,12 @@ - - - - - - + + + + + + diff --git a/Ghidra/Processors/HCS08/data/languages/HCS08.cspec b/Ghidra/Processors/HCS08/data/languages/HCS08.cspec index f0c0752202..451d0d541d 100644 --- a/Ghidra/Processors/HCS08/data/languages/HCS08.cspec +++ b/Ghidra/Processors/HCS08/data/languages/HCS08.cspec @@ -6,45 +6,32 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - diff --git a/Ghidra/Processors/HCS08/data/languages/HCS_HC.sinc b/Ghidra/Processors/HCS08/data/languages/HCS_HC.sinc index 567207d182..3e6d10db34 100644 --- a/Ghidra/Processors/HCS08/data/languages/HCS_HC.sinc +++ b/Ghidra/Processors/HCS08/data/languages/HCS_HC.sinc @@ -108,25 +108,26 @@ oprx16_8_SP: imm16,SP is imm16 & SP { address:2 = SP + imm16:2; export *:1 @if defined(HCS08) opr16a_16: imm16 is imm16 { export *:2 imm16; } -oprx8_16_SP: imm8,SP is imm8 & SP { address:2 = SP + zext(imm8:1); export *:2 address; } +oprx8_16_SP: imm8,SP is imm8 & SP { address:2 = SP + imm8; export *:2 address; } @endif # X or HIX addressing @if defined(HC05) -oprx8_8_X: imm8,X is imm8 & X { address:1 = X + imm8:1; export *:1 address; } -comma_X: ","X is X { address:1 = X; export *:1 address; } +oprx8_8_X: imm8,X is imm8 & X { address:2 = zext(X) + imm8; export *:1 address; } +oprx16_8_X: imm16,X is imm16 & X { address:2 = zext(X) + imm16; export *:1 address; } +comma_X: ","X is X { address:2 = zext(X); export *:1 address; } @endif @if defined(HCS08) || defined(HC08) -oprx8_8_X: imm8,X is imm8 & X { address:2 = HIX + zext(imm8:1); export *:1 address; } -oprx16_8_X: imm16,X is imm16 & X { address:2 = HIX + imm16:2; export *:1 address; } -comma_X: ","X is X { address:2 = HIX; export *:1 address; } +oprx8_8_X: imm8,X is imm8 & X { address:2 = HIX + imm8; export *:1 address; } +oprx16_8_X: imm16,X is imm16 & X { address:2 = HIX + imm16; export *:1 address; } +comma_X: ","X is X { address:2 = HIX; export *:1 address; } @endif @if defined(HCS08) -oprx8_16_X: imm8,X is imm8 & X { address:2 = HIX + zext(imm8:1); export *:2 address; } -oprx16_16_X: imm16,X is imm16 & X { address:2 = HIX + imm16:2; export *:2 address; } +oprx8_16_X: imm8,X is imm8 & X { address:2 = HIX + imm8; export *:2 address; } +oprx16_16_X: imm16,X is imm16 & X { address:2 = HIX + imm16; export *:2 address; } @endif @@ -135,11 +136,7 @@ oprx16_16_X: imm16,X is imm16 & X { address:2 = HIX + imm16:2; export *:2 OP1: iopr8i is op4_6=2; iopr8i { export iopr8i; } OP1: opr8a_8 is op4_6=3; opr8a_8 { export opr8a_8; } OP1: opr16a_8 is op4_6=4; opr16a_8 { export opr16a_8; } - -@if defined(HCS08) || defined(HC08) OP1: oprx16_8_X is op4_6=5; oprx16_8_X { export oprx16_8_X; } -@endif - OP1: oprx8_8_X is op4_6=6; oprx8_8_X { export oprx8_8_X; } OP1: comma_X is op4_6=7 & comma_X { export comma_X; } @@ -151,10 +148,7 @@ op2_opr8a: imm8 is imm8 { export *:1 imm8; } ADDR: opr8a_8 is op4_6=3; opr8a_8 { export opr8a_8; } ADDR: opr16a_8 is op4_6=4; opr16a_8 { export opr16a_8; } -@if defined(HCS08) || defined(HC08) ADDRI: oprx16_8_X is op4_6=5; oprx16_8_X { export oprx16_8_X; } -@endif - ADDRI: oprx8_8_X is op4_6=6; oprx8_8_X { export oprx8_8_X; } ADDRI: comma_X is op4_6=7 & comma_X { export comma_X; } @@ -1772,7 +1766,7 @@ macro Push2(operand) { @if defined(HCS08) || defined(HC08) || defined(HC05) :RSP is op = 0x9C { - SPL = 0xff; + SP = 0xff; } @endif