@@ -675,6 +675,19 @@ def i_jumpr(offset, threshold, condition):
675
675
return _jump_relr (threshold , cmp_op , offset )
676
676
677
677
678
+ def _jump_rels (threshold , cond , offset ):
679
+ """
680
+ Equivalent of I_JUMP_RELS macro in binutils-esp32ulp
681
+ """
682
+ _bs .imm = threshold
683
+ _bs .cmp = cond
684
+ _bs .offset = abs (offset )
685
+ _bs .sign = 0 if offset >= 0 else 1
686
+ _bs .sub_opcode = SUB_OPCODE_BS
687
+ _bs .opcode = OPCODE_BRANCH
688
+ return _bs .all
689
+
690
+
678
691
def i_jumps (offset , threshold , condition ):
679
692
offset = get_rel (offset )
680
693
threshold = get_imm (threshold )
@@ -685,19 +698,27 @@ def i_jumps(offset, threshold, condition):
685
698
cmp_op = BRCOND_LE
686
699
elif condition == 'ge' :
687
700
cmp_op = BRCOND_GE
701
+ elif condition == 'eq' : # eq == le but not lt
702
+ skip_cond = BRCOND_LT
703
+ jump_cond = BRCOND_LE
704
+
705
+ # jump over next JUMPS
706
+ skip_ins = _jump_rels (threshold , skip_cond , 2 )
707
+ # jump to target
708
+ offset -= 1 # adjust for the additional JUMPS instruction
709
+ jump_ins = _jump_rels (threshold , jump_cond , offset )
710
+
711
+ return (skip_ins , jump_ins )
688
712
else :
689
713
raise ValueError ("invalid comparison condition" )
690
- _bs .imm = threshold
691
- _bs .cmp = cmp_op
692
- _bs .offset = abs (offset )
693
- _bs .sign = 0 if offset >= 0 else 1
694
- _bs .sub_opcode = SUB_OPCODE_BS
695
- _bs .opcode = OPCODE_BRANCH
696
- return _bs .all
714
+ return _jump_rels (threshold , cmp_op , offset )
697
715
698
716
699
717
def no_of_instr (opcode , args ):
700
718
if opcode == 'jumpr' and get_cond (args [2 ]) == 'eq' :
701
719
return 2
702
720
721
+ if opcode == 'jumps' and get_cond (args [2 ]) == 'eq' :
722
+ return 2
723
+
703
724
return 1
0 commit comments