aboutsummaryrefslogtreecommitdiffhomepage
path: root/amd64/emit.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-11-22 09:50:14 +0100
committerlemon <lsof@mailbox.org>2025-11-22 09:50:14 +0100
commite471cfe5d94f47b7bcd95ce37e7d5c75997a7a67 (patch)
treed8082d30d1036ebafcd2e73789fa80940335a7ab /amd64/emit.c
parentfd74f66379b45e2ce29fd83a00f4cbebb2214269 (diff)
amd64/emit: fix REX-requiring 8-bit GPR encoding checking wrong reg
Diffstat (limited to 'amd64/emit.c')
-rw-r--r--amd64/emit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/amd64/emit.c b/amd64/emit.c
index 5a63a61..4ad0a04 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -293,7 +293,7 @@ encode(uchar **pcode, const struct desc *tab, int ntab, enum irclass k, struct o
rex |= (dst.reg >> 3) << 2; /* REX.R */
rex |= (src.reg >> 3) << 0; /* REX.B */
if (rex) B(0x40 | rex);
- else if (en->r8 && in_range(dst.reg, RSP, RDI)) {
+ else if (en->r8 && in_range(src.reg, RSP, RDI)) {
/* /r8 needs REX to encode SP,BP,SI,DI (otherwise -> AH..BH) */
B(0x40);
}
@@ -304,7 +304,7 @@ encode(uchar **pcode, const struct desc *tab, int ntab, enum irclass k, struct o
rex |= (src.reg >> 3) << 2; /* REX.R */
rex |= (dst.reg >> 3) << 0; /* REX.B */
if (rex) B(0x40 | rex);
- else if (en->r8 && in_range(src.reg, RSP, RDI)) {
+ else if (en->r8 && in_range(dst.reg, RSP, RDI)) {
/* /r8 needs REX to encode SP,BP,SI,DI (otherwise -> AH..BH) */
B(0x40);
}