Skip to content

Fix negative immediate offset handling for JUMPS and JUMPR opcodes #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified gas/testsuite/gas/esp32ulp/esp32/compare/esp32ulp_all.bin
Binary file not shown.
7 changes: 7 additions & 0 deletions gas/testsuite/gas/esp32ulp/esp32/compare/esp32ulp_all.lst
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,10 @@ ESP32ULP GAS ./gas/testsuite/gas/esp32ulp/esp32/esp32ulp_all.s page 1
179 0154 20408810 REG_WR 0x20, 1, 2,0x10 // REG[0x120] = 0x10[1:2]
180
181 0158 000000B0 HALT // Move chip to powerdown
182
183 // JUMPR negative offset
184 015c 14000983 JUMPR -16, 20, GE //Jump to address "position - 16" if value in R0 >=
185
186 // JUMPS negative offset
187 0160 14000484 JUMPS -16, 20, EQ //Jump to address “position - 16” if value in S
187 14000B85
Binary file modified gas/testsuite/gas/esp32ulp/esp32/compare/esp32ulp_jumpr.bin
Binary file not shown.
6 changes: 6 additions & 0 deletions gas/testsuite/gas/esp32ulp/esp32/compare/esp32ulp_jumpr.lst
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ ESP32ULP GAS ./gas/testsuite/gas/esp32ulp/esp32/esp32ulp_jumpr.s page 1
54
55
56
57 007c 04000283 JUMPR -0x04, 0x4, LT
58 0080 05000283 JUMPR -0x04, 0x4, LE
59 0084 05000582 JUMPR -0x04, 0x4, EQ
59 04000583
60 008c 05000383 JUMPR -0x04, 0x4, GT
61 0090 04000383 JUMPR -0x04, 0x4, GE
6 changes: 6 additions & 0 deletions gas/testsuite/gas/esp32ulp/esp32/esp32ulp_all.s
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,9 @@ labelsd: STAGE_DEC 1 // stage_cnt--;
REG_WR 0x20, 1, 2,0x10 // REG[0x120] = 0x10[1:2]

HALT // Move chip to powerdown

// JUMPR negative offset
JUMPR -16, 20, GE //Jump to address "position - 16" if value in R0 >= 20

// JUMPS negative offset
JUMPS -16, 20, EQ //Jump to address “position - 16” if value in Stage_Cnt == 20
5 changes: 5 additions & 0 deletions gas/testsuite/gas/esp32ulp/esp32/esp32ulp_jumpr.s
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ Check2:



JUMPR -0x04, 0x4, LT
JUMPR -0x04, 0x4, LE
JUMPR -0x04, 0x4, EQ
JUMPR -0x04, 0x4, GT
JUMPR -0x04, 0x4, GE
Binary file modified gas/testsuite/gas/esp32ulp/esp32s2/compare/esp32s2ulp_jump.bin
Binary file not shown.
15 changes: 15 additions & 0 deletions gas/testsuite/gas/esp32ulp/esp32s2/compare/esp32s2ulp_jump.lst
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,18 @@ ESP32ULP GAS ./gas/testsuite/gas/esp32ulp/esp32s2/esp32s2ulp_jump.s page 1
83 0118 00800388 jumps 0x0, 0x00, GE
84
85
86 //jumpr with negative offset
87 011c 00000682 jumpr -0x4, 0x00, EQ
88 0120 00000482 jumpr -0x4, 0x00, LT
89 0124 00000582 jumpr -0x4, 0x00, GT
90 0128 00000482 jumpr -0x4, 0x00, LE
90 00000A82
91 0130 00000582 jumpr -0x4, 0x00, GE
91 00000A82
92
93 //jumps with negative offset
94 0138 0000128A jumps -0x4, 0x00, EQ
95 013c 0080108A jumps -0x4, 0x00, LT
96 0140 0080118A jumps -0x4, 0x00, GT
97 0144 0080128A jumps -0x4, 0x00, LE
98 0148 0080138A jumps -0x4, 0x00, GE
13 changes: 13 additions & 0 deletions gas/testsuite/gas/esp32ulp/esp32s2/esp32s2ulp_jump.s
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,16 @@ jmp2: nop
jumps 0x0, 0x00, GE


//jumpr with negative offset
jumpr -0x4, 0x00, EQ
jumpr -0x4, 0x00, LT
jumpr -0x4, 0x00, GT
jumpr -0x4, 0x00, LE
jumpr -0x4, 0x00, GE

//jumps with negative offset
jumps -0x4, 0x00, EQ
jumps -0x4, 0x00, LT
jumps -0x4, 0x00, GT
jumps -0x4, 0x00, LE
jumps -0x4, 0x00, GE
4 changes: 2 additions & 2 deletions include/opcode/esp32ulp_esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ typedef struct {
#define I_JUMP_RELR(thresh, jud, stp) { *(unsigned int*)&(jump_alu_relr ){ \
.threshold = thresh, \
.judge = jud, \
.step = stp, \
.step = ((stp < 0) ? ((-stp) | (1 << 7)) : stp) , \
.sub_opcode = SUB_OPCODE_BR, \
.opcode = OPCODE_BRANCH } }

Expand All @@ -129,7 +129,7 @@ typedef struct {
#define I_JUMP_RELS(thresh, jud, stp) { *(unsigned int*)&(jump_alu_rels ){ \
.threshold = thresh, \
.judge = jud, \
.step = stp, \
.step = ((stp < 0) ? ((-stp) | (1 << 7)) : stp) , \
.sub_opcode = SUB_OPCODE_BS, \
.opcode = OPCODE_BRANCH } }

Expand Down
4 changes: 2 additions & 2 deletions include/opcode/esp32ulp_esp32s2.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ typedef struct {
#define I_JUMP_RELR(thresh, jud, stp) { *(unsigned int*)&(jump_alu_relr ){ \
.threshold = thresh, \
.judge = jud, \
.step = stp, \
.step = ((stp < 0) ? ((-stp) | (1 << 7)) : stp) , \
.sub_opcode = SUB_OPCODE_BR, \
.opcode = OPCODE_BRANCH } }

Expand All @@ -155,7 +155,7 @@ typedef struct {
.threshold = thresh, \
.unused = 0, \
.judge = jud, \
.step = stp, \
.step = ((stp < 0) ? ((-stp) | (1 << 7)) : stp) , \
.sub_opcode = SUB_OPCODE_BS, \
.opcode = OPCODE_BRANCH } }

Expand Down