add_asp(instruction, bits);
size_prob = false;
-
- for (temp = nasm_instructions[instruction->opcode]; temp->opcode != -1; temp++){
+
+ for (temp = nasm_instructions[instruction->opcode]; temp->opcode != -1; temp++){
int m = matches(temp, instruction, bits);
-
+
if (m == 99)
m += jmp_match(segment, offset, bits, instruction, temp->code);
NO_SEG, NO_SEG);
offset++;
}
- }
+ }
insn_end = offset + insn_size;
gencode(segment, offset, bits, instruction, codes,
insn_end);
break;
case 0300:
case 0301:
- case 0302:
- case 0303:
+ case 0302:
+ case 0303:
break;
case 0310:
if (bits == 64)
length += (bits != 32) && !has_prefix(ins,P_A32);
break;
case 0312:
- break;
+ break;
case 0313:
if (bits != 64 || has_prefix(ins,P_A16) || has_prefix(ins,P_A32))
return -1;
int rfield;
int32_t rflags;
ea_data.rex = 0; /* Ensure ea.REX is initially 0 */
-
+
if (c <= 0177) {
/* pick rfield from operand b */
rflags = regflag(&ins->oprs[c & 7]);
}
ins->rex &= rex_mask;
-
+
if (ins->rex & REX_D) {
if (ins->rex & REX_H) {
errfunc(ERR_NONFATAL, "cannot use high register in drex instruction");
uint8_t bytes[4];
int32_t size;
int64_t data;
-
+
while (*codes)
switch (c = *codes++) {
case 01:
out(offset, segment, bytes, OUT_RAWDATA + 1, NO_SEG, NO_SEG);
offset += 1;
break;
-
+
case 054:
case 055:
case 056:
break;
case 0322:
- case 0323:
- break;
-
+ case 0323:
+ break;
+
case 0324:
ins->rex |= REX_W;
break;
-
+
case 0330:
*bytes = *codes++ ^ condval[ins->condition];
out(offset, segment, bytes, OUT_RAWDATA + 1, NO_SEG, NO_SEG);
int32_t rflags;
uint8_t *p;
int32_t s;
-
+
if (c <= 0177) {
/* pick rfield from operand b */
rflags = regflag(&ins->oprs[c & 7]);
rfield, rflags, ins->forw_ref)) {
errfunc(ERR_NONFATAL, "invalid effective address");
}
-
+
p = bytes;
*p++ = ea_data.modrm;
if (ea_data.sib_present)
}
s++;
break;
- case 8:
+ case 8:
case 2:
case 4:
data = ins->oprs[(c >> 3) & 7].offset;
for (i = 0; i < itemp->operands; i++)
if (instruction->oprs[i].type & ~itemp->opd[i] & (COLON | TO))
return 0;
-
+
/*
* Check that the operand flags all match up
*/
for (i = 0; i < MAX_OPERANDS; i++)
size[i] = asize;
}
-
+
if (itemp->flags & (IF_SM | IF_SM2)) {
oprs = (itemp->flags & IF_SM2 ? 2 : itemp->operands);
asize = 0;
*/
if (((itemp->flags & IF_PLEVEL) > cpu))
return 3;
-
+
/*
* Check if instruction is available in long mode
*/
if (REG_EA & ~f)
return NULL; /* Invalid EA register */
-
+
output->rex |= op_rexflags(input, REX_B|REX_P|REX_W|REX_H);
output->sib_present = false; /* no SIB necessary */
if (s == 0)
i = -1; /* make this easy, at least */
-
+
if (i >= EXPR_REG_START && i < REG_ENUM_LIMIT) {
it = regvals[i];
ix = reg_flags[i];
it = -1;
ix = 0;
}
-
+
if (b != -1 && b >= EXPR_REG_START && b < REG_ENUM_LIMIT) {
bt = regvals[b];
bx = reg_flags[b];
bt = -1;
bx = 0;
}
-
+
/* check for a 32/64-bit memory reference... */
if ((ix|bx) & (BITS32|BITS64)) {
/* it must be a 32/64-bit memory reference. Firstly we have
return NULL; /* Invalid size */
sok &= ~bx;
}
-
+
/* While we're here, ensure the user didn't specify WORD. */
if (input->addr_size == 16 ||
(input->addr_size == 32 && !(sok & BITS32)) ||
if (it == -1 && (bt & 7) != REG_NUM_ESP) {
/* no SIB needed */
int mod, rm;
-
+
if (bt == -1) {
rm = 5;
mod = 0;
} else {
/* we need a SIB */
int mod, scale, index, base;
-
+
if (it == -1)
index = 4, s = 1;
else
index = (it & 7);
-
+
switch (s) {
case 1:
scale = 0;
default: /* then what the smeg is it? */
return NULL; /* panic */
}
-
+
if (bt == -1) {
base = 5;
mod = 0;
}
} else { /* it's 16-bit */
int mod, rm;
-
+
/* check for 64-bit long mode */
if (addrbits == 64)
return NULL;
}
}
}
-
+
output->size = 1 + output->sib_present + output->bytes;
return output;
}
for (j = 0; j < instruction->operands; j++) {
if (!(MEMORY & ~instruction->oprs[j].type)) {
int32_t i, b;
-
+
/* Verify as Register */
if (instruction->oprs[j].indexreg < EXPR_REG_START
|| instruction->oprs[j].indexreg >= REG_ENUM_LIMIT)
i = 0;
else
i = reg_flags[instruction->oprs[j].indexreg];
-
+
/* Verify as Register */
if (instruction->oprs[j].basereg < EXPR_REG_START
|| instruction->oprs[j].basereg >= REG_ENUM_LIMIT)
b = 0;
else
b = reg_flags[instruction->oprs[j].basereg];
-
+
if (instruction->oprs[j].scale == 0)
i = 0;
valid &= 32;
if (!(REG64 & ~b))
valid &= 64;
-
+
if (!(REG16 & ~i))
valid &= 16;
if (!(REG32 & ~i))