summaryrefslogtreecommitdiff
path: root/gen_x86.c
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-05-02 00:10:24 -0700
committerMike Pavone <pavone@retrodev.com>2013-05-02 00:10:24 -0700
commitcb7600f819e01e4f6f5e6a9fad7e2331e37e5bc3 (patch)
tree068839bd0d7c9e674a4f44298811ee7de2d3b2f2 /gen_x86.c
parent1cd5b239a879696d0005f4e830cbb5bbc4d6277f (diff)
Don't mix *H regs with the REX prefix
Diffstat (limited to 'gen_x86.c')
-rw-r--r--gen_x86.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gen_x86.c b/gen_x86.c
index 184dd1c..3439a32 100644
--- a/gen_x86.c
+++ b/gen_x86.c
@@ -134,6 +134,10 @@ uint8_t * x86_rr_sizedir(uint8_t * out, uint16_t opcode, uint8_t src, uint8_t ds
}
if (size == SZ_Q || src >= R8 || dst >= R8 || (size == SZ_B && src >= RSP && src <= RDI)) {
*out = PRE_REX;
+ if (src >= AH && src <= BH || dst >= AH && dst <= BH) {
+ fprintf(stderr, "attempt to use *H reg in an instruction requiring REX prefix. opcode = %X\n", opcode);
+ exit(1);
+ }
if (size == SZ_Q) {
*out |= REX_QUAD;
}
@@ -176,6 +180,10 @@ uint8_t * x86_rrdisp8_sizedir(uint8_t * out, uint16_t opcode, uint8_t reg, uint8
}
if (size == SZ_Q || reg >= R8 || base >= R8 || (size == SZ_B && reg >= RSP && reg <= RDI)) {
*out = PRE_REX;
+ if (reg >= AH && reg <= BH) {
+ fprintf(stderr, "attempt to use *H reg in an instruction requiring REX prefix. opcode = %X\n", opcode);
+ exit(1);
+ }
if (size == SZ_Q) {
*out |= REX_QUAD;
}
@@ -221,6 +229,10 @@ uint8_t * x86_rrind_sizedir(uint8_t * out, uint8_t opcode, uint8_t reg, uint8_t
}
if (size == SZ_Q || reg >= R8 || base >= R8 || (size == SZ_B && reg >= RSP && reg <= RDI)) {
*out = PRE_REX;
+ if (reg >= AH && reg <= BH) {
+ fprintf(stderr, "attempt to use *H reg in an instruction requiring REX prefix. opcode = %X\n", opcode);
+ exit(1);
+ }
if (size == SZ_Q) {
*out |= REX_QUAD;
}
@@ -258,6 +270,10 @@ uint8_t * x86_r_size(uint8_t * out, uint8_t opcode, uint8_t opex, uint8_t dst, u
}
if (size == SZ_Q || dst >= R8) {
*out = PRE_REX;
+ if (dst >= AH && dst <= BH) {
+ fprintf(stderr, "attempt to use *H reg in an instruction requiring REX prefix. opcode = %X\n", opcode);
+ exit(1);
+ }
if (size == SZ_Q) {
*out |= REX_QUAD;
}