Skip to content

Commit d97cb13

Browse files
committed
fix JUMPS for all "single instruction" conditions
JUMPS can only do LT, LE and GE comparisons. GT and EQ can be emulated by the assembler generating 2 instructions using supported conditions to achieve the desired effect. For now only the "natively-supported" comparisons are supported. Support for the dual-instruction jumps will be added in an upcoming commit. In other words this change temporarily removes support for the GT and EQ conditions, given they resulted in incorrect instructions anyway. Implementing them correctly requires the upcoming dual-instruction approach.
1 parent a96a7ee commit d97cb13

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

esp32_ulp/opcodes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def arg_qualify(arg):
301301
if 0 <= reg <= 3:
302302
return ARG(REG, reg, arg)
303303
raise ValueError('arg_qualify: valid registers are r0, r1, r2, r3. Given: %s' % arg)
304-
if arg_lower in ['--', 'eq', 'ov', 'lt', 'gt', 'ge']:
304+
if arg_lower in ['--', 'eq', 'ov', 'lt', 'gt', 'ge', 'le']:
305305
return ARG(COND, arg_lower, arg)
306306
try:
307307
return ARG(IMM, int(arg), arg)
@@ -661,10 +661,10 @@ def i_jumps(offset, threshold, condition):
661661
condition = get_cond(condition)
662662
if condition == 'lt':
663663
cmp_op = BRCOND_LT
664-
elif condition == 'gt':
665-
cmp_op = BRCOND_GT
666-
elif condition == 'eq':
667-
cmp_op = BRCOND_EQ
664+
elif condition == 'le':
665+
cmp_op = BRCOND_LE
666+
elif condition == 'ge':
667+
cmp_op = BRCOND_GE
668668
else:
669669
raise ValueError("invalid comparison condition")
670670
_bs.imm = threshold

tests/compat/jumps.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ entry:
66
jumps entry, 42, lt
77
jumps entry, 42, lt
88
jumps later, 42, lt
9+
jumps entry, 42, le
10+
jumps later, 42, le
11+
jumps entry, 42, ge
12+
jumps later, 42, ge
913

1014
jumpr entry, 42, lt
1115
jumpr later, 42, lt

0 commit comments

Comments
 (0)