Mercurial > repos > blastem
changeset 1711:87d4f0b4bf1d
Actually correct overflow flag calculation in CPU DSL
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 29 Jan 2019 21:26:39 -0800 |
parents | 2344b3650b38 |
children | 0a9a88b3d061 |
files | cpu_dsl.py |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/cpu_dsl.py Mon Jan 28 22:56:43 2019 -0800 +++ b/cpu_dsl.py Tue Jan 29 21:26:39 2019 -0800 @@ -241,7 +241,7 @@ dst = prog.carryFlowDst = name prog.lastA = a prog.lastB = b - prog.lastBFlow = '(-' + b + ')' if op == '-' else b + prog.lastBFlow = b if op == '-' else '(~{b})'.format(b=b) else: dst = params[2] return decl + '\n\t{dst} = {a} {op} {b};'.format( @@ -316,7 +316,7 @@ myRes = '({a} ^ {b} ^ {res})'.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.lastBFlow, res = lastDst) + myRes = '((({a} ^ {b})) & ({a} ^ {res}))'.format(a = prog.lastA, b = prog.lastBFlow, res = lastDst) else: resultBit = int(resultBit) if type(storage) is tuple: @@ -440,8 +440,8 @@ decl,name = prog.getTemp(size) dst = prog.carryFlowDst = name prog.lastA = params[0] - prog.lastB = '({b} ^ ({check} ? 1 : 0))'.format(b = params[1], check = carryCheck) - prog.lastBFlow = prog.lastB + prog.lastB = '({b} + ({check} ? 1 : 0))'.format(b = params[1], check = carryCheck) + prog.lastBFlow = '(~{b})'.format(b=params[1]) else: dst = params[2] return decl + '\n\t{dst} = {a} + {b} + ({check} ? 1 : 0);'.format(dst = dst, @@ -469,7 +469,7 @@ dst = prog.carryFlowDst = name prog.lastA = params[1] prog.lastB = '({b} ^ ({check} ? 1 : 0))'.format(b = params[0], check = carryCheck) - prog.lastBFlow = '((-{b}) ^ ({check} ? -1 : 0))'.format(b = params[0], check = carryCheck) + prog.lastBFlow = params[0] else: dst = params[2] return decl + '\n\t{dst} = {b} - {a} - ({check} ? 1 : 0);'.format(dst = dst,