-:4: 16-bit addresses not supported in 64-bit mode
-:5: invalid effective address
-:6: invalid effective address
--:7: invalid combination of operands and effective address
+-:7: cannot use A/B/C/DH with instruction needing REX
--:2: invalid combination of opcode and operands
--:3: invalid combination of opcode and operands
+-:2: cannot use A/B/C/DH with instruction needing REX
+-:3: cannot use A/B/C/DH with instruction needing REX
x86_expritem_reg_size size = (x86_expritem_reg_size)(reg & ~0xFUL);
if (size == X86_REG8X || (reg & 0xF) >= 8) {
- if (*rex == 0xff)
+ /* Check to make sure we can set it */
+ if (*rex == 0xff) {
+ yasm_error_set(YASM_ERROR_TYPE,
+ N_("cannot use A/B/C/DH with instruction needing REX"));
return 1;
+ }
*rex |= 0x40 | (((reg & 8) >> 3) << rexbit);
} else if (size == X86_REG8 && (reg & 7) >= 4) {
/* AH/BH/CH/DH, so no REX allowed */
- if (*rex != 0 && *rex != 0xff)
+ if (*rex != 0 && *rex != 0xff) {
+ yasm_error_set(YASM_ERROR_TYPE,
+ N_("cannot use A/B/C/DH with instruction needing REX"));
return 1;
- *rex = 0xff;
+ }
+ *rex = 0xff; /* Flag so we can NEVER set it (see above) */
}
}
*/
if (yasm_x86__set_rex_from_reg(rex, &low3,
(unsigned int)(X86_REG64 | basereg),
- bits, X86_REX_B)) {
- yasm_error_set(YASM_ERROR_TYPE,
- N_("invalid combination of operands and effective address"));
+ bits, X86_REX_B))
return 1;
- }
x86_ea->modrm |= low3;
/* we don't need an SIB *unless* basereg is ESP or R12 */
if (basereg == REG3264_ESP || basereg == REG64_R12)
else {
if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int)
(X86_REG64 | basereg), bits,
- X86_REX_B)) {
- yasm_error_set(YASM_ERROR_TYPE,
- N_("invalid combination of operands and effective address"));
+ X86_REX_B))
return 1;
- }
x86_ea->sib |= low3;
}
else {
if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int)
(X86_REG64 | indexreg), bits,
- X86_REX_X)) {
- yasm_error_set(YASM_ERROR_TYPE,
- N_("invalid combination of operands and effective address"));
+ X86_REX_X))
return 1;
- }
x86_ea->sib |= low3 << 3;
/* Set scale field, 1 case -> 0, so don't bother. */
switch (reg3264mult[indexreg]) {
spare = (unsigned char)(op->data.reg&7);
else if (op->type == YASM_INSN__OPERAND_REG) {
if (yasm_x86__set_rex_from_reg(&insn->rex, &spare,
- op->data.reg, mode_bits, X86_REX_R)) {
- yasm_error_set(YASM_ERROR_TYPE,
- N_("invalid combination of opcode and operands"));
+ op->data.reg, mode_bits, X86_REX_R))
return;
- }
} else
yasm_internal_error(N_("invalid operand conversion"));
break;
if (op->type == YASM_INSN__OPERAND_REG) {
unsigned char opadd;
if (yasm_x86__set_rex_from_reg(&insn->rex, &opadd,
- op->data.reg, mode_bits, X86_REX_B)) {
- yasm_error_set(YASM_ERROR_TYPE,
- N_("invalid combination of opcode and operands"));
+ op->data.reg, mode_bits, X86_REX_B))
return;
- }
insn->opcode.opcode[0] += opadd;
} else
yasm_internal_error(N_("invalid operand conversion"));
if (op->type == YASM_INSN__OPERAND_REG) {
unsigned char opadd;
if (yasm_x86__set_rex_from_reg(&insn->rex, &opadd,
- op->data.reg, mode_bits, X86_REX_B)) {
- yasm_error_set(YASM_ERROR_TYPE,
- N_("invalid combination of opcode and operands"));
+ op->data.reg, mode_bits, X86_REX_B))
return;
- }
insn->opcode.opcode[1] += opadd;
} else
yasm_internal_error(N_("invalid operand conversion"));
if (!insn->x86_ea ||
yasm_x86__set_rex_from_reg(&insn->rex, &spare,
op->data.reg, mode_bits, X86_REX_R)) {
- yasm_error_set(YASM_ERROR_TYPE,
- N_("invalid combination of opcode and operands"));
if (insn->x86_ea)
yasm_xfree(insn->x86_ea);
yasm_xfree(insn);