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
184 op->e = e;184 op->e = e;
185 /* compare against unsigned 12-bit maximum */185 /* compare against unsigned 12-bit maximum */
186 if (!op->e.sym) {186 if (!op->e.sym) {
187 if (op->e.v < 0x2000)187 if (op->e.v < 0x1000)
188 op->type = OP_IM12S;188 op->type = OP_IM12S;
189 } else189 } else
190 expect("operand");190 expect("operand");
@@ -1176,19 +1176,14 @@ static void asm_emit_cj(int token, uint16_t opcode, const Operand *imm) · 985 unmodified lines
1176{1176{
1177 uint32_t offset;1177 uint32_t offset;
1178 1178
1179 if (imm->type != OP_IM12S && imm->type != OP_IM32) {1179 /* +-2 KiB range */
1180 tcc_error("'%s': Expected source operand that is an immediate value", get_tok_str(token, NULL));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));
1181 return;1182 return;
1182 }1183 }
1183 1184
1184 offset = imm->e.v;1185 offset = imm->e.v;
1185 1186
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
1192 if (offset & 1) {1187 if (offset & 1) {
1193 tcc_error("'%s': Expected source operand that is an even immediate value", get_tok_str(token, NULL));1188 tcc_error("'%s': Expected source operand that is an even immediate value", get_tok_str(token, NULL));
1194 return;1189 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