Mercurial > repos > blastem
changeset 1707:a16088324f30
Less broken flag calulcation for sub instructions in CPU DSL
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 28 Jan 2019 21:30:23 -0800 |
parents | c2324849a5e5 |
children | 5bfed2eedc9d |
files | cpu_dsl.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/cpu_dsl.py Mon Jan 28 21:16:41 2019 -0800 +++ b/cpu_dsl.py Mon Jan 28 21:30:23 2019 -0800 @@ -240,7 +240,8 @@ decl,name = prog.getTemp(size) dst = prog.carryFlowDst = name prog.lastA = a - prog.lastB = b + prog.lastB = '(-' + b + ')' if op == '-' else b + prog.lastWasSub = op == '-' else: dst = params[2] return decl + '\n\t{dst} = {a} {op} {b};'.format( @@ -312,7 +313,8 @@ resultBit = prog.paramSize(prog.lastDst) elif calc == 'half': resultBit = 4 - myRes = '({a} ^ {b} ^ {res})'.format(a = prog.lastA, b = prog.lastB, res = lastDst) + fmt = '({a} ^ {b} ^ ~{res})' if prog.lastWasSub else '({a} ^ {b} ^ {res})' + myRes = fmt.format(a = prog.lastA, b = prog.lastB, res = lastDst) elif calc == 'overflow': resultBit = prog.paramSize(prog.lastDst) - 1 myRes = '((~({a} ^ {b})) & ({a} ^ {res}))'.format(a = prog.lastA, b = prog.lastB, res = lastDst) @@ -989,6 +991,7 @@ self.carryFlowDst = None self.lastA = None self.lastB = None + self.lastWasSub = False def __str__(self): pieces = []