diff options
author | noneofyourbusiness <noneofyourbusiness@danwin1210.de> | 2023-12-09 00:57:52 +0100 |
---|---|---|
committer | noneofyourbusiness <noneofyourbusiness@danwin1210.de> | 2023-12-09 01:00:16 +0100 |
commit | 279dbb94e24e04444d37e968f45bb4380f66b880 (patch) | |
tree | add6afe8b8786c4680a851d04790e3e834199caf | |
parent | 275dfbea20849762bc9b50849d795bfe3fad97f5 (diff) |
riscv64-asm.c: correct check for 12-bit immediate
asm_emit_cj: correct check for offset size
-rw-r--r-- | riscv64-asm.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/riscv64-asm.c b/riscv64-asm.c index a542f71..c961a82 100644 --- a/riscv64-asm.c +++ b/riscv64-asm.c @@ -184,7 +184,7 @@ static void parse_operand(TCCState *s1, Operand *op) op->e = e; /* compare against unsigned 12-bit maximum */ if (!op->e.sym) { - if (op->e.v < 0x2000) + if (op->e.v < 0x1000) op->type = OP_IM12S; } else expect("operand"); @@ -1176,19 +1176,14 @@ static void asm_emit_cj(int token, uint16_t opcode, const Operand *imm) { uint32_t offset; - if (imm->type != OP_IM12S && imm->type != OP_IM32) { - tcc_error("'%s': Expected source operand that is an immediate value", get_tok_str(token, NULL)); + /* +-2 KiB range */ + if (imm->type != OP_IM12S) { + tcc_error("'%s': Expected source operand that is a 12-bit immediate value", get_tok_str(token, NULL)); return; } offset = imm->e.v; - /* +-2 KiB range; max. 0x7fe min. 0xffe (-0x7fe) */ - if (offset > 0x1fff) { - tcc_error("'%s': Expected source operand that is an immediate value between 0 and 0x1fff", get_tok_str(token, NULL)); - return; - } - if (offset & 1) { tcc_error("'%s': Expected source operand that is an even immediate value", get_tok_str(token, NULL)); return; |