History

riscv64-asm.c: correct check for 12-bit immediate

asm_emit_cj: correct check for offset size

noneofyourbusiness committed 2 years ago

Commit 279dbb91 parent 275dfbe1 file · +4 −9Browse files

Unified · Split

riscv64-asm.c+4−9
@@ -184,7 +184,7 @@ static void parse_operand(TCCState *s1, Operand *op) · 183 unmodified lines
184184 op->e = e;
185185 /* compare against unsigned 12-bit maximum */
186186 if (!op->e.sym) {
187− if (op->e.v < 0x2000)
187+ if (op->e.v < 0x1000)
188188 op->type = OP_IM12S;
189189 } else
190190 expect("operand");
@@ -1176,19 +1176,14 @@ static void asm_emit_cj(int token, uint16_t opcode, const Operand *imm) · 985 unmodified lines
11761176 {
11771177 uint32_t offset;
11781178
1179− if (imm->type != OP_IM12S && imm->type != OP_IM32) {
1180− tcc_error("'%s': Expected source operand that is an immediate value", get_tok_str(token, NULL));
1179+ /* +-2 KiB range */
1180+ if (imm->type != OP_IM12S) {
1181+ tcc_error("'%s': Expected source operand that is a 12-bit immediate value", get_tok_str(token, NULL));
11811182 return;
11821183 }
11831184
11841185 offset = imm->e.v;
11851186
1186− /* +-2 KiB range; max. 0x7fe min. 0xffe (-0x7fe) */
1187− if (offset > 0x1fff) {
1188− tcc_error("'%s': Expected source operand that is an immediate value between 0 and 0x1fff", get_tok_str(token, NULL));
1189− return;
1190− }
1191−
11921187 if (offset & 1) {
11931188 tcc_error("'%s': Expected source operand that is an even immediate value", get_tok_str(token, NULL));
11941189 return;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t