From 95e5511ab8736f6fd9953fe66a05096b79afae16 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 15 Oct 2017 01:59:11 -0700 Subject: 4069 subx: unconditional 'jump' --- html/subx/012indirect_addressing.cc.html | 81 ++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 24 deletions(-) (limited to 'html/subx/012indirect_addressing.cc.html') diff --git a/html/subx/012indirect_addressing.cc.html b/html/subx/012indirect_addressing.cc.html index b43a2098..8bf288af 100644 --- a/html/subx/012indirect_addressing.cc.html +++ b/html/subx/012indirect_addressing.cc.html @@ -15,19 +15,20 @@ body { font-size: 12pt; font-family: monospace; color: #aaaaaa; background-color a { color:#eeeeee; text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } -.Constant { color: #00a0a0; } -.Special { color: #c00000; } -.Conceal { color: #4e4e4e; } .SalientComment { color: #00ffff; } +.LineNr { color: #444444; } +.Error { color: #ffffff; background-color: #ff6060; padding-bottom: 1px; } +.traceAbsent { color: #c00000; } +.Delimiter { color: #800080; } +.Normal { color: #aaaaaa; background-color: #080808; padding-bottom: 1px; } +.traceContains { color: #008000; } +.Conceal { color: #4e4e4e; } .Comment { color: #9090ff; } .Comment a { color:#0000ee; text-decoration:underline; } -.Delimiter { color: #800080; } -.LineNr { color: #444444; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } .Identifier { color: #c0a020; } -.Normal { color: #aaaaaa; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } -.Error { color: #ffffff; background-color: #ff6060; padding-bottom: 1px; } -.traceContains { color: #008000; } --> @@ -79,7 +80,7 @@ if ('onhashchange' in window) { 15 // mod 0 is usually indirect addressing 16 switch (rm) { 17 default: - 18 ¦ trace(2, "run") << "effective address is mem at address 0x" << std::hex << Reg[rm].u << " (reg " << NUM(rm) << ")" << end(); + 18 ¦ trace(2, "run") << "effective address is mem at address 0x" << std::hex << Reg[rm].u << " (reg " << NUM(rm) << ")" << end(); 19 ¦ assert(Reg[rm].u + sizeof(int32_t) <= Mem.size()); 20 ¦ result = reinterpret_cast<int32_t*>(&Mem.at(Reg[rm].u)); // rely on the host itself being in little-endian order 21 ¦ break; @@ -101,9 +102,9 @@ if ('onhashchange' in window) { 37 38 :(before "End Single-Byte Opcodes") 39 case 0x03: { // add r/m32 to r32 - 40 uint8_t modrm = next(); + 40 uint8_t modrm = next(); 41 uint8_t arg1 = (modrm>>3)&0x7; - 42 trace(2, "run") << "add effective address to reg " << NUM(arg1) << end(); + 42 trace(2, "run") << "add effective address to reg " << NUM(arg1) << end(); 43 const int32_t* arg2 = effective_address(modrm); 44 BINARY_ARITHMETIC_OP(+, Reg[arg1].i, *arg2); 45 break; @@ -135,9 +136,9 @@ if ('onhashchange' in window) { 71 72 :(before "End Single-Byte Opcodes") 73 case 0x2b: { // subtract r/m32 from r32 - 74 uint8_t modrm = next(); + 74 uint8_t modrm = next(); 75 uint8_t arg1 = (modrm>>3)&0x7; - 76 trace(2, "run") << "subtract effective address from reg " << NUM(arg1) << end(); + 76 trace(2, "run") << "subtract effective address from reg " << NUM(arg1) << end(); 77 const int32_t* arg2 = effective_address(modrm); 78 BINARY_ARITHMETIC_OP(-, Reg[arg1].i, *arg2); 79 break; @@ -169,9 +170,9 @@ if ('onhashchange' in window) { 105 106 :(before "End Single-Byte Opcodes") 107 case 0x23: { // and r/m32 with r32 -108 uint8_t modrm = next(); +108 uint8_t modrm = next(); 109 uint8_t arg1 = (modrm>>3)&0x7; -110 trace(2, "run") << "and effective address with reg " << NUM(arg1) << end(); +110 trace(2, "run") << "and effective address with reg " << NUM(arg1) << end(); 111 const int32_t* arg2 = effective_address(modrm); 112 BINARY_BITWISE_OP(&, Reg[arg1].u, *arg2); 113 break; @@ -203,9 +204,9 @@ if ('onhashchange' in window) { 139 140 :(before "End Single-Byte Opcodes") 141 case 0x0b: { // or r/m32 with r32 -142 uint8_t modrm = next(); +142 uint8_t modrm = next(); 143 uint8_t arg1 = (modrm>>3)&0x7; -144 trace(2, "run") << "or effective address with reg " << NUM(arg1) << end(); +144 trace(2, "run") << "or effective address with reg " << NUM(arg1) << end(); 145 const int32_t* arg2 = effective_address(modrm); 146 BINARY_BITWISE_OP(|, Reg[arg1].u, *arg2); 147 break; @@ -237,9 +238,9 @@ if ('onhashchange' in window) { 173 174 :(before "End Single-Byte Opcodes") 175 case 0x33: { // xor r/m32 with r32 -176 uint8_t modrm = next(); +176 uint8_t modrm = next(); 177 uint8_t arg1 = (modrm>>3)&0x7; -178 trace(2, "run") << "xor effective address with reg " << NUM(arg1) << end(); +178 trace(2, "run") << "xor effective address with reg " << NUM(arg1) << end(); 179 const int32_t* arg2 = effective_address(modrm); 180 BINARY_BITWISE_OP(|, Reg[arg1].u, *arg2); 181 break; @@ -303,9 +304,9 @@ if ('onhashchange' in window) { 239 240 :(before "End Single-Byte Opcodes") 241 case 0x3b: { // set SF if r32 < r/m32 -242 uint8_t modrm = next(); +242 uint8_t modrm = next(); 243 uint8_t reg1 = (modrm>>3)&0x7; -244 trace(2, "run") << "compare effective address with reg " << NUM(reg1) << end(); +244 trace(2, "run") << "compare effective address with reg " << NUM(reg1) << end(); 245 int32_t arg1 = Reg[reg1].i; 246 int32_t* arg2 = effective_address(modrm); 247 int32_t tmp1 = arg1 - *arg2; @@ -361,14 +362,46 @@ if ('onhashchange' in window) { 297 298 :(before "End Single-Byte Opcodes") 299 case 0x8b: { // copy r32 to r/m32 -300 uint8_t modrm = next(); +300 uint8_t modrm = next(); 301 uint8_t reg1 = (modrm>>3)&0x7; -302 trace(2, "run") << "copy effective address to reg " << NUM(reg1) << end(); +302 trace(2, "run") << "copy effective address to reg " << NUM(reg1) << end(); 303 int32_t* arg2 = effective_address(modrm); 304 Reg[reg1].i = *arg2; -305 trace(2, "run") << "storing 0x" << HEXWORD << *arg2 << end(); +305 trace(2, "run") << "storing 0x" << HEXWORD << *arg2 << end(); 306 break; 307 } +308 +309 //:: jump +310 +311 :(scenario jump_mem_at_r32) +312 % Reg[0].i = 0x60; +313 % SET_WORD_IN_MEM(0x60, 8); +314 # op ModRM SIB displacement immediate +315 ff 20 # jump to *EAX (reg 0) +316 05 00 00 00 01 +317 05 00 00 00 02 +318 +run: inst: 0x00000001 +319 +run: jump to effective address +320 +run: effective address is mem at address 0x60 (reg 0) +321 +run: jumping to 0x00000008 +322 +run: inst: 0x00000008 +323 -run: inst: 0x00000003 +324 +325 :(before "End Single-Byte Opcodes") +326 case 0xff: { // jump to r/m32 +327 uint8_t modrm = next(); +328 uint8_t subop = (modrm>>3)&0x7; // middle 3 'reg opcode' bits +329 switch (subop) { +330 case 4: +331 ¦ trace(2, "run") << "jump to effective address" << end(); +332 ¦ int32_t* arg2 = effective_address(modrm); +333 ¦ EIP = *arg2; +334 ¦ trace(2, "run") << "jumping to 0x" << HEXWORD << EIP << end(); +335 ¦ break; +336 // End Op ff Subops +337 } +338 break; +339 } -- cgit 1.4.1-2-gfad0