@@ -675,6 +675,19 @@ def i_jumpr(offset, threshold, condition):
675675 return _jump_relr (threshold , cmp_op , offset )
676676
677677
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+
678691def i_jumps (offset , threshold , condition ):
679692 offset = get_rel (offset )
680693 threshold = get_imm (threshold )
@@ -685,19 +698,27 @@ def i_jumps(offset, threshold, condition):
685698 cmp_op = BRCOND_LE
686699 elif condition == 'ge' :
687700 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 )
688712 else :
689713 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 )
697715
698716
699717def no_of_instr (opcode , args ):
700718 if opcode == 'jumpr' and get_cond (args [2 ]) == 'eq' :
701719 return 2
702720
721+ if opcode == 'jumps' and get_cond (args [2 ]) == 'eq' :
722+ return 2
723+
703724 return 1
0 commit comments