Merge remote-tracking branch

'origin/GP-3606_ghidorahrex_6x09_flags_and_stack_fixes' into patch
(Closes #5508)
This commit is contained in:
ghidra1 2023-07-10 19:41:57 -04:00
commit c3cc2630f2

View File

@ -508,56 +508,69 @@ macro clear(op)
macro addition(reg, op)
{
$(C) = carry(reg, op);
$(V) = scarry(reg, op);
local tmp = reg;
local val = op;
$(C) = carry(tmp, val);
$(V) = scarry(tmp, val);
reg = reg + op;
tmp = tmp + val;
setNZFlags(reg);
setNZFlags(tmp);
reg = tmp;
}
macro additionWithCarry(reg, op)
{
local carryIn = zext($(C));
local tmp = reg;
local val = op;
local mask = 0x0F; # Low nibble mask
local tmpResult = reg + op;
local result = tmp + val;
$(H) = (((reg & mask) + (op & mask) + carryIn) >> 4) & 1;
$(C) = carry(reg, op) || carry(tmpResult, carryIn);
$(V) = scarry(reg, op) ^^ scarry(tmpResult, carryIn);
$(H) = (((tmp & mask) + (val & mask) + carryIn) >> 4) & 1;
$(C) = carry(tmp, val) || carry(result, carryIn);
$(V) = scarry(tmp, val) ^^ scarry(result, carryIn);
reg = tmpResult + carryIn;
tmp = result + carryIn;
setNZFlags(reg);
setNZFlags(tmp);
reg = tmp;
}
macro subtraction(reg, op)
{
$(V) = sborrow(reg, op);
reg = reg - op;
setNZFlags(reg);
$(C) = (reg < op);
local tmp = reg;
local val = op;
$(V) = sborrow(tmp, val);
$(C) = (tmp < val);
tmp = tmp - val;
setNZFlags(tmp);
reg = tmp;
}
macro subtractionWithCarry(reg, op)
{
local carryIn = zext($(C));
local tmpResult = reg - op;
local tmp = reg;
local val = op;
local tmpResult = tmp - val;
$(C) = (reg < op) || (tmpResult < carryIn);
$(V) = sborrow(reg, op) ^^ sborrow(tmpResult, carryIn);
reg = tmpResult - carryIn;
setNZFlags(reg);
$(C) = (tmp < val) || (tmpResult < carryIn);
$(V) = sborrow(tmp, val) ^^ sborrow(tmpResult, carryIn);
tmp = tmpResult - carryIn;
setNZFlags(tmp);
reg = tmp;
}
macro compare(reg, op)
{
$(V) = sborrow(reg, op);
local tmp = reg - op;
local tmp = reg;
local val = op;
$(V) = sborrow(tmp, val);
$(C) = (tmp < val);
tmp = tmp - val;
setNZFlags(tmp);
$(C) = (tmp < op);
reg = tmp;
}
macro logicalAnd(reg, op)
@ -612,9 +625,8 @@ macro Push1(reg, op)
# Push 2 byte operand op2
macro Push2(reg, op)
{
reg = reg - 1;
reg = reg - 2;
*:2 reg = op;
reg = reg - 1;
}
# Pull 1 byte operand op1
@ -627,9 +639,8 @@ macro Pull1(reg, op)
# Pull 2 byte operand op2
macro Pull2(reg, op)
{
reg = reg + 1;
op = *:2 reg;
reg = reg + 1;
reg = reg + 2;
}
macro PushUYXDpD()