Commit 18001857 authored by alan's avatar alan
Browse files

fixed shift insturctions

parent dbca3b2e
from pydigital.utils import sextend, as_twos_comp
def alu(op1, op2, alu_fun):
if alu_fun == 0: # NOP
return 0
......@@ -19,9 +20,9 @@ def alu(op1, op2, alu_fun):
elif alu_fun == 8: #sub
return op1 - op2
elif alu_fun == 9: #shift right logical
return op1 >> op2
return sextend(as_twos_comp(op1) >> (0x1f & op2))
elif alu_fun == 10: #shift left logical
return op1 << op2
return sextend(0xffffffff & (as_twos_comp(op1) << (0x1f & op2)))
elif alu_fun == 11: #Or
return op1 | op2
else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment