Mercurial > repos > blastem
changeset 603:8c7b63f9fab8
Fix reg-indirect mode for RBP/R13
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 26 Dec 2014 19:36:41 -0800 |
parents | 452ad0b42afa |
children | 39d7d463ed5b |
files | gen_x86.c |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/gen_x86.c Fri Dec 26 15:46:53 2014 -0800 +++ b/gen_x86.c Fri Dec 26 19:36:41 2014 -0800 @@ -322,10 +322,17 @@ opcode |= BIT_SIZE; } *(out++) = opcode | dir; - *(out++) = MODE_REG_INDIRECT | base | (reg << 3); - if (base == RSP) { - //add SIB byte, with no index and RSP as base - *(out++) = (RSP << 3) | RSP; + if (base == RBP) { + //add a dummy 8-bit displacement since MODE_REG_INDIRECT with + //an R/M field of RBP selects RIP, relative addressing + *(out++) = MODE_REG_DISPLACE8 | base | (reg << 3); + *(out++) = 0; + } else { + *(out++) = MODE_REG_INDIRECT | base | (reg << 3); + if (base == RSP) { + //add SIB byte, with no index and RSP as base + *(out++) = (RSP << 3) | RSP; + } } code->cur = out; }