mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-15 03:40:56 +01:00
barrel shifter handle rotation of 0 bits
This commit is contained in:
parent
0f0d2a4c20
commit
e1f348ac1c
1 changed files with 4 additions and 0 deletions
|
@ -87,6 +87,7 @@ class CPU
|
|||
# Logical shift left
|
||||
def lsl(word : Word, bits : Int, set_conditions : Bool) : Word
|
||||
log "lsl - word:#{hex_str word}, bits:#{bits}"
|
||||
return word if bits == 0
|
||||
@cpsr.carry = bit?(word, 32 - bits) if set_conditions
|
||||
word << bits
|
||||
end
|
||||
|
@ -94,6 +95,7 @@ class CPU
|
|||
# Logical shift right
|
||||
def lsr(word : Word, bits : Int, set_conditions : Bool) : Word
|
||||
log "lsr - word:#{hex_str word}, bits:#{bits}"
|
||||
bits = 32 if bits == 0
|
||||
@cpsr.carry = bit?(word, bits - 1) if set_conditions
|
||||
word >> bits
|
||||
end
|
||||
|
@ -101,6 +103,7 @@ class CPU
|
|||
# Arithmetic shift right
|
||||
def asr(word : Word, bits : Int, set_conditions : Bool) : Word
|
||||
log "asr - word:#{hex_str word}, bits:#{bits}"
|
||||
bits = 32 if bits == 0
|
||||
@cpsr.carry = bit?(word, bits - 1) if set_conditions
|
||||
word >> bits | (0xFFFFFFFF_u32 &* (word >> 31)) << (32 - bits)
|
||||
end
|
||||
|
@ -108,6 +111,7 @@ class CPU
|
|||
# Rotate right
|
||||
def ror(word : Word, bits : Int, set_conditions : Bool) : Word
|
||||
log "ror - word:#{hex_str word}, bits:#{bits}"
|
||||
return word if bits == 0
|
||||
@cpsr.carry = bit?(word, bits - 1) if set_conditions
|
||||
word >> bits | word << (32 - bits)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue