@@ -636,6 +636,19 @@ def i_jump(target, condition='--'):
636636 raise TypeError ('unsupported operand: %s' % target .raw )
637637
638638
639+ def _jump_relr (threshold , cond , offset ):
640+ """
641+ Equivalent of I_JUMP_RELR macro in binutils-esp32ulp
642+ """
643+ _br .imm = threshold
644+ _br .cmp = cond
645+ _br .offset = abs (offset )
646+ _br .sign = 0 if offset >= 0 else 1
647+ _br .sub_opcode = SUB_OPCODE_BR
648+ _br .opcode = OPCODE_BRANCH
649+ return _br .all
650+
651+
639652def i_jumpr (offset , threshold , condition ):
640653 offset = get_rel (offset )
641654 threshold = get_imm (threshold )
@@ -650,15 +663,16 @@ def i_jumpr(offset, threshold, condition):
650663 elif condition == 'gt' : # gt == ge(threshold+1)
651664 threshold += 1
652665 cmp_op = BRCOND_GE
666+ elif condition == 'eq' : # eq == ge(threshold) but not ge(threshold+1)
667+ # jump over next JUMPR
668+ skip_ins = _jump_relr (threshold + 1 , BRCOND_GE , 2 )
669+ # jump to target
670+ offset -= 1 # adjust for the additional JUMPR instruction
671+ jump_ins = _jump_relr (threshold , BRCOND_GE , offset )
672+ return (skip_ins , jump_ins )
653673 else :
654674 raise ValueError ("invalid comparison condition" )
655- _br .imm = threshold
656- _br .cmp = cmp_op
657- _br .offset = abs (offset )
658- _br .sign = 0 if offset >= 0 else 1
659- _br .sub_opcode = SUB_OPCODE_BR
660- _br .opcode = OPCODE_BRANCH
661- return _br .all
675+ return _jump_relr (threshold , cmp_op , offset )
662676
663677
664678def i_jumps (offset , threshold , condition ):
@@ -680,3 +694,10 @@ def i_jumps(offset, threshold, condition):
680694 _bs .sub_opcode = SUB_OPCODE_BS
681695 _bs .opcode = OPCODE_BRANCH
682696 return _bs .all
697+
698+
699+ def no_of_instr (opcode , args ):
700+ if opcode == 'jumpr' and get_cond (args [2 ]) == 'eq' :
701+ return 2
702+
703+ return 1
0 commit comments