comparison gen_x86.c @ 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 5ef3fe516da9
children 24ccfd70133a
comparison
equal deleted inserted replaced
602:452ad0b42afa 603:8c7b63f9fab8
320 } 320 }
321 } else { 321 } else {
322 opcode |= BIT_SIZE; 322 opcode |= BIT_SIZE;
323 } 323 }
324 *(out++) = opcode | dir; 324 *(out++) = opcode | dir;
325 *(out++) = MODE_REG_INDIRECT | base | (reg << 3); 325 if (base == RBP) {
326 if (base == RSP) { 326 //add a dummy 8-bit displacement since MODE_REG_INDIRECT with
327 //add SIB byte, with no index and RSP as base 327 //an R/M field of RBP selects RIP, relative addressing
328 *(out++) = (RSP << 3) | RSP; 328 *(out++) = MODE_REG_DISPLACE8 | base | (reg << 3);
329 *(out++) = 0;
330 } else {
331 *(out++) = MODE_REG_INDIRECT | base | (reg << 3);
332 if (base == RSP) {
333 //add SIB byte, with no index and RSP as base
334 *(out++) = (RSP << 3) | RSP;
335 }
329 } 336 }
330 code->cur = out; 337 code->cur = out;
331 } 338 }
332 339
333 void x86_rrindex_sizedir(code_info *code, uint8_t opcode, uint8_t reg, uint8_t base, uint8_t index, uint8_t scale, uint8_t size, uint8_t dir) 340 void x86_rrindex_sizedir(code_info *code, uint8_t opcode, uint8_t reg, uint8_t base, uint8_t index, uint8_t scale, uint8_t size, uint8_t dir)