diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-10-12 23:41:43 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-10-12 23:41:43 -0700 |
commit | 222c31db2102daecd1e77d66299a3ea01982ec35 (patch) | |
tree | 25930bd76874e16651774ba1fd0988397dda5a12 /subx/016index_addressing.cc | |
parent | 01dada15c33dff954f3b76406fd9ed09ef4834c8 (diff) | |
download | mu-222c31db2102daecd1e77d66299a3ea01982ec35.tar.gz |
4688
Diffstat (limited to 'subx/016index_addressing.cc')
-rw-r--r-- | subx/016index_addressing.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/subx/016index_addressing.cc b/subx/016index_addressing.cc index f98d4c0d..3501a522 100644 --- a/subx/016index_addressing.cc +++ b/subx/016index_addressing.cc @@ -21,8 +21,8 @@ case 4: // exception: mod 0b00 rm 0b100 => incoming SIB (scale-index-base) byte break; :(code) uint32_t effective_address_from_sib(uint8_t mod) { - uint8_t sib = next(); - uint8_t base = sib&0x7; + const uint8_t sib = next(); + const uint8_t base = sib&0x7; uint32_t addr = 0; if (base != EBP || mod != 0) { addr = Reg[base].u; @@ -33,13 +33,13 @@ uint32_t effective_address_from_sib(uint8_t mod) { addr = next32(); // ignore base trace(90, "run") << "effective address is initially 0x" << std::hex << addr << " (disp32)" << end(); } - uint8_t index = (sib>>3)&0x7; + const uint8_t index = (sib>>3)&0x7; if (index == ESP) { // ignore index and scale trace(90, "run") << "effective address is 0x" << std::hex << addr << end(); } else { - uint8_t scale = (1 << (sib>>6)); + const uint8_t scale = (1 << (sib>>6)); addr += Reg[index].i*scale; // treat index register as signed. Maybe base as well? But we'll always ensure it's non-negative. trace(90, "run") << "effective address is 0x" << std::hex << addr << " (after adding " << rname(index) << "*" << NUM(scale) << ")" << end(); } |