예제 #1
0
파일: disassem.cpp 프로젝트: trieck/source
CString Disassembler::Get(USHORT &address)
{
    Memory *mem = Memory::instance();
    BYTE b = mem->Get(address);

    const Instruction *pInstr = instructions[b];

    return FormatInstruction(pInstr, b, address);
}
예제 #2
0
파일: StackView.cpp 프로젝트: trieck/source
CString StackView::GetLine(USHORT i)
{
    static const TCHAR line[] = _T("$1%.2hX:  %.2hX");
    TCHAR buf[10];

    Memory* mem = Memory::instance();

    _stprintf(buf, line, 0xff - i, mem->Get(0x1ff - i));

    return buf;
}
예제 #3
0
파일: disassem.cpp 프로젝트: trieck/source
CString Disassembler::FormatInstruction(const Instruction *pInstr,
                                        USHORT &address)
{
    Memory *mem = Memory::instance();

    BYTE b1, b2;
    CString output;

    switch (pInstr->mode) {
    case IMMEDIATE:
        address++;
        b1 = mem->Get(address++);
        output.Format(_T("%.2hX      %s #$%.2hX"),
                      b1, pInstr->mnemonic, b1);
        break;
    case _ABSOLUTE:
        address++;
        b1 = mem->Get(address++);
        b2 = mem->Get(address++);
        output.Format(_T("%.2hX %.2hX   %s $%.4hX"),
                      b1, b2, pInstr->mnemonic, MAKEWORD(b1, b2));
        break;
    case ZPAGE:
        address++;
        b1 = mem->Get(address++);
        output.Format(_T("%.2hX      %s $%.2hX"),
                      b1, pInstr->mnemonic, b1);
        break;
    case ACCUM:
        address++;
        output.Format(_T("        %s"), pInstr->mnemonic);
        break;
    case IMPLIED:
        address++;
        output.Format(_T("        %s"), pInstr->mnemonic);
        break;
    case INDX:
        address++;
        b1 = mem->Get(address++);
        output.Format(_T("%.2hX      %s ($%.2hX, X)"),
                      b1, pInstr->mnemonic, b1);
        break;
    case INDY:
        address++;
        b1 = mem->Get(address++);
        output.Format(_T("%.2hX      %s ($%.2hX), Y"),
                      b1, pInstr->mnemonic, b1);
        break;
    case ZPAGEX:
        address++;
        b1 = mem->Get(address++);
        output.Format(_T("%.2hX      %s $%.2hX, X"),
                      b1, pInstr->mnemonic, b1);
        break;
    case ABSX:
        address++;
        b1 = mem->Get(address++);
        b2 = mem->Get(address++);
        output.Format(_T("%.2hX %.2hX   %s $%.4hX, X"),
                      b1, b2, pInstr->mnemonic, MAKEWORD(b1, b2));
        break;
    case ABSY:
        address++;
        b1 = mem->Get(address++);
        b2 = mem->Get(address++);
        output.Format(_T("%.2hX %.2hX   %s $%.4hX, Y"),
                      b1, b2, pInstr->mnemonic, MAKEWORD(b1, b2));
        break;
    case IND:
        address++;
        b1 = mem->Get(address++);
        b2 = mem->Get(address++);
        output.Format(_T("%.2hX %.2hX   %s ($%.4hX)"),
                      b1, b2, pInstr->mnemonic, MAKEWORD(b1, b2));
        break;
    case ZPAGEY:
        address++;
        b1 = mem->Get(address++);
        output.Format(_T("%.2hX      %s $%.2hX, Y"),
                      b1, pInstr->mnemonic, b1);
        break;
    case _RELATIVE:
        address++;
        b1 = mem->Get(address++);
        output.Format(_T("%.2hX      %s $%.2hX"),
                      b1, pInstr->mnemonic, b1);
        break;
    };

    return output;
}