From 4c37b3e91b3e9c891c22379f029c42abc38e408c Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 28 Oct 2018 13:41:53 -0700 Subject: 4734 --- html/subx/021byte_addressing.cc.html | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'html/subx/021byte_addressing.cc.html') diff --git a/html/subx/021byte_addressing.cc.html b/html/subx/021byte_addressing.cc.html index b20ff4cb..a6b00dc7 100644 --- a/html/subx/021byte_addressing.cc.html +++ b/html/subx/021byte_addressing.cc.html @@ -65,7 +65,7 @@ if ('onhashchange' in window) { 4 //: Unfortunately the register encodings when dealing with bytes are a mess. 5 //: We need a special case for them. 6 :(code) - 7 string rname_8bit(uint8_t r) { + 7 string rname_8bit(uint8_t r) { 8 switch (r) { 9 case 0: return "AL"; // lowest byte of EAX 10 case 1: return "CL"; // lowest byte of ECX @@ -75,23 +75,23 @@ if ('onhashchange' in window) { 14 case 5: return "CH"; // second lowest byte of ECX 15 case 6: return "DH"; // second lowest byte of EDX 16 case 7: return "BH"; // second lowest byte of EBX - 17 default: raise << "invalid 8-bit register " << r << '\n' << end(); return ""; + 17 default: raise << "invalid 8-bit register " << r << '\n' << end(); return ""; 18 } 19 } 20 - 21 uint8_t* effective_byte_address(uint8_t modrm) { + 21 uint8_t* effective_byte_address(uint8_t modrm) { 22 uint8_t mod = (modrm>>6); 23 uint8_t rm = modrm & 0x7; 24 if (mod == 3) { 25 // select an 8-bit register - 26 trace(90, "run") << "r/m8 is " << rname_8bit(rm) << end(); - 27 return reg_8bit(rm); + 26 trace(90, "run") << "r/m8 is " << rname_8bit(rm) << end(); + 27 return reg_8bit(rm); 28 } 29 // the rest is as usual - 30 return mem_addr_u8(effective_address_number(modrm)); + 30 return mem_addr_u8(effective_address_number(modrm)); 31 } 32 - 33 uint8_t* reg_8bit(uint8_t rm) { + 33 uint8_t* reg_8bit(uint8_t rm) { 34 uint8_t* result = reinterpret_cast<uint8_t*>(&Reg[rm & 0x3].i); // _L register 35 if (rm & 0x4) 36 ++result; // _H register; assumes host is little-endian @@ -99,7 +99,7 @@ if ('onhashchange' in window) { 38 } 39 40 :(before "End Initialize Op Names") - 41 put_new(Name, "88", "copy r8 to r8/m8-at-r32"); + 41 put_new(Name, "88", "copy r8 to r8/m8-at-r32"); 42 43 :(scenario copy_r8_to_mem_at_r32) 44 % Reg[EBX].i = 0x224488ab; @@ -117,21 +117,21 @@ if ('onhashchange' in window) { 56 57 :(before "End Single-Byte Opcodes") 58 case 0x88: { // copy r8 to r/m8 - 59 const uint8_t modrm = next(); + 59 const uint8_t modrm = next(); 60 const uint8_t rsrc = (modrm>>3)&0x7; - 61 trace(90, "run") << "copy " << rname_8bit(rsrc) << " to r8/m8-at-r32" << end(); + 61 trace(90, "run") << "copy " << rname_8bit(rsrc) << " to r8/m8-at-r32" << end(); 62 // use unsigned to zero-extend 8-bit value to 32 bits - 63 uint8_t* dest = reinterpret_cast<uint8_t*>(effective_byte_address(modrm)); - 64 const uint8_t* src = reg_8bit(rsrc); + 63 uint8_t* dest = reinterpret_cast<uint8_t*>(effective_byte_address(modrm)); + 64 const uint8_t* src = reg_8bit(rsrc); 65 *dest = *src; - 66 trace(90, "run") << "storing 0x" << HEXBYTE << NUM(*dest) << end(); + 66 trace(90, "run") << "storing 0x" << HEXBYTE << NUM(*dest) << end(); 67 break; 68 } 69 70 //: 71 72 :(before "End Initialize Op Names") - 73 put_new(Name, "8a", "copy r8/m8-at-r32 to r8"); + 73 put_new(Name, "8a", "copy r8/m8-at-r32 to r8"); 74 75 :(scenario copy_mem_at_r32_to_r8) 76 % Reg[EBX].i = 0xaabbcc0f; // one nibble each of lowest byte set to all 0s and all 1s, to maximize value of this test @@ -146,20 +146,20 @@ if ('onhashchange' in window) { 85 +run: effective address is 0x00002000 (EAX) 86 +run: storing 0xab 87 # remaining bytes of EBX are *not* cleared - 88 +run: EBX now contains 0xaabbccab + 88 +run: EBX now contains 0xaabbccab 89 90 :(before "End Single-Byte Opcodes") 91 case 0x8a: { // copy r/m8 to r8 - 92 const uint8_t modrm = next(); + 92 const uint8_t modrm = next(); 93 const uint8_t rdest = (modrm>>3)&0x7; - 94 trace(90, "run") << "copy r8/m8-at-r32 to " << rname_8bit(rdest) << end(); + 94 trace(90, "run") << "copy r8/m8-at-r32 to " << rname_8bit(rdest) << end(); 95 // use unsigned to zero-extend 8-bit value to 32 bits - 96 const uint8_t* src = reinterpret_cast<uint8_t*>(effective_byte_address(modrm)); - 97 uint8_t* dest = reg_8bit(rdest); - 98 trace(90, "run") << "storing 0x" << HEXBYTE << NUM(*src) << end(); + 96 const uint8_t* src = reinterpret_cast<uint8_t*>(effective_byte_address(modrm)); + 97 uint8_t* dest = reg_8bit(rdest); + 98 trace(90, "run") << "storing 0x" << HEXBYTE << NUM(*src) << end(); 99 *dest = *src; 100 const uint8_t rdest_32bit = rdest & 0x3; -101 trace(90, "run") << rname(rdest_32bit) << " now contains 0x" << HEXWORD << Reg[rdest_32bit].u << end(); +101 trace(90, "run") << rname(rdest_32bit) << " now contains 0x" << HEXWORD << Reg[rdest_32bit].u << end(); 102 break; 103 } 104 -- cgit 1.4.1-2-gfad0