def sbf(rd, rs1, rs2):
rd = 0
+ # start setting if no predicate or if 1st predicate bit set
setting_mode = rs2 == x0 or (regs[rs2] & 1)
while i < XLEN:
bit = 1<<i
Pseudo-code:
- def sbf(rd, rs1, rs2):
+ def sif(rd, rs1, rs2):
rd = 0
+ # start setting if no predicate or if 1st predicate bit set
setting_mode = rs2 == x0 or (regs[rs2] & 1)
while i < XLEN:
bit = 1<<i
1 1 0 1 0 1 0 0 a3 contents
sof a2, a3, a0
0 1 x x x x 0 0 a2 contents
+
+Pseudo-code:
+
+ def sof(rd, rs1, rs2):
+ rd = 0
+ # search mode starts on
+ search_mode = True
+ while i < XLEN:
+ bit = 1<<i
+ if search_mode:
+ if regs[rs1] & bit: # found a bit in rs1:
+ regs[rd] |= bit
+ search_mode = False
+ else if rs2 != x0:
+ # only reenable when predicate in use, and bit valid
+ if (regs[rs2] & bit):
+ search_mode = True # back into "search" mode
+ i += 1
+