mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-27 08:10:07 +08:00
Fix op2 references that had not yet been converted; introduce opy
Fix op2 references not yet converted to accessing op2; add an opy pointer similar to the opx pointer instead of multiple references. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
941fcbb3ab
commit
33d5fc074f
47
assemble.c
47
assemble.c
@ -1773,20 +1773,20 @@ static void gencode(int32_t segment, int64_t offset, int bits,
|
|||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
int32_t s;
|
int32_t s;
|
||||||
enum out_type type;
|
enum out_type type;
|
||||||
|
struct operand *opy = &ins->oprs[op2];
|
||||||
|
|
||||||
if (c <= 0177) {
|
if (c <= 0177) {
|
||||||
/* pick rfield from operand b */
|
/* pick rfield from operand b (opx) */
|
||||||
rflags = regflag(&ins->oprs[op1]);
|
rflags = regflag(opx);
|
||||||
rfield = nasm_regvals[ins->oprs[op1].basereg];
|
rfield = nasm_regvals[opx->basereg];
|
||||||
} else {
|
} else {
|
||||||
/* rfield is constant */
|
/* rfield is constant */
|
||||||
rflags = 0;
|
rflags = 0;
|
||||||
rfield = c & 7;
|
rfield = c & 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process_ea
|
if (!process_ea(opy, &ea_data, bits, ins->addr_size,
|
||||||
(&ins->oprs[op2], &ea_data, bits,
|
rfield, rflags)) {
|
||||||
ins->addr_size, rfield, rflags)) {
|
|
||||||
errfunc(ERR_NONFATAL, "invalid effective address");
|
errfunc(ERR_NONFATAL, "invalid effective address");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1798,8 +1798,7 @@ static void gencode(int32_t segment, int64_t offset, int bits,
|
|||||||
|
|
||||||
/* DREX suffixes come between the SIB and the displacement */
|
/* DREX suffixes come between the SIB and the displacement */
|
||||||
if (ins->rex & REX_D) {
|
if (ins->rex & REX_D) {
|
||||||
*p++ =
|
*p++ = (ins->drexdst << 4) |
|
||||||
(ins->drexdst << 4) |
|
|
||||||
(ins->rex & REX_OC ? 0x08 : 0) |
|
(ins->rex & REX_OC ? 0x08 : 0) |
|
||||||
(ins->rex & (REX_R|REX_X|REX_B));
|
(ins->rex & (REX_R|REX_X|REX_B));
|
||||||
ins->rex = 0;
|
ins->rex = 0;
|
||||||
@ -1819,13 +1818,12 @@ static void gencode(int32_t segment, int64_t offset, int bits,
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (ins->oprs[(c >> 3) & 7].segment != NO_SEG) {
|
if (opy->segment != NO_SEG) {
|
||||||
data = ins->oprs[(c >> 3) & 7].offset;
|
data = opy->offset;
|
||||||
out(offset, segment, &data, OUT_ADDRESS, 1,
|
out(offset, segment, &data, OUT_ADDRESS, 1,
|
||||||
ins->oprs[(c >> 3) & 7].segment,
|
opy->segment, opy->wrt);
|
||||||
ins->oprs[(c >> 3) & 7].wrt);
|
|
||||||
} else {
|
} else {
|
||||||
*bytes = ins->oprs[(c >> 3) & 7].offset;
|
*bytes = opy->offset;
|
||||||
out(offset, segment, bytes, OUT_RAWDATA, 1,
|
out(offset, segment, bytes, OUT_RAWDATA, 1,
|
||||||
NO_SEG, NO_SEG);
|
NO_SEG, NO_SEG);
|
||||||
}
|
}
|
||||||
@ -1834,27 +1832,22 @@ static void gencode(int32_t segment, int64_t offset, int bits,
|
|||||||
case 8:
|
case 8:
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
data = ins->oprs[(c >> 3) & 7].offset;
|
data = opy->offset;
|
||||||
warn_overflow(ea_data.bytes, &ins->oprs[(c >> 3) & 7]);
|
warn_overflow(ea_data.bytes, opy);
|
||||||
s += ea_data.bytes;
|
s += ea_data.bytes;
|
||||||
if (ea_data.rip) {
|
if (ea_data.rip) {
|
||||||
if (ins->oprs[(c >> 3) & 7].segment == segment) {
|
if (opy->segment == segment) {
|
||||||
data -= insn_end;
|
data -= insn_end;
|
||||||
out(offset, segment, &data,
|
out(offset, segment, &data, OUT_ADDRESS,
|
||||||
OUT_ADDRESS, ea_data.bytes,
|
ea_data.bytes, NO_SEG, NO_SEG);
|
||||||
NO_SEG, NO_SEG);
|
|
||||||
} else {
|
} else {
|
||||||
out(offset, segment, &data,
|
out(offset, segment, &data, OUT_REL4ADR,
|
||||||
OUT_REL4ADR, insn_end - offset,
|
insn_end - offset, opy->segment, opy->wrt);
|
||||||
ins->oprs[(c >> 3) & 7].segment,
|
|
||||||
ins->oprs[(c >> 3) & 7].wrt);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
type = OUT_ADDRESS;
|
type = OUT_ADDRESS;
|
||||||
out(offset, segment, &data,
|
out(offset, segment, &data, OUT_ADDRESS,
|
||||||
OUT_ADDRESS, ea_data.bytes,
|
ea_data.bytes, opy->segment, opy->wrt);
|
||||||
ins->oprs[(c >> 3) & 7].segment,
|
|
||||||
ins->oprs[(c >> 3) & 7].wrt);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user