Skip to content

Commit b2cdb24

Browse files
committed
implement the remaining "single instruction" JUMPR conditions
JUMPR can only do LT and GE comparisons, so the assembler implements LE and GT conditions by using the LT and GE conditions respectively and by adjusting the threshold accordingly.
1 parent d97cb13 commit b2cdb24

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

esp32_ulp/opcodes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ def i_jumpr(offset, threshold, condition):
644644
cmp_op = BRCOND_LT
645645
elif condition == 'ge':
646646
cmp_op = BRCOND_GE
647+
elif condition == 'le': # le == lt(threshold+1)
648+
threshold += 1
649+
cmp_op = BRCOND_LT
650+
elif condition == 'gt': # gt == ge(threshold+1)
651+
threshold += 1
652+
cmp_op = BRCOND_GE
647653
else:
648654
raise ValueError("invalid comparison condition")
649655
_br.imm = threshold

tests/compat/jumps.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ entry:
1515
jumpr later, 42, lt
1616
jumpr entry, 42, ge
1717
jumpr later, 42, ge
18+
jumpr entry, 42, le
19+
jumpr later, 42, le
20+
jumpr entry, 42, gt
21+
jumpr later, 42, gt
1822

1923
nop
2024
nop

0 commit comments

Comments
 (0)