summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoneofyourbusiness <noneofyourbusiness@danwin1210.de>2023-12-02 17:07:16 +0100
committernoneofyourbusiness <noneofyourbusiness@danwin1210.de>2023-12-02 17:08:05 +0100
commit81a32ec305ee871d8129978bf3d57bc108bec46b (patch)
tree840126861325bdf06a509244775c7f30c3df32cd
parent0655fd9637dbb764f6904041bf3b1b210698e09c (diff)
riscv64-asm.c: asm_emit_j: correct check of immediate
-rw-r--r--riscv64-asm.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/riscv64-asm.c b/riscv64-asm.c
index 8da006f..1e6bada 100644
--- a/riscv64-asm.c
+++ b/riscv64-asm.c
@@ -291,8 +291,9 @@ static void asm_emit_j(int token, uint32_t opcode, const Operand* rd, const Oper
imm = rs2->e.v;
- if (imm >= 0x100000) {
- tcc_error("'%s': Expected second source operand that is an immediate value between 0 and 0xfffff", get_tok_str(token, NULL));
+ /* even offsets in a +- 1 MiB range */
+ if (imm > 0x1ffffe) {
+ tcc_error("'%s': Expected second source operand that is an immediate value between 0 and 0x1fffff", get_tok_str(token, NULL));
return;
}