From 7e274cf2be2afcd54b187a3184b5aefe79ebf0c9 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 26 Sep 2018 10:48:44 -0700 Subject: 4520 --- html/subx/013direct_addressing.cc.html | 66 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'html/subx/013direct_addressing.cc.html') diff --git a/html/subx/013direct_addressing.cc.html b/html/subx/013direct_addressing.cc.html index d4e8482c..e4eeb855 100644 --- a/html/subx/013direct_addressing.cc.html +++ b/html/subx/013direct_addressing.cc.html @@ -83,7 +83,7 @@ if ('onhashchange' in window) { 18 case 0x01: { // add r32 to r/m32 19 uint8_t modrm = next(); 20 uint8_t arg2 = (modrm>>3)&0x7; - 21 trace(90, "run") << "add " << rname(arg2) << " to r/m32" << end(); + 21 trace(90, "run") << "add " << rname(arg2) << " to r/m32" << end(); 22 int32_t* arg1 = effective_address(modrm); 23 BINARY_ARITHMETIC_OP(+, *arg1, Reg[arg2].i); 24 break; @@ -99,7 +99,7 @@ if ('onhashchange' in window) { 34 uint8_t rm = modrm & 0x7; 35 if (mod == 3) { 36 // mod 3 is just register direct addressing - 37 trace(90, "run") << "r/m32 is " << rname(rm) << end(); + 37 trace(90, "run") << "r/m32 is " << rname(rm) << end(); 38 return &Reg[rm].i; 39 } 40 return mem_addr_i32(effective_address_number(modrm)); @@ -113,7 +113,7 @@ if ('onhashchange' in window) { 48 switch (mod) { 49 case 3: 50 // mod 3 is just register direct addressing - 51 raise << "unexpected direct addressing mode\n" << end(); + 51 raise << "unexpected direct addressing mode\n" << end(); 52 return 0; 53 // End Mod Special-cases(addr) 54 default: @@ -134,7 +134,7 @@ if ('onhashchange' in window) { 69 case 5: return "EBP"; 70 case 6: return "ESI"; 71 case 7: return "EDI"; - 72 default: raise << "invalid register " << r << '\n' << end(); return ""; + 72 default: raise << "invalid register " << r << '\n' << end(); return ""; 73 } 74 } 75 @@ -158,7 +158,7 @@ if ('onhashchange' in window) { 93 case 0x29: { // subtract r32 from r/m32 94 uint8_t modrm = next(); 95 uint8_t arg2 = (modrm>>3)&0x7; - 96 trace(90, "run") << "subtract " << rname(arg2) << " from r/m32" << end(); + 96 trace(90, "run") << "subtract " << rname(arg2) << " from r/m32" << end(); 97 int32_t* arg1 = effective_address(modrm); 98 BINARY_ARITHMETIC_OP(-, *arg1, Reg[arg2].i); 99 break; @@ -184,17 +184,17 @@ if ('onhashchange' in window) { 119 :(before "End Single-Byte Opcodes") 120 case 0xf7: { // xor r32 with r/m32 121 uint8_t modrm = next(); -122 trace(90, "run") << "operate on r/m32" << end(); +122 trace(90, "run") << "operate on r/m32" << end(); 123 int32_t* arg1 = effective_address(modrm); 124 uint8_t subop = (modrm>>3)&0x7; // middle 3 'reg opcode' bits 125 switch (subop) { 126 case 4: { // mul unsigned EAX by r/m32 -127 trace(90, "run") << "subop: multiply EAX by r/m32" << end(); +127 trace(90, "run") << "subop: multiply EAX by r/m32" << end(); 128 uint64_t result = Reg[EAX].u * static_cast<uint32_t>(*arg1); 129 Reg[EAX].u = result & 0xffffffff; 130 Reg[EDX].u = result >> 32; 131 OF = (Reg[EDX].u != 0); -132 trace(90, "run") << "storing 0x" << HEXWORD << Reg[EAX].u << end(); +132 trace(90, "run") << "storing 0x" << HEXWORD << Reg[EAX].u << end(); 133 break; 134 } 135 // End Op f7 Subops @@ -225,7 +225,7 @@ if ('onhashchange' in window) { 160 case 0xaf: { // multiply r32 into r/m32 161 uint8_t modrm = next(); 162 uint8_t arg2 = (modrm>>3)&0x7; -163 trace(90, "run") << "multiply r/m32 into " << rname(arg2) << end(); +163 trace(90, "run") << "multiply r/m32 into " << rname(arg2) << end(); 164 int32_t* arg1 = effective_address(modrm); 165 BINARY_ARITHMETIC_OP(*, Reg[arg2].i, *arg1); 166 break; @@ -251,7 +251,7 @@ if ('onhashchange' in window) { 186 case 0x21: { // and r32 with r/m32 187 uint8_t modrm = next(); 188 uint8_t arg2 = (modrm>>3)&0x7; -189 trace(90, "run") << "and " << rname(arg2) << " with r/m32" << end(); +189 trace(90, "run") << "and " << rname(arg2) << " with r/m32" << end(); 190 int32_t* arg1 = effective_address(modrm); 191 BINARY_BITWISE_OP(&, *arg1, Reg[arg2].u); 192 break; @@ -277,7 +277,7 @@ if ('onhashchange' in window) { 212 case 0x09: { // or r32 with r/m32 213 uint8_t modrm = next(); 214 uint8_t arg2 = (modrm>>3)&0x7; -215 trace(90, "run") << "or " << rname(arg2) << " with r/m32" << end(); +215 trace(90, "run") << "or " << rname(arg2) << " with r/m32" << end(); 216 int32_t* arg1 = effective_address(modrm); 217 BINARY_BITWISE_OP(|, *arg1, Reg[arg2].u); 218 break; @@ -303,7 +303,7 @@ if ('onhashchange' in window) { 238 case 0x31: { // xor r32 with r/m32 239 uint8_t modrm = next(); 240 uint8_t arg2 = (modrm>>3)&0x7; -241 trace(90, "run") << "xor " << rname(arg2) << " with r/m32" << end(); +241 trace(90, "run") << "xor " << rname(arg2) << " with r/m32" << end(); 242 int32_t* arg1 = effective_address(modrm); 243 BINARY_BITWISE_OP(^, *arg1, Reg[arg2].u); 244 break; @@ -327,9 +327,9 @@ if ('onhashchange' in window) { 262 263 :(before "End Op f7 Subops") 264 case 2: { // not r/m32 -265 trace(90, "run") << "subop: not" << end(); +265 trace(90, "run") << "subop: not" << end(); 266 *arg1 = ~(*arg1); -267 trace(90, "run") << "storing 0x" << HEXWORD << *arg1 << end(); +267 trace(90, "run") << "storing 0x" << HEXWORD << *arg1 << end(); 268 SF = (*arg1 >> 31); 269 ZF = (*arg1 == 0); 270 OF = false; @@ -356,7 +356,7 @@ if ('onhashchange' in window) { 291 case 0x39: { // set SF if r/m32 < r32 292 uint8_t modrm = next(); 293 uint8_t reg2 = (modrm>>3)&0x7; -294 trace(90, "run") << "compare " << rname(reg2) << " with r/m32" << end(); +294 trace(90, "run") << "compare " << rname(reg2) << " with r/m32" << end(); 295 int32_t* arg1 = effective_address(modrm); 296 int32_t arg2 = Reg[reg2].i; 297 int32_t tmp1 = *arg1 - arg2; @@ -364,7 +364,7 @@ if ('onhashchange' in window) { 299 ZF = (tmp1 == 0); 300 int64_t tmp2 = *arg1 - arg2; 301 OF = (tmp1 != tmp2); -302 trace(90, "run") << "SF=" << SF << "; ZF=" << ZF << "; OF=" << OF << end(); +302 trace(90, "run") << "SF=" << SF << "; ZF=" << ZF << "; OF=" << OF << end(); 303 break; 304 } 305 @@ -409,10 +409,10 @@ if ('onhashchange' in window) { 344 case 0x89: { // copy r32 to r/m32 345 uint8_t modrm = next(); 346 uint8_t reg2 = (modrm>>3)&0x7; -347 trace(90, "run") << "copy " << rname(reg2) << " to r/m32" << end(); +347 trace(90, "run") << "copy " << rname(reg2) << " to r/m32" << end(); 348 int32_t* arg1 = effective_address(modrm); 349 *arg1 = Reg[reg2].i; -350 trace(90, "run") << "storing 0x" << HEXWORD << *arg1 << end(); +350 trace(90, "run") << "storing 0x" << HEXWORD << *arg1 << end(); 351 break; 352 } 353 @@ -437,13 +437,13 @@ if ('onhashchange' in window) { 372 case 0x87: { // exchange r32 with r/m32 373 uint8_t modrm = next(); 374 uint8_t reg2 = (modrm>>3)&0x7; -375 trace(90, "run") << "exchange " << rname(reg2) << " with r/m32" << end(); +375 trace(90, "run") << "exchange " << rname(reg2) << " with r/m32" << end(); 376 int32_t* arg1 = effective_address(modrm); 377 int32_t tmp = *arg1; 378 *arg1 = Reg[reg2].i; 379 Reg[reg2].i = tmp; -380 trace(90, "run") << "storing 0x" << HEXWORD << *arg1 << " in r/m32" << end(); -381 trace(90, "run") << "storing 0x" << HEXWORD << Reg[reg2].i << " in " << rname(reg2) << end(); +380 trace(90, "run") << "storing 0x" << HEXWORD << *arg1 << " in r/m32" << end(); +381 trace(90, "run") << "storing 0x" << HEXWORD << Reg[reg2].i << " in " << rname(reg2) << end(); 382 break; 383 } 384 @@ -477,9 +477,9 @@ if ('onhashchange' in window) { 412 case 0x46: 413 case 0x47: { // increment r32 414 uint8_t reg = op & 0x7; -415 trace(90, "run") << "increment " << rname(reg) << end(); +415 trace(90, "run") << "increment " << rname(reg) << end(); 416 ++Reg[reg].u; -417 trace(90, "run") << "storing value 0x" << HEXWORD << Reg[reg].u << end(); +417 trace(90, "run") << "storing value 0x" << HEXWORD << Reg[reg].u << end(); 418 break; 419 } 420 @@ -502,10 +502,10 @@ if ('onhashchange' in window) { 437 uint8_t subop = (modrm>>3)&0x7; // middle 3 'reg opcode' bits 438 switch (subop) { 439 case 0: { // increment r/m32 -440 trace(90, "run") << "increment r/m32" << end(); +440 trace(90, "run") << "increment r/m32" << end(); 441 int32_t* arg = effective_address(modrm); 442 ++*arg; -443 trace(90, "run") << "storing value 0x" << HEXWORD << *arg << end(); +443 trace(90, "run") << "storing value 0x" << HEXWORD << *arg << end(); 444 break; 445 } 446 // End Op ff Subops @@ -543,9 +543,9 @@ if ('onhashchange' in window) { 478 case 0x4e: 479 case 0x4f: { // decrement r32 480 uint8_t reg = op & 0x7; -481 trace(90, "run") << "decrement " << rname(reg) << end(); +481 trace(90, "run") << "decrement " << rname(reg) << end(); 482 --Reg[reg].u; -483 trace(90, "run") << "storing value 0x" << HEXWORD << Reg[reg].u << end(); +483 trace(90, "run") << "storing value 0x" << HEXWORD << Reg[reg].u << end(); 484 break; 485 } 486 @@ -561,10 +561,10 @@ if ('onhashchange' in window) { 496 497 :(before "End Op ff Subops") 498 case 1: { // decrement r/m32 -499 trace(90, "run") << "decrement r/m32" << end(); +499 trace(90, "run") << "decrement r/m32" << end(); 500 int32_t* arg = effective_address(modrm); 501 --*arg; -502 trace(90, "run") << "storing value 0x" << HEXWORD << *arg << end(); +502 trace(90, "run") << "storing value 0x" << HEXWORD << *arg << end(); 503 break; 504 } 505 @@ -600,7 +600,7 @@ if ('onhashchange' in window) { 535 case 0x56: 536 case 0x57: { // push r32 to stack 537 uint8_t reg = op & 0x7; -538 trace(90, "run") << "push " << rname(reg) << end(); +538 trace(90, "run") << "push " << rname(reg) << end(); 539 //? cerr << "push: " << NUM(reg) << ": " << Reg[reg].u << " => " << Reg[ESP].u << '\n'; 540 push(Reg[reg].u); 541 break; @@ -640,7 +640,7 @@ if ('onhashchange' in window) { 575 case 0x5e: 576 case 0x5f: { // pop stack into r32 577 uint8_t reg = op & 0x7; -578 trace(90, "run") << "pop into " << rname(reg) << end(); +578 trace(90, "run") << "pop into " << rname(reg) << end(); 579 //? cerr << "pop from " << Reg[ESP].u << '\n'; 580 Reg[reg].u = pop(); 581 //? cerr << "=> " << NUM(reg) << ": " << Reg[reg].u << '\n'; @@ -649,9 +649,9 @@ if ('onhashchange' in window) { 584 :(code) 585 uint32_t pop() { 586 uint32_t result = read_mem_u32(Reg[ESP].u); -587 trace(90, "run") << "popping value 0x" << HEXWORD << result << end(); +587 trace(90, "run") << "popping value 0x" << HEXWORD << result << end(); 588 Reg[ESP].u += 4; -589 trace(90, "run") << "incrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end(); +589 trace(90, "run") << "incrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end(); 590 return result; 591 } -- cgit 1.4.1-2-gfad0