From 695f9bf8d0a7d0a871b8ab75270ceb29715d9be3 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 25 Jul 2019 00:08:23 -0700 Subject: 5468 --- html/subx/015immediate_addressing.cc.html | 204 +++++++++++++++--------------- 1 file changed, 102 insertions(+), 102 deletions(-) (limited to 'html/subx/015immediate_addressing.cc.html') diff --git a/html/subx/015immediate_addressing.cc.html b/html/subx/015immediate_addressing.cc.html index 087f04db..cbc5d8cc 100644 --- a/html/subx/015immediate_addressing.cc.html +++ b/html/subx/015immediate_addressing.cc.html @@ -62,12 +62,12 @@ if ('onhashchange' in window) { 1 //: instructions that (immediately) contain an argument to act with 2 3 :(before "End Initialize Op Names") - 4 put_new(Name, "05", "add imm32 to EAX (add)"); + 4 put_new(Name, "05", "add imm32 to EAX (add)"); 5 6 :(before "End Single-Byte Opcodes") 7 case 0x05: { // add imm32 to EAX 8 int32_t signed_arg2 = next32(); - 9 trace(Callstack_depth+1, "run") << "add imm32 0x" << HEXWORD << signed_arg2 << " to EAX" << end(); + 9 trace(Callstack_depth+1, "run") << "add imm32 0x" << HEXWORD << signed_arg2 << " to EAX" << end(); 10 int32_t signed_result = Reg[EAX].i + signed_arg2; 11 SF = (signed_result < 0); 12 ZF = (signed_result == 0); @@ -80,7 +80,7 @@ if ('onhashchange' in window) { 19 CF = (unsigned_result != unsigned_full_result); 20 trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); 21 Reg[EAX].i = signed_result; - 22 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); + 22 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); 23 break; 24 } 25 @@ -92,7 +92,7 @@ if ('onhashchange' in window) { 31 // op ModR/M SIB displacement immediate 32 " 05 01 00 00 00 \n" // add 1 to EAX 33 ); - 34 CHECK_TRACE_CONTENTS( + 34 CHECK_TRACE_CONTENTS( 35 "run: add imm32 0x00000001 to EAX\n" 36 "run: SF=1; ZF=0; CF=0; OF=1\n" 37 "run: storing 0x80000000\n" @@ -107,7 +107,7 @@ if ('onhashchange' in window) { 46 // op ModR/M SIB displacement immediate 47 " 05 01 00 00 00 \n" // add 1 to EAX 48 ); - 49 CHECK_TRACE_CONTENTS( + 49 CHECK_TRACE_CONTENTS( 50 "run: add imm32 0x00000001 to EAX\n" 51 "run: SF=0; ZF=1; CF=1; OF=0\n" 52 "run: storing 0x00000000\n" @@ -121,7 +121,7 @@ if ('onhashchange' in window) { 60 // op ModR/M SIB displacement immediate 61 " 05 00 00 00 80 \n" // add 0x80000000 to EAX 62 ); - 63 CHECK_TRACE_CONTENTS( + 63 CHECK_TRACE_CONTENTS( 64 "run: add imm32 0x80000000 to EAX\n" 65 "run: SF=0; ZF=1; CF=1; OF=1\n" 66 "run: storing 0x00000000\n" @@ -131,7 +131,7 @@ if ('onhashchange' in window) { 70 //: 71 72 :(before "End Initialize Op Names") - 73 put_new(Name, "81", "combine rm32 with imm32 based on subop (add/sub/and/or/xor/cmp)"); + 73 put_new(Name, "81", "combine rm32 with imm32 based on subop (add/sub/and/or/xor/cmp)"); 74 75 :(code) 76 void test_add_imm32_to_r32() { @@ -142,7 +142,7 @@ if ('onhashchange' in window) { 81 " 81 c3 0a 0b 0c 0d\n" // add 0x0d0c0b0a to EBX 82 // ModR/M in binary: 11 (direct mode) 000 (subop add) 011 (dest EBX) 83 ); - 84 CHECK_TRACE_CONTENTS( + 84 CHECK_TRACE_CONTENTS( 85 "run: combine r/m32 with imm32\n" 86 "run: r/m32 is EBX\n" 87 "run: imm32 is 0x0d0c0b0a\n" @@ -154,10 +154,10 @@ if ('onhashchange' in window) { 93 :(before "End Single-Byte Opcodes") 94 case 0x81: { // combine r/m32 with imm32 95 trace(Callstack_depth+1, "run") << "combine r/m32 with imm32" << end(); - 96 const uint8_t modrm = next(); + 96 const uint8_t modrm = next(); 97 int32_t* signed_arg1 = effective_address(modrm); 98 const int32_t signed_arg2 = next32(); - 99 trace(Callstack_depth+1, "run") << "imm32 is 0x" << HEXWORD << signed_arg2 << end(); + 99 trace(Callstack_depth+1, "run") << "imm32 is 0x" << HEXWORD << signed_arg2 << end(); 100 const uint8_t subop = (modrm>>3)&0x7; // middle 3 'reg opcode' bits 101 switch (subop) { 102 case 0: { @@ -175,12 +175,12 @@ if ('onhashchange' in window) { 114 CF = (unsigned_result != unsigned_full_result); 115 trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); 116 *signed_arg1 = signed_result; - 117 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); + 117 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); 118 break; 119 } 120 // End Op 81 Subops 121 default: - 122 cerr << "unrecognized subop for opcode 81: " << NUM(subop) << '\n'; + 122 cerr << "unrecognized subop for opcode 81: " << NUM(subop) << '\n'; 123 exit(1); 124 } 125 break; @@ -195,7 +195,7 @@ if ('onhashchange' in window) { 134 " 81 c3 01 00 00 00\n" // add 1 to EBX 135 // ModR/M in binary: 11 (direct mode) 000 (subop add) 011 (dest EBX) 136 ); - 137 CHECK_TRACE_CONTENTS( + 137 CHECK_TRACE_CONTENTS( 138 "run: combine r/m32 with imm32\n" 139 "run: r/m32 is EBX\n" 140 "run: imm32 is 0x00000001\n" @@ -213,7 +213,7 @@ if ('onhashchange' in window) { 152 " 81 c3 01 00 00 00\n" // add 1 to EBX 153 // ModR/M in binary: 11 (direct mode) 011 (subop add) 011 (dest EBX) 154 ); - 155 CHECK_TRACE_CONTENTS( + 155 CHECK_TRACE_CONTENTS( 156 "run: combine r/m32 with imm32\n" 157 "run: r/m32 is EBX\n" 158 "run: imm32 is 0x00000001\n" @@ -231,7 +231,7 @@ if ('onhashchange' in window) { 170 " 81 c3 00 00 00 80\n" // add 0x80000000 to EBX 171 // ModR/M in binary: 11 (direct mode) 011 (subop add) 011 (dest EBX) 172 ); - 173 CHECK_TRACE_CONTENTS( + 173 CHECK_TRACE_CONTENTS( 174 "run: combine r/m32 with imm32\n" 175 "run: r/m32 is EBX\n" 176 "run: imm32 is 0x80000000\n" @@ -254,7 +254,7 @@ if ('onhashchange' in window) { 193 "== data 0x2000\n" 194 "01 00 00 00\n" // 0x00000001 195 ); - 196 CHECK_TRACE_CONTENTS( + 196 CHECK_TRACE_CONTENTS( 197 "run: combine r/m32 with imm32\n" 198 "run: effective address is 0x00002000 (EBX)\n" 199 "run: imm32 is 0x0d0c0b0a\n" @@ -266,7 +266,7 @@ if ('onhashchange' in window) { 205 //:: subtract 206 207 :(before "End Initialize Op Names") - 208 put_new(Name, "2d", "subtract imm32 from EAX (sub)"); + 208 put_new(Name, "2d", "subtract imm32 from EAX (sub)"); 209 210 :(code) 211 void test_subtract_imm32_from_EAX() { @@ -276,7 +276,7 @@ if ('onhashchange' in window) { 215 // op ModR/M SIB displacement immediate 216 " 2d 0a 0b 0c 0d \n" // subtract 0x0d0c0b0a from EAX 217 ); - 218 CHECK_TRACE_CONTENTS( + 218 CHECK_TRACE_CONTENTS( 219 "run: subtract imm32 0x0d0c0b0a from EAX\n" 220 "run: storing 0x000000a0\n" 221 ); @@ -285,7 +285,7 @@ if ('onhashchange' in window) { 224 :(before "End Single-Byte Opcodes") 225 case 0x2d: { // subtract imm32 from EAX 226 const int32_t signed_arg2 = next32(); - 227 trace(Callstack_depth+1, "run") << "subtract imm32 0x" << HEXWORD << signed_arg2 << " from EAX" << end(); + 227 trace(Callstack_depth+1, "run") << "subtract imm32 0x" << HEXWORD << signed_arg2 << " from EAX" << end(); 228 int32_t signed_result = Reg[EAX].i - signed_arg2; 229 SF = (signed_result < 0); 230 ZF = (signed_result == 0); @@ -298,7 +298,7 @@ if ('onhashchange' in window) { 237 CF = (unsigned_result != unsigned_full_result); 238 trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); 239 Reg[EAX].i = signed_result; - 240 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); + 240 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); 241 break; 242 } 243 @@ -310,7 +310,7 @@ if ('onhashchange' in window) { 249 // op ModR/M SIB displacement immediate 250 " 2d ff ff ff 7f \n" // subtract largest positive signed integer from EAX 251 ); - 252 CHECK_TRACE_CONTENTS( + 252 CHECK_TRACE_CONTENTS( 253 "run: subtract imm32 0x7fffffff from EAX\n" 254 "run: SF=0; ZF=0; CF=0; OF=1\n" 255 "run: storing 0x00000001\n" @@ -324,7 +324,7 @@ if ('onhashchange' in window) { 263 // op ModR/M SIB displacement immediate 264 " 2d 01 00 00 00 \n" // subtract 1 from EAX 265 ); - 266 CHECK_TRACE_CONTENTS( + 266 CHECK_TRACE_CONTENTS( 267 "run: subtract imm32 0x00000001 from EAX\n" 268 "run: SF=1; ZF=0; CF=1; OF=0\n" 269 "run: storing 0xffffffff\n" @@ -338,7 +338,7 @@ if ('onhashchange' in window) { 277 // op ModR/M SIB displacement immediate 278 " 2d 00 00 00 80 \n" // subtract smallest negative signed integer from EAX 279 ); - 280 CHECK_TRACE_CONTENTS( + 280 CHECK_TRACE_CONTENTS( 281 "run: subtract imm32 0x80000000 from EAX\n" 282 "run: SF=1; ZF=0; CF=1; OF=1\n" 283 "run: storing 0x80000000\n" @@ -357,7 +357,7 @@ if ('onhashchange' in window) { 296 "== data 0x2000\n" 297 "0a 00 00 00\n" // 0x0000000a 298 ); - 299 CHECK_TRACE_CONTENTS( + 299 CHECK_TRACE_CONTENTS( 300 "run: combine r/m32 with imm32\n" 301 "run: effective address is 0x00002000 (EBX)\n" 302 "run: imm32 is 0x00000001\n" @@ -382,7 +382,7 @@ if ('onhashchange' in window) { 321 CF = (unsigned_result != unsigned_full_result); 322 trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); 323 *signed_arg1 = signed_result; - 324 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); + 324 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); 325 break; 326 } 327 @@ -397,7 +397,7 @@ if ('onhashchange' in window) { 336 "== data 0x2000\n" 337 "00 00 00 80\n" // smallest negative signed integer 338 ); - 339 CHECK_TRACE_CONTENTS( + 339 CHECK_TRACE_CONTENTS( 340 "run: combine r/m32 with imm32\n" 341 "run: effective address is 0x00002000 (EBX)\n" 342 "run: effective address contains 80000000\n" @@ -418,7 +418,7 @@ if ('onhashchange' in window) { 357 "== data 0x2000\n" 358 "00 00 00 00\n" // 0 359 ); - 360 CHECK_TRACE_CONTENTS( + 360 CHECK_TRACE_CONTENTS( 361 "run: combine r/m32 with imm32\n" 362 "run: effective address is 0x00002000 (EBX)\n" 363 "run: effective address contains 0\n" @@ -439,7 +439,7 @@ if ('onhashchange' in window) { 378 "== data 0x2000\n" 379 "00 00 00 00\n" // 0 380 ); - 381 CHECK_TRACE_CONTENTS( + 381 CHECK_TRACE_CONTENTS( 382 "run: combine r/m32 with imm32\n" 383 "run: effective address is 0x00002000 (EBX)\n" 384 "run: effective address contains 0\n" @@ -460,7 +460,7 @@ if ('onhashchange' in window) { 399 " 81 eb 01 00 00 00 \n" // subtract 1 from EBX 400 // ModR/M in binary: 11 (direct mode) 101 (subop subtract) 011 (dest EBX) 401 ); - 402 CHECK_TRACE_CONTENTS( + 402 CHECK_TRACE_CONTENTS( 403 "run: combine r/m32 with imm32\n" 404 "run: r/m32 is EBX\n" 405 "run: imm32 is 0x00000001\n" @@ -472,7 +472,7 @@ if ('onhashchange' in window) { 411 //:: shift left 412 413 :(before "End Initialize Op Names") - 414 put_new(Name, "c1", "shift rm32 by imm8 bits depending on subop (sal/sar/shl/shr)"); + 414 put_new(Name, "c1", "shift rm32 by imm8 bits depending on subop (sal/sar/shl/shr)"); 415 416 :(code) 417 void test_shift_left_r32_with_imm8() { @@ -483,7 +483,7 @@ if ('onhashchange' in window) { 422 " c1 e3 01 \n" // shift EBX left by 1 bit 423 // ModR/M in binary: 11 (direct mode) 100 (subop shift left) 011 (dest EBX) 424 ); - 425 CHECK_TRACE_CONTENTS( + 425 CHECK_TRACE_CONTENTS( 426 "run: operate on r/m32\n" 427 "run: r/m32 is EBX\n" 428 "run: subop: shift left by CL bits\n" @@ -493,14 +493,14 @@ if ('onhashchange' in window) { 432 433 :(before "End Single-Byte Opcodes") 434 case 0xc1: { - 435 const uint8_t modrm = next(); + 435 const uint8_t modrm = next(); 436 trace(Callstack_depth+1, "run") << "operate on r/m32" << end(); 437 int32_t* arg1 = effective_address(modrm); 438 const uint8_t subop = (modrm>>3)&0x7; // middle 3 'reg opcode' bits 439 switch (subop) { 440 case 4: { // shift left r/m32 by CL 441 trace(Callstack_depth+1, "run") << "subop: shift left by CL bits" << end(); - 442 uint8_t count = next() & 0x1f; + 442 uint8_t count = next() & 0x1f; 443 // OF is only defined if count is 1 444 if (count == 1) { 445 bool msb = (*arg1 & 0x80000000) >> 1; @@ -512,12 +512,12 @@ if ('onhashchange' in window) { 451 SF = (*arg1 < 0); 452 // CF undefined 453 trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); - 454 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *arg1 << end(); + 454 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *arg1 << end(); 455 break; 456 } 457 // End Op c1 Subops 458 default: - 459 cerr << "unrecognized subop for opcode c1: " << NUM(subop) << '\n'; + 459 cerr << "unrecognized subop for opcode c1: " << NUM(subop) << '\n'; 460 exit(1); 461 } 462 break; @@ -534,7 +534,7 @@ if ('onhashchange' in window) { 473 " c1 fb 01 \n" // shift EBX right by 1 bit 474 // ModR/M in binary: 11 (direct mode) 111 (subop shift right arithmetic) 011 (dest EBX) 475 ); - 476 CHECK_TRACE_CONTENTS( + 476 CHECK_TRACE_CONTENTS( 477 "run: operate on r/m32\n" 478 "run: r/m32 is EBX\n" 479 "run: subop: shift right by CL bits, while preserving sign\n" @@ -545,7 +545,7 @@ if ('onhashchange' in window) { 484 :(before "End Op c1 Subops") 485 case 7: { // shift right r/m32 by CL, preserving sign 486 trace(Callstack_depth+1, "run") << "subop: shift right by CL bits, while preserving sign" << end(); - 487 uint8_t count = next() & 0x1f; + 487 uint8_t count = next() & 0x1f; 488 int32_t result = (*arg1 >> count); 489 ZF = (*arg1 == 0); 490 SF = (*arg1 < 0); @@ -555,7 +555,7 @@ if ('onhashchange' in window) { 494 CF = ((*arg1 >> (count-1)) & 0x1); 495 trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); 496 *arg1 = result; - 497 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *arg1 << end(); + 497 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *arg1 << end(); 498 break; 499 } 500 @@ -568,7 +568,7 @@ if ('onhashchange' in window) { 507 " c1 fb 01 \n" // shift EBX right by 1 bit 508 // ModR/M in binary: 11 (direct mode) 111 (subop shift right arithmetic) 011 (dest EBX) 509 ); - 510 CHECK_TRACE_CONTENTS( + 510 CHECK_TRACE_CONTENTS( 511 "run: operate on r/m32\n" 512 "run: r/m32 is EBX\n" 513 "run: subop: shift right by CL bits, while preserving sign\n" @@ -586,7 +586,7 @@ if ('onhashchange' in window) { 525 " c1 fb 01 \n" // shift EBX right by 1 bit, while preserving sign 526 // ModR/M in binary: 11 (direct mode) 111 (subop shift right arithmetic) 011 (dest EBX) 527 ); - 528 CHECK_TRACE_CONTENTS( + 528 CHECK_TRACE_CONTENTS( 529 "run: operate on r/m32\n" 530 "run: r/m32 is EBX\n" 531 "run: subop: shift right by CL bits, while preserving sign\n" @@ -606,7 +606,7 @@ if ('onhashchange' in window) { 545 " c1 eb 01 \n" // shift EBX right by 1 bit, while padding zeroes 546 // ModR/M in binary: 11 (direct mode) 101 (subop shift right logical) 011 (dest EBX) 547 ); - 548 CHECK_TRACE_CONTENTS( + 548 CHECK_TRACE_CONTENTS( 549 "run: operate on r/m32\n" 550 "run: r/m32 is EBX\n" 551 "run: subop: shift right by CL bits, while padding zeroes\n" @@ -617,7 +617,7 @@ if ('onhashchange' in window) { 556 :(before "End Op c1 Subops") 557 case 5: { // shift right r/m32 by CL, preserving sign 558 trace(Callstack_depth+1, "run") << "subop: shift right by CL bits, while padding zeroes" << end(); - 559 uint8_t count = next() & 0x1f; + 559 uint8_t count = next() & 0x1f; 560 // OF is only defined if count is 1 561 if (count == 1) { 562 bool msb = (*arg1 & 0x80000000) >> 1; @@ -631,7 +631,7 @@ if ('onhashchange' in window) { 570 SF = false; 571 // CF undefined 572 trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); - 573 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *arg1 << end(); + 573 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *arg1 << end(); 574 break; 575 } 576 @@ -643,7 +643,7 @@ if ('onhashchange' in window) { 582 // op ModR/M SIB displacement immediate 583 " c1 eb 01 \n" // shift EBX right by 1 bit, while padding zeroes 584 ); - 585 CHECK_TRACE_CONTENTS( + 585 CHECK_TRACE_CONTENTS( 586 "run: operate on r/m32\n" 587 "run: r/m32 is EBX\n" 588 "run: subop: shift right by CL bits, while padding zeroes\n" @@ -661,7 +661,7 @@ if ('onhashchange' in window) { 600 " c1 eb 01 \n" // shift EBX right by 1 bit, while padding zeroes 601 // ModR/M in binary: 11 (direct mode) 101 (subop shift right logical) 011 (dest EBX) 602 ); - 603 CHECK_TRACE_CONTENTS( + 603 CHECK_TRACE_CONTENTS( 604 "run: operate on r/m32\n" 605 "run: r/m32 is EBX\n" 606 "run: subop: shift right by CL bits, while padding zeroes\n" @@ -672,7 +672,7 @@ if ('onhashchange' in window) { 611 //:: and 612 613 :(before "End Initialize Op Names") - 614 put_new(Name, "25", "EAX = bitwise AND of imm32 with EAX (and)"); + 614 put_new(Name, "25", "EAX = bitwise AND of imm32 with EAX (and)"); 615 616 :(code) 617 void test_and_EAX_with_imm32() { @@ -682,7 +682,7 @@ if ('onhashchange' in window) { 621 // op ModR/M SIB displacement immediate 622 " 25 0a 0b 0c 0d \n" // and 0x0d0c0b0a with EAX 623 ); - 624 CHECK_TRACE_CONTENTS( + 624 CHECK_TRACE_CONTENTS( 625 "run: and imm32 0x0d0c0b0a with EAX\n" 626 "run: storing 0x0000000a\n" 627 ); @@ -693,9 +693,9 @@ if ('onhashchange' in window) { 632 // bitwise ops technically operate on unsigned numbers, but it makes no 633 // difference 634 const int32_t signed_arg2 = next32(); - 635 trace(Callstack_depth+1, "run") << "and imm32 0x" << HEXWORD << signed_arg2 << " with EAX" << end(); + 635 trace(Callstack_depth+1, "run") << "and imm32 0x" << HEXWORD << signed_arg2 << " with EAX" << end(); 636 Reg[EAX].i &= signed_arg2; - 637 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); + 637 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); 638 SF = (Reg[EAX].i >> 31); 639 ZF = (Reg[EAX].i == 0); 640 CF = false; @@ -717,7 +717,7 @@ if ('onhashchange' in window) { 656 "== data 0x2000\n" 657 "ff 00 00 00\n" // 0x000000ff 658 ); - 659 CHECK_TRACE_CONTENTS( + 659 CHECK_TRACE_CONTENTS( 660 "run: combine r/m32 with imm32\n" 661 "run: effective address is 0x00002000 (EBX)\n" 662 "run: imm32 is 0x0d0c0b0a\n" @@ -732,7 +732,7 @@ if ('onhashchange' in window) { 671 // bitwise ops technically operate on unsigned numbers, but it makes no 672 // difference 673 *signed_arg1 &= signed_arg2; - 674 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); + 674 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); 675 SF = (*signed_arg1 >> 31); 676 ZF = (*signed_arg1 == 0); 677 CF = false; @@ -752,7 +752,7 @@ if ('onhashchange' in window) { 691 " 81 e3 0a 0b 0c 0d \n" // and 0x0d0c0b0a with EBX 692 // ModR/M in binary: 11 (direct mode) 100 (subop and) 011 (dest EBX) 693 ); - 694 CHECK_TRACE_CONTENTS( + 694 CHECK_TRACE_CONTENTS( 695 "run: combine r/m32 with imm32\n" 696 "run: r/m32 is EBX\n" 697 "run: imm32 is 0x0d0c0b0a\n" @@ -764,7 +764,7 @@ if ('onhashchange' in window) { 703 //:: or 704 705 :(before "End Initialize Op Names") - 706 put_new(Name, "0d", "EAX = bitwise OR of imm32 with EAX (or)"); + 706 put_new(Name, "0d", "EAX = bitwise OR of imm32 with EAX (or)"); 707 708 :(code) 709 void test_or_EAX_with_imm32() { @@ -774,7 +774,7 @@ if ('onhashchange' in window) { 713 // op ModR/M SIB displacement immediate 714 " 0d 0a 0b 0c 0d \n" // or 0x0d0c0b0a with EAX 715 ); - 716 CHECK_TRACE_CONTENTS( + 716 CHECK_TRACE_CONTENTS( 717 "run: or imm32 0x0d0c0b0a with EAX\n" 718 "run: storing 0xddccbbaa\n" 719 ); @@ -785,9 +785,9 @@ if ('onhashchange' in window) { 724 // bitwise ops technically operate on unsigned numbers, but it makes no 725 // difference 726 const int32_t signed_arg2 = next32(); - 727 trace(Callstack_depth+1, "run") << "or imm32 0x" << HEXWORD << signed_arg2 << " with EAX" << end(); + 727 trace(Callstack_depth+1, "run") << "or imm32 0x" << HEXWORD << signed_arg2 << " with EAX" << end(); 728 Reg[EAX].i |= signed_arg2; - 729 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); + 729 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); 730 SF = (Reg[EAX].i >> 31); 731 ZF = (Reg[EAX].i == 0); 732 CF = false; @@ -809,7 +809,7 @@ if ('onhashchange' in window) { 748 "== data 0x2000\n" 749 "a0 b0 c0 d0\n" // 0xd0c0b0a0 750 ); - 751 CHECK_TRACE_CONTENTS( + 751 CHECK_TRACE_CONTENTS( 752 "run: combine r/m32 with imm32\n" 753 "run: effective address is 0x00002000 (EBX)\n" 754 "run: imm32 is 0x0d0c0b0a\n" @@ -824,7 +824,7 @@ if ('onhashchange' in window) { 763 // bitwise ops technically operate on unsigned numbers, but it makes no 764 // difference 765 *signed_arg1 |= signed_arg2; - 766 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); + 766 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); 767 SF = (*signed_arg1 >> 31); 768 ZF = (*signed_arg1 == 0); 769 CF = false; @@ -842,7 +842,7 @@ if ('onhashchange' in window) { 781 " 81 cb 0a 0b 0c 0d \n" // or 0x0d0c0b0a with EBX 782 // ModR/M in binary: 11 (direct mode) 001 (subop or) 011 (dest EBX) 783 ); - 784 CHECK_TRACE_CONTENTS( + 784 CHECK_TRACE_CONTENTS( 785 "run: combine r/m32 with imm32\n" 786 "run: r/m32 is EBX\n" 787 "run: imm32 is 0x0d0c0b0a\n" @@ -854,7 +854,7 @@ if ('onhashchange' in window) { 793 //:: xor 794 795 :(before "End Initialize Op Names") - 796 put_new(Name, "35", "EAX = bitwise XOR of imm32 with EAX (xor)"); + 796 put_new(Name, "35", "EAX = bitwise XOR of imm32 with EAX (xor)"); 797 798 :(code) 799 void test_xor_EAX_with_imm32() { @@ -864,7 +864,7 @@ if ('onhashchange' in window) { 803 // op ModR/M SIB displacement immediate 804 " 35 0a 0b 0c 0d \n" // xor 0x0d0c0b0a with EAX 805 ); - 806 CHECK_TRACE_CONTENTS( + 806 CHECK_TRACE_CONTENTS( 807 "run: xor imm32 0x0d0c0b0a with EAX\n" 808 "run: storing 0xd0c0bbaa\n" 809 ); @@ -875,9 +875,9 @@ if ('onhashchange' in window) { 814 // bitwise ops technically operate on unsigned numbers, but it makes no 815 // difference 816 const int32_t signed_arg2 = next32(); - 817 trace(Callstack_depth+1, "run") << "xor imm32 0x" << HEXWORD << signed_arg2 << " with EAX" << end(); + 817 trace(Callstack_depth+1, "run") << "xor imm32 0x" << HEXWORD << signed_arg2 << " with EAX" << end(); 818 Reg[EAX].i ^= signed_arg2; - 819 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); + 819 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); 820 SF = (Reg[EAX].i >> 31); 821 ZF = (Reg[EAX].i == 0); 822 CF = false; @@ -899,7 +899,7 @@ if ('onhashchange' in window) { 838 "== data 0x2000\n" 839 "a0 b0 c0 d0\n" // 0xd0c0b0a0 840 ); - 841 CHECK_TRACE_CONTENTS( + 841 CHECK_TRACE_CONTENTS( 842 "run: combine r/m32 with imm32\n" 843 "run: effective address is 0x00002000 (EBX)\n" 844 "run: imm32 is 0x0d0c0b0a\n" @@ -914,7 +914,7 @@ if ('onhashchange' in window) { 853 // bitwise ops technically operate on unsigned numbers, but it makes no 854 // difference 855 *signed_arg1 ^= signed_arg2; - 856 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); + 856 trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << *signed_arg1 << end(); 857 SF = (*signed_arg1 >> 31); 858 ZF = (*signed_arg1 == 0); 859 CF = false; @@ -932,7 +932,7 @@ if ('onhashchange' in window) { 871 " 81 f3 0a 0b 0c 0d \n" // xor 0x0d0c0b0a with EBX 872 // ModR/M in binary: 11 (direct mode) 110 (subop xor) 011 (dest EBX) 873 ); - 874 CHECK_TRACE_CONTENTS( + 874 CHECK_TRACE_CONTENTS( 875 "run: combine r/m32 with imm32\n" 876 "run: r/m32 is EBX\n" 877 "run: imm32 is 0x0d0c0b0a\n" @@ -944,7 +944,7 @@ if ('onhashchange' in window) { 883 //:: compare (cmp) 884 885 :(before "End Initialize Op Names") - 886 put_new(Name, "3d", "compare: set SF if EAX < imm32 (cmp)"); + 886 put_new(Name, "3d", "compare: set SF if EAX < imm32 (cmp)"); 887 888 :(code) 889 void test_compare_EAX_with_imm32_greater() { @@ -954,7 +954,7 @@ if ('onhashchange' in window) { 893 // op ModR/M SIB displacement immediate 894 " 3d 07 0b 0c 0d \n" // compare EAX with 0x0d0c0b07 895 ); - 896 CHECK_TRACE_CONTENTS( + 896 CHECK_TRACE_CONTENTS( 897 "run: compare EAX with imm32 0x0d0c0b07\n" 898 "run: SF=0; ZF=0; CF=0; OF=0\n" 899 ); @@ -964,7 +964,7 @@ if ('onhashchange' in window) { 903 case 0x3d: { // compare EAX with imm32 904 const int32_t signed_arg1 = Reg[EAX].i; 905 const int32_t signed_arg2 = next32(); - 906 trace(Callstack_depth+1, "run") << "compare EAX with imm32 0x" << HEXWORD << signed_arg2 << end(); + 906 trace(Callstack_depth+1, "run") << "compare EAX with imm32 0x" << HEXWORD << signed_arg2 << end(); 907 const int32_t signed_difference = signed_arg1 - signed_arg2; 908 SF = (signed_difference < 0); 909 ZF = (signed_difference == 0); @@ -987,7 +987,7 @@ if ('onhashchange' in window) { 926 // op ModR/M SIB displacement immediate 927 " 3d 0d 0c 0b 0a \n" // compare EAX with imm32 928 ); - 929 CHECK_TRACE_CONTENTS( + 929 CHECK_TRACE_CONTENTS( 930 "run: compare EAX with imm32 0x0a0b0c0d\n" 931 "run: SF=1; ZF=0; CF=1; OF=0\n" 932 ); @@ -1000,7 +1000,7 @@ if ('onhashchange' in window) { 939 // op ModR/M SIB displacement immediate 940 " 3d 00 00 00 80\n" // compare EAX with smallest negative signed integer 941 ); - 942 CHECK_TRACE_CONTENTS( + 942 CHECK_TRACE_CONTENTS( 943 "run: compare EAX with imm32 0x80000000\n" 944 "run: SF=1; ZF=0; CF=1; OF=1\n" 945 ); @@ -1013,7 +1013,7 @@ if ('onhashchange' in window) { 952 // op ModR/M SIB displacement immediate 953 " 3d 01 00 00 00\n" // compare EAX with 1 954 ); - 955 CHECK_TRACE_CONTENTS( + 955 CHECK_TRACE_CONTENTS( 956 "run: compare EAX with imm32 0x00000001\n" 957 "run: SF=1; ZF=0; CF=0; OF=0\n" 958 ); @@ -1026,7 +1026,7 @@ if ('onhashchange' in window) { 965 // op ModR/M SIB displacement immediate 966 " 3d ff ff ff ff\n" // compare EAX with -1 967 ); - 968 CHECK_TRACE_CONTENTS( + 968 CHECK_TRACE_CONTENTS( 969 "run: compare EAX with imm32 0xffffffff\n" 970 "run: SF=0; ZF=0; CF=1; OF=0\n" 971 ); @@ -1039,7 +1039,7 @@ if ('onhashchange' in window) { 978 // op ModR/M SIB displacement immediate 979 " 3d 0a 0b 0c 0d \n" // compare 0x0d0c0b0a with EAX 980 ); - 981 CHECK_TRACE_CONTENTS( + 981 CHECK_TRACE_CONTENTS( 982 "run: compare EAX with imm32 0x0d0c0b0a\n" 983 "run: SF=0; ZF=1; CF=0; OF=0\n" 984 ); @@ -1055,7 +1055,7 @@ if ('onhashchange' in window) { 994 " 81 fb 07 0b 0c 0d \n" // compare 0x0d0c0b07 with EBX 995 // ModR/M in binary: 11 (direct mode) 111 (subop compare) 011 (dest EBX) 996 ); - 997 CHECK_TRACE_CONTENTS( + 997 CHECK_TRACE_CONTENTS( 998 "run: combine r/m32 with imm32\n" 999 "run: r/m32 is EBX\n" 1000 "run: imm32 is 0x0d0c0b07\n" @@ -1089,7 +1089,7 @@ if ('onhashchange' in window) { 1028 " 81 f8 0d 0c 0b 0a \n" // compare EAX with imm32 1029 // ModR/M in binary: 11 (direct mode) 111 (subop compare) 000 (dest EAX) 1030 ); -1031 CHECK_TRACE_CONTENTS( +1031 CHECK_TRACE_CONTENTS( 1032 "run: combine r/m32 with imm32\n" 1033 "run: r/m32 is EAX\n" 1034 "run: imm32 is 0x0a0b0c0d\n" @@ -1106,7 +1106,7 @@ if ('onhashchange' in window) { 1045 " 81 f8 00 00 00 80\n" // compare EAX with smallest negative signed integer 1046 // ModR/M in binary: 11 (direct mode) 111 (subop compare) 000 (dest EAX) 1047 ); -1048 CHECK_TRACE_CONTENTS( +1048 CHECK_TRACE_CONTENTS( 1049 "run: combine r/m32 with imm32\n" 1050 "run: r/m32 is EAX\n" 1051 "run: imm32 is 0x80000000\n" @@ -1123,7 +1123,7 @@ if ('onhashchange' in window) { 1062 " 81 f8 01 00 00 00\n" // compare EAX with 1 1063 // ModR/M in binary: 11 (direct mode) 111 (subop compare) 000 (dest EAX) 1064 ); -1065 CHECK_TRACE_CONTENTS( +1065 CHECK_TRACE_CONTENTS( 1066 "run: combine r/m32 with imm32\n" 1067 "run: r/m32 is EAX\n" 1068 "run: imm32 is 0x00000001\n" @@ -1140,7 +1140,7 @@ if ('onhashchange' in window) { 1079 " 81 f8 ff ff ff ff\n" // compare EAX with -1 1080 // ModR/M in binary: 11 (direct mode) 111 (subop compare) 000 (dest EAX) 1081 ); -1082 CHECK_TRACE_CONTENTS( +1082 CHECK_TRACE_CONTENTS( 1083 "run: combine r/m32 with imm32\n" 1084 "run: r/m32 is EAX\n" 1085 "run: imm32 is 0xffffffff\n" @@ -1158,7 +1158,7 @@ if ('onhashchange' in window) { 1097 " 81 fb 0a 0b 0c 0d \n" // compare 0x0d0c0b0a with EBX 1098 // ModR/M in binary: 11 (direct mode) 111 (subop compare) 011 (dest EBX) 1099 ); -1100 CHECK_TRACE_CONTENTS( +1100 CHECK_TRACE_CONTENTS( 1101 "run: combine r/m32 with imm32\n" 1102 "run: r/m32 is EBX\n" 1103 "run: imm32 is 0x0d0c0b0a\n" @@ -1177,7 +1177,7 @@ if ('onhashchange' in window) { 1116 "== data 0x2000\n" 1117 "0a 0b 0c 0d\n" // 0x0d0c0b0a 1118 ); -1119 CHECK_TRACE_CONTENTS( +1119 CHECK_TRACE_CONTENTS( 1120 "run: combine r/m32 with imm32\n" 1121 "run: effective address is 0x00002000 (EBX)\n" 1122 "run: imm32 is 0x0d0c0b07\n" @@ -1196,7 +1196,7 @@ if ('onhashchange' in window) { 1135 "== data 0x2000\n" 1136 "07 0b 0c 0d\n" // 0x0d0c0b07 1137 ); -1138 CHECK_TRACE_CONTENTS( +1138 CHECK_TRACE_CONTENTS( 1139 "run: combine r/m32 with imm32\n" 1140 "run: effective address is 0x00002000 (EAX)\n" 1141 "run: imm32 is 0x0d0c0b0a\n" @@ -1216,7 +1216,7 @@ if ('onhashchange' in window) { 1155 "== data 0x2000\n" 1156 "0a 0b 0c 0d\n" // 0x0d0c0b0a 1157 ); -1158 CHECK_TRACE_CONTENTS( +1158 CHECK_TRACE_CONTENTS( 1159 "run: combine r/m32 with imm32\n" 1160 "run: effective address is 0x00002000 (EBX)\n" 1161 "run: imm32 is 0x0d0c0b0a\n" @@ -1228,13 +1228,13 @@ if ('onhashchange' in window) { 1167 1168 :(before "End Initialize Op Names") 1169 // b8 defined earlier to copy imm32 to EAX -1170 put_new(Name, "b9", "copy imm32 to ECX (mov)"); -1171 put_new(Name, "ba", "copy imm32 to EDX (mov)"); -1172 put_new(Name, "bb", "copy imm32 to EBX (mov)"); -1173 put_new(Name, "bc", "copy imm32 to ESP (mov)"); -1174 put_new(Name, "bd", "copy imm32 to EBP (mov)"); -1175 put_new(Name, "be", "copy imm32 to ESI (mov)"); -1176 put_new(Name, "bf", "copy imm32 to EDI (mov)"); +1170 put_new(Name, "b9", "copy imm32 to ECX (mov)"); +1171 put_new(Name, "ba", "copy imm32 to EDX (mov)"); +1172 put_new(Name, "bb", "copy imm32 to EBX (mov)"); +1173 put_new(Name, "bc", "copy imm32 to ESP (mov)"); +1174 put_new(Name, "bd", "copy imm32 to EBP (mov)"); +1175 put_new(Name, "be", "copy imm32 to ESI (mov)"); +1176 put_new(Name, "bf", "copy imm32 to EDI (mov)"); 1177 1178 :(code) 1179 void test_copy_imm32_to_r32() { @@ -1243,7 +1243,7 @@ if ('onhashchange' in window) { 1182 // op ModR/M SIB displacement immediate 1183 " bb 0a 0b 0c 0d \n" // copy 0x0d0c0b0a to EBX 1184 ); -1185 CHECK_TRACE_CONTENTS( +1185 CHECK_TRACE_CONTENTS( 1186 "run: copy imm32 0x0d0c0b0a to EBX\n" 1187 ); 1188 } @@ -1258,7 +1258,7 @@ if ('onhashchange' in window) { 1197 case 0xbf: { // copy imm32 to r32 1198 const uint8_t rdest = op & 0x7; 1199 const int32_t src = next32(); -1200 trace(Callstack_depth+1, "run") << "copy imm32 0x" << HEXWORD << src << " to " << rname(rdest) << end(); +1200 trace(Callstack_depth+1, "run") << "copy imm32 0x" << HEXWORD << src << " to " << rname(rdest) << end(); 1201 Reg[rdest].i = src; 1202 break; 1203 } @@ -1266,7 +1266,7 @@ if ('onhashchange' in window) { 1205 //: 1206 1207 :(before "End Initialize Op Names") -1208 put_new(Name, "c7", "copy imm32 to rm32 (mov)"); +1208 put_new(Name, "c7", "copy imm32 to rm32 (mov)"); 1209 1210 :(code) 1211 void test_copy_imm32_to_mem_at_r32() { @@ -1277,7 +1277,7 @@ if ('onhashchange' in window) { 1216 " c7 03 0a 0b 0c 0d \n" // copy 0x0d0c0b0a to *EBX 1217 // ModR/M in binary: 00 (indirect mode) 000 (unused) 011 (dest EBX) 1218 ); -1219 CHECK_TRACE_CONTENTS( +1219 CHECK_TRACE_CONTENTS( 1220 "run: copy imm32 to r/m32\n" 1221 "run: effective address is 0x00000060 (EBX)\n" 1222 "run: imm32 is 0x0d0c0b0a\n" @@ -1286,16 +1286,16 @@ if ('onhashchange' in window) { 1225 1226 :(before "End Single-Byte Opcodes") 1227 case 0xc7: { // copy imm32 to r32 -1228 const uint8_t modrm = next(); +1228 const uint8_t modrm = next(); 1229 trace(Callstack_depth+1, "run") << "copy imm32 to r/m32" << end(); 1230 const uint8_t subop = (modrm>>3)&0x7; // middle 3 'reg opcode' bits 1231 if (subop != 0) { -1232 cerr << "unrecognized subop for opcode c7: " << NUM(subop) << " (only 0/copy currently implemented)\n"; +1232 cerr << "unrecognized subop for opcode c7: " << NUM(subop) << " (only 0/copy currently implemented)\n"; 1233 exit(1); 1234 } 1235 int32_t* dest = effective_address(modrm); 1236 const int32_t src = next32(); -1237 trace(Callstack_depth+1, "run") << "imm32 is 0x" << HEXWORD << src << end(); +1237 trace(Callstack_depth+1, "run") << "imm32 is 0x" << HEXWORD << src << end(); 1238 *dest = src; 1239 break; 1240 } @@ -1303,7 +1303,7 @@ if ('onhashchange' in window) { 1242 //:: push 1243 1244 :(before "End Initialize Op Names") -1245 put_new(Name, "68", "push imm32 to stack (push)"); +1245 put_new(Name, "68", "push imm32 to stack (push)"); 1246 1247 :(code) 1248 void test_push_imm32() { @@ -1314,7 +1314,7 @@ if ('onhashchange' in window) { 1253 // op ModR/M SIB displacement immediate 1254 " 68 af 00 00 00 \n" // push *EAX to stack 1255 ); -1256 CHECK_TRACE_CONTENTS( +1256 CHECK_TRACE_CONTENTS( 1257 "run: push imm32 0x000000af\n" 1258 "run: ESP is now 0xbd000010\n" 1259 "run: contents at ESP: 0x000000af\n" @@ -1324,11 +1324,11 @@ if ('onhashchange' in window) { 1263 :(before "End Single-Byte Opcodes") 1264 case 0x68: { 1265 const uint32_t val = static_cast<uint32_t>(next32()); -1266 trace(Callstack_depth+1, "run") << "push imm32 0x" << HEXWORD << val << end(); +1266 trace(Callstack_depth+1, "run") << "push imm32 0x" << HEXWORD << val << end(); 1267 //? cerr << "push: " << val << " => " << Reg[ESP].u << '\n'; 1268 push(val); -1269 trace(Callstack_depth+1, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); -1270 trace(Callstack_depth+1, "run") << "contents at ESP: 0x" << HEXWORD << read_mem_u32(Reg[ESP].u) << end(); +1269 trace(Callstack_depth+1, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); +1270 trace(Callstack_depth+1, "run") << "contents at ESP: 0x" << HEXWORD << read_mem_u32(Reg[ESP].u) << end(); 1271 break; 1272 } -- cgit 1.4.1-2-gfad0