asm_emit_cj: correct check for offset size
Unified · Split
| @@ -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 | } else | 189 | } 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; |