Skip to content

Commit

Permalink
riscv64-asm.c: fix assembly instruction with negative immediate offsets.
Browse files Browse the repository at this point in the history
This fixes expressions like ld a0, s0, -24 that regressed in
d87801b
  • Loading branch information
stikonas committed Jan 12, 2024
1 parent 6120656 commit 04365dd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion riscv64-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,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 < 0x1000)
if ((int) op->e.v >= -0x1000 && (int) op->e.v < 0x1000)
op->type = OP_IM12S;
} else if (op->e.sym->type.t & (VT_EXTERN | VT_STATIC)) {
label.type.t = VT_VOID | VT_STATIC;
Expand Down

0 comments on commit 04365dd

Please sign in to comment.