Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Side by Side Diff: src/ia32/disasm-ia32.cc

Issue 176993004: Print properly signed displacement in IA32 disassembler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 return 5; 400 return 5;
401 } else if (rm == esp) { 401 } else if (rm == esp) {
402 byte sib = *(modrmp + 1); 402 byte sib = *(modrmp + 1);
403 int scale, index, base; 403 int scale, index, base;
404 get_sib(sib, &scale, &index, &base); 404 get_sib(sib, &scale, &index, &base);
405 if (index == esp && base == esp && scale == 0 /*times_1*/) { 405 if (index == esp && base == esp && scale == 0 /*times_1*/) {
406 AppendToBuffer("[%s]", (this->*register_name)(rm)); 406 AppendToBuffer("[%s]", (this->*register_name)(rm));
407 return 2; 407 return 2;
408 } else if (base == ebp) { 408 } else if (base == ebp) {
409 int32_t disp = *reinterpret_cast<int32_t*>(modrmp + 2); 409 int32_t disp = *reinterpret_cast<int32_t*>(modrmp + 2);
410 AppendToBuffer("[%s*%d+0x%x]", 410 AppendToBuffer("[%s*%d+0x%x]",
titzer 2014/03/04 13:43:35 Here too!
Michael Starzinger 2014/03/04 18:29:53 Done.
411 (this->*register_name)(index), 411 (this->*register_name)(index),
412 1 << scale, 412 1 << scale,
413 disp); 413 disp);
414 return 6; 414 return 6;
415 } else if (index != esp && base != ebp) { 415 } else if (index != esp && base != ebp) {
416 // [base+index*scale] 416 // [base+index*scale]
417 AppendToBuffer("[%s+%s*%d]", 417 AppendToBuffer("[%s+%s*%d]",
418 (this->*register_name)(base), 418 (this->*register_name)(base),
419 (this->*register_name)(index), 419 (this->*register_name)(index),
420 1 << scale); 420 1 << scale);
421 return 2; 421 return 2;
422 } else { 422 } else {
423 UnimplementedInstruction(); 423 UnimplementedInstruction();
424 return 1; 424 return 1;
425 } 425 }
426 } else { 426 } else {
427 AppendToBuffer("[%s]", (this->*register_name)(rm)); 427 AppendToBuffer("[%s]", (this->*register_name)(rm));
428 return 1; 428 return 1;
429 } 429 }
430 break; 430 break;
431 case 1: // fall through 431 case 1: // fall through
432 case 2: 432 case 2:
433 if (rm == esp) { 433 if (rm == esp) {
434 byte sib = *(modrmp + 1); 434 byte sib = *(modrmp + 1);
435 int scale, index, base; 435 int scale, index, base;
436 get_sib(sib, &scale, &index, &base); 436 get_sib(sib, &scale, &index, &base);
437 int disp = 437 int disp =
438 mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 2) : *(modrmp + 2); 438 mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 2) : *(modrmp + 2);
439 if (index == base && index == rm /*esp*/ && scale == 0 /*times_1*/) { 439 if (index == base && index == rm /*esp*/ && scale == 0 /*times_1*/) {
440 AppendToBuffer("[%s+0x%x]", (this->*register_name)(rm), disp); 440 AppendToBuffer("[%s+0x%x]", (this->*register_name)(rm), disp);
titzer 2014/03/04 13:43:35 Here too!
Michael Starzinger 2014/03/04 18:29:53 Done.
441 } else { 441 } else {
442 AppendToBuffer("[%s+%s*%d+0x%x]", 442 AppendToBuffer("[%s+%s*%d+0x%x]",
titzer 2014/03/04 13:43:35 Here too!
Michael Starzinger 2014/03/04 18:29:53 Done.
443 (this->*register_name)(base), 443 (this->*register_name)(base),
444 (this->*register_name)(index), 444 (this->*register_name)(index),
445 1 << scale, 445 1 << scale,
446 disp); 446 disp);
447 } 447 }
448 return mod == 2 ? 6 : 3; 448 return mod == 2 ? 6 : 3;
449 } else { 449 } else {
450 // No sib. 450 // No sib.
451 int disp = 451 int disp =
452 mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 1) : *(modrmp + 1); 452 mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 1) :
453 AppendToBuffer("[%s+0x%x]", (this->*register_name)(rm), disp); 453 *reinterpret_cast<int8_t*>(modrmp + 1);
454 AppendToBuffer("[%s%s0x%x]",
455 (this->*register_name)(rm),
456 disp < 0 ? "-" : "+",
457 disp < 0 ? -disp : disp);
titzer 2014/03/04 13:43:35 I think you want a subroutine for adding the displ
Michael Starzinger 2014/03/04 18:29:53 Done for x64. No subroutine though, I think that's
454 return mod == 2 ? 5 : 2; 458 return mod == 2 ? 5 : 2;
455 } 459 }
456 break; 460 break;
457 case 3: 461 case 3:
458 AppendToBuffer("%s", (this->*register_name)(rm)); 462 AppendToBuffer("%s", (this->*register_name)(rm));
459 return 1; 463 return 1;
460 default: 464 default:
461 UnimplementedInstruction(); 465 UnimplementedInstruction();
462 return 1; 466 return 1;
463 } 467 }
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 fprintf(f, " "); 1772 fprintf(f, " ");
1769 } 1773 }
1770 fprintf(f, " %s\n", buffer.start()); 1774 fprintf(f, " %s\n", buffer.start());
1771 } 1775 }
1772 } 1776 }
1773 1777
1774 1778
1775 } // namespace disasm 1779 } // namespace disasm
1776 1780
1777 #endif // V8_TARGET_ARCH_IA32 1781 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698