Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3621: Fixed 6x09 left-shift instruction flags

ghidorahrex8cd3a31afaff
diff --git a/Ghidra/Processors/MC6800/data/languages/6x09.sinc b/Ghidra/Processors/MC6800/data/languages/6x09.sinc
index 035e5ab4eb..b155b12337 100644
--- a/Ghidra/Processors/MC6800/data/languages/6x09.sinc
+++ b/Ghidra/Processors/MC6800/data/languages/6x09.sinc
@@ -434,6 +434,15 @@ macro complement(op)
setNZFlags(op);
}
+# Signed shift right.
+# P-code INT_SRIGHT.
+macro arithmeticShiftRight(op)
+{
+ $(C) = op & 1;
+ op = (op s>> 1);
+ setNZFlags(op);
+}
+
macro logicalShiftRight(op)
{
$(C) = op & 1;
@@ -450,31 +459,25 @@ macro rotateRightWithCarry(op)
setNZFlags(op);
}
-macro rotateLeftWithCarry(op)
+macro logicalShiftLeft(op)
{
- local carryIn = $(C);
- $(C) = op >> 7;
- op = (op << 1) | carryIn;
+ local tmp = (op >> 7);
+ $(C) = tmp;
+ op = op << 1;
+ $(V) = tmp ^ (op >> 7);
setNZFlags(op);
}
-# Signed shift right.
-# P-code INT_SRIGHT.
-macro arithmeticShiftRight(op)
+macro rotateLeftWithCarry(op)
{
- $(C) = op & 1;
- op = (op s>> 1);
+ local carryIn = $(C);
+ local tmp = (op >> 7);
+ $(C) = tmp;
+ op = (op << 1) | carryIn;
+ $(V) = tmp ^ (op >> 7);
setNZFlags(op);
}
-macro logicalShiftLeft(op)
-{
- $(C) = (op >> 7);
- op = op << 1;
- $(Z) = (op == 0);
- $(N) = (op >> 7);
-}
-
macro increment(op)
{
$(V) = (op == 0x7F);
@@ -1204,7 +1207,7 @@ macro PushEntireState()
:ADDB OP1 is (op=0xCB | op=0xDB | op=0xEB | op=0xFB) ... & OP1
{
- setHFlag(A, OP1);
+ setHFlag(B, OP1);
addition(B, OP1);
}