emulenv.cc (4604:3ffdd00e6c02) | emulenv.cc (4712:79b4c64296ce) |
---|---|
1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * All rights reserved. 4 * 5 * Redistribution and use of this software in source and binary forms, 6 * with or without modification, are permitted provided that the 7 * following conditions are met: 8 * --- 52 unchanged lines hidden (view full) --- 61using namespace X86ISA; 62 63void EmulEnv::doModRM(const ExtMachInst & machInst) 64{ 65 assert(machInst.modRM.mod != 3); 66 //Use the SIB byte for addressing if the modrm byte calls for it. 67 if (machInst.modRM.rm == 4 && machInst.addrSize != 2) { 68 scale = 1 << machInst.sib.scale; | 1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * All rights reserved. 4 * 5 * Redistribution and use of this software in source and binary forms, 6 * with or without modification, are permitted provided that the 7 * following conditions are met: 8 * --- 52 unchanged lines hidden (view full) --- 61using namespace X86ISA; 62 63void EmulEnv::doModRM(const ExtMachInst & machInst) 64{ 65 assert(machInst.modRM.mod != 3); 66 //Use the SIB byte for addressing if the modrm byte calls for it. 67 if (machInst.modRM.rm == 4 && machInst.addrSize != 2) { 68 scale = 1 << machInst.sib.scale; |
69 index = machInst.sib.index; 70 base = machInst.sib.base; | 69 index = machInst.sib.index | (machInst.rex.x << 3); 70 base = machInst.sib.base | (machInst.rex.b << 3); |
71 //In this special case, we don't use a base. The displacement also 72 //changes, but that's managed by the predecoder. 73 if (machInst.sib.base == INTREG_RBP && machInst.modRM.mod == 0) 74 base = NUM_INTREGS; 75 //In -this- special case, we don't use an index. 76 if (machInst.sib.index == INTREG_RSP) 77 index = NUM_INTREGS; 78 } else { 79 if (machInst.addrSize == 2) { 80 warn("I'm not really using 16 bit MODRM like I'm supposed to!\n"); 81 } else { 82 scale = 0; | 71 //In this special case, we don't use a base. The displacement also 72 //changes, but that's managed by the predecoder. 73 if (machInst.sib.base == INTREG_RBP && machInst.modRM.mod == 0) 74 base = NUM_INTREGS; 75 //In -this- special case, we don't use an index. 76 if (machInst.sib.index == INTREG_RSP) 77 index = NUM_INTREGS; 78 } else { 79 if (machInst.addrSize == 2) { 80 warn("I'm not really using 16 bit MODRM like I'm supposed to!\n"); 81 } else { 82 scale = 0; |
83 base = machInst.modRM.rm; | 83 base = machInst.modRM.rm | (machInst.rex.b << 3); |
84 if (machInst.modRM.mod == 0 && machInst.modRM.rm == 5) { 85 base = NUM_INTREGS; | 84 if (machInst.modRM.mod == 0 && machInst.modRM.rm == 5) { 85 base = NUM_INTREGS; |
86 if (machInst.mode.submode == SixtyFourBitMode) 87 base = NUM_INTREGS+7; | 86 //Since we need to use a different encoding of this 87 //instruction anyway, just ignore the base in those cases 88// if (machInst.mode.submode == SixtyFourBitMode) 89// base = NUM_INTREGS+7; |
88 } 89 } 90 } 91} 92 | 90 } 91 } 92 } 93} 94 |