Skip to content

Commit 101988c

Browse files
Fix verbose print of instrs that omit low imm bits
Modify `unscatter` so it works for instructions that do not encode the lowest bits of the immediate value provided to them. This issue has been hidden because many instructions have been encoded using the lower immediate bits rather than upper immediate bits (e.g. `imm[19:0]` rather than `imm[31:12]` for `lui`), and others (which do omit lower immediate bits) are not included in disassembly output (e.g. `c_lui` with empty `rv_c_disass`). See also: CTSRD-CHERI#41
1 parent 09fa1c6 commit 101988c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/InstrCodec.hs

+4-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ subst :: Mapping -> BitList -> BitList
122122
subst m bs = unscatter [(bi, bs !! si) | (bi, si) <- m]
123123

124124
-- Join a scattered bit-string, complain if gaps or overlapping
125-
unscatter :: [(Int, a)] -> [a]
126-
unscatter = join 0
125+
unscatter :: [(Int, Bool)] -> BitList
126+
unscatter m = zeros ++ join lsb m
127127
where
128+
lsb = minimum [j | (j, _) <- m]
129+
zeros = take lsb $ repeat False
128130
join _ [] = []
129131
join i m =
130132
case [x | (j, x) <- m, i == j] of

0 commit comments

Comments
 (0)