| 519 | } |
| 520 | |
| 521 | void DisassemblyFunction::load() |
| 522 | { |
| 523 | generateBranchLines(); |
| 524 | |
| 525 | // gather all branch targets |
| 526 | std::set<u32> branchTargets; |
| 527 | for (size_t i = 0; i < lines.size(); i++) |
| 528 | { |
| 529 | switch (lines[i].type) |
| 530 | { |
| 531 | case LINE_DOWN: |
| 532 | branchTargets.insert(lines[i].second); |
| 533 | break; |
| 534 | case LINE_UP: |
| 535 | branchTargets.insert(lines[i].first); |
| 536 | break; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | u32 funcPos = address; |
| 541 | u32 funcEnd = address+size; |
| 542 | |
| 543 | SymbolInfo nextData = cpu->GetSymbolGuardian().SymbolAfterAddress( |
| 544 | funcPos-1, ccc::GLOBAL_VARIABLE | ccc::LOCAL_VARIABLE); |
| 545 | u32 opcodeSequenceStart = funcPos; |
| 546 | while (funcPos < funcEnd) |
| 547 | { |
| 548 | if (funcPos == nextData.address.value && nextData.size > 0) |
| 549 | { |
| 550 | if (opcodeSequenceStart != funcPos) |
| 551 | addOpcodeSequence(opcodeSequenceStart,funcPos); |
| 552 | |
| 553 | DisassemblyData* data = new DisassemblyData(cpu,funcPos,nextData.size,DATATYPE_WORD); |
| 554 | entries[funcPos] = data; |
| 555 | lineAddresses.push_back(funcPos); |
| 556 | funcPos += data->getTotalSize(); |
| 557 | |
| 558 | nextData = cpu->GetSymbolGuardian().SymbolAfterAddress(funcPos-1, |
| 559 | ccc::GLOBAL_VARIABLE | ccc::LOCAL_VARIABLE); |
| 560 | opcodeSequenceStart = funcPos; |
| 561 | continue; |
| 562 | } |
| 563 | |
| 564 | // force align |
| 565 | if (funcPos % 4) |
| 566 | { |
| 567 | u32 nextPos = (funcPos+3) & ~3; |
| 568 | |
| 569 | DisassemblyComment* comment = new DisassemblyComment(cpu,funcPos,nextPos-funcPos,".align","4"); |
| 570 | entries[funcPos] = comment; |
| 571 | lineAddresses.push_back(funcPos); |
| 572 | |
| 573 | funcPos = nextPos; |
| 574 | opcodeSequenceStart = funcPos; |
| 575 | continue; |
| 576 | } |
| 577 | |
| 578 | MIPSAnalyst::MipsOpcodeInfo opInfo = MIPSAnalyst::GetOpcodeInfo(cpu,funcPos); |
no test coverage detected