1 def bmask(bm
, RA
, RB
=None, zero
=False, XLEN
=64):
2 mask
= RB
if RB
is not None else ((1<<XLEN
)-1)
5 a1
= ra
if mode1
else ~ra
6 mode2
= (bm
>> 1) & 0b11
7 if mode2
== 0: a2
= -ra
8 if mode2
== 1: a2
= ra
-1
9 if mode2
== 2: a2
= ra
+1
10 if mode2
== 3: a2
= ~
(ra
+1)
13 mode3
= (bm
>> 3) & 0b11
14 if mode3
== 0: RS
= a1 | a2
15 if mode3
== 1: RS
= a1
& a2
16 if mode3
== 2: RS
= a1 ^ a2
17 if mode3
== 3: RS
= 0 # RESERVED
20 # put back masked-out bits of RA
24 SBF
= 0b01010 # set before first
25 SOF
= 0b01001 # set only first
26 SIF
= 0b10000 # set including first 10011 also works no idea why yet