⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dasmtest.cpp

📁 一个任天堂掌上游戏机NDS的源代码
💻 CPP
字号:
/**************************************************************************
* DSemu - The Next Generation                                             *
* Portable ARM cores: Disassembly tester [dasmtest.cpp]                   *
* Copyright Imran Nazar, 2005; released under the BSD public licence.     *
**************************************************************************/

#include <fstream>
#include "armdasm.h"
#include "datadefs.h"
#include "byteswap.h"
#include "sysdep.h"

u8 *buf; u32 *bufw;

// Function the disasm will use to read the ROM buffer
u32 rdW(u32 addr) { return bufw[addr>>2]; }

// Input: A binary file on the command line
// Output: A disassembly, starting at R15=0, to stdout
int main(int argc, char *argv[])
{
    if(argc != 2)
    {
	printf("Usage: dasmtest <ROM to disasm>\n");
	return 0;
    }
    
    std::ifstream input(argv[1], std::ios::binary);
    if(!input.is_open())
    {
	printf("Failed opening %s.\n", argv[1]);
	return 1;
    }
    
    int size;
    ARMDasm dasm(rdW);

    input.seekg(0, std::ios::end);
    size = input.tellg();
    input.seekg(0, std::ios::beg);

    buf = new u8[size];
    bufw = (u32*)buf;

    input.read((char*)buf, size);
    input.close();

    for(int i=0; i<(size>>2); i++)
    {
        printf("%08X | %08X | ", i*4, bufw[i], mtohl(bufw[i]));
        printf("%s\n",dasm.disasm(mtohl(bufw[i]),i*4).c_str());
    }

    delete buf; buf=NULL;
    return 0;
}

/*** EOF: dasmtest.cpp ***************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -