Skip to content

Commit

Permalink
GP-2650: fixed issues with 6x09 jump calculations.
Browse files Browse the repository at this point in the history
  • Loading branch information
GhidorahRex committed Jan 19, 2023
1 parent c2440f9 commit 55ca546
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions Ghidra/Processors/MC6800/data/languages/6x09.sinc
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ EA: "["addr",PCR]" is noOffset5=1 & idxMode=0b11101; simm16 [ addr = inst_next +
export eaddr;
}

EA: "["addr"]" is noOffset5=1 & idxReg=0b00 & idxMode=0b11111; simm16 [ addr = inst_next; ]
EA: "["imm16"]" is noOffset5=1 & idxReg=0b00 & idxMode=0b11111; imm16
{
local eaddr:2 = inst_next;
local eaddr:2 = imm16;
eaddr = *:2 eaddr;
export eaddr;
}
Expand Down Expand Up @@ -366,6 +366,7 @@ OP2: "#"imm16 is (op47=8 | op47=0xC); imm16
{
export *[const]:2 imm16;
}

OP2: "<"imm8 is (op47=0 | op47=9 | op47=0xD); imm8
{
local tmp:2 = (zext(DP) << 8) + imm8;
Expand All @@ -381,6 +382,21 @@ OP2: imm16 is (op47=7 | op47=0xB | op47=0xF); imm16
export *:2 imm16;
}

#JMP and JSR treat the direct/indexed/extended address modes differently
OP2J: "<"imm8 is (op47=0 | op47=9); imm8
{
local tmp:2 = (zext(DP) << 8) + imm8;
export tmp;
}
OP2J: EA is (op47=6 | op47=0xA); EA
{
export EA;
}
OP2J: imm16 is (op47=7 | op47=0xB ); imm16
{
export imm16;
}

################################################################
# Macros
################################################################
Expand Down Expand Up @@ -586,8 +602,8 @@ macro storeRegister(reg, op)
# Push 1 byte operand op1
macro Push1(reg, op)
{
*:1 reg = op;
reg = reg - 1;
*:1 reg = op;
}

# Push 2 byte operand op2
Expand Down Expand Up @@ -803,9 +819,9 @@ macro PushEntireState()
test(OP1);
}

:JMP OP2 is (op=0x0E | op=0x6E | op=0x7E) ... & OP2
:JMP OP2J is (op=0x0E | op=0x6E | op=0x7E) ... & OP2J
{
local target = OP2;
local target = OP2J;
goto [target];
}

Expand Down Expand Up @@ -1205,11 +1221,11 @@ macro PushEntireState()
call REL;
}

:JSR OP2 is (op=0x9D | op=0xAD | op=0xBD) ... & OP2
:JSR OP2J is (op=0x9D | op=0xAD | op=0xBD) ... & OP2J
{
local addr:2 = inst_next;
Push2(S, addr);
local target = OP2;
local target = OP2J;
call [target];
}

Expand Down

0 comments on commit 55ca546

Please sign in to comment.