Commit b37eff0a authored by Connor Abbott's avatar Connor Abbott

split out disassembly into separate file

parent f4b5b993
project(Disassembler) project(Disassembler)
set(SRCS Main.cpp) set(SRCS Main.cpp Disasm.cpp)
add_executable(disasm ${SRCS}) add_executable(disasm ${SRCS})
#include "Disasm.h"
#include <stdio.h>
void DumpInstructions(unsigned indent, uint8_t* instBlob, uint32_t size)
{
uint8_t* instEnd = instBlob + size;
while (instBlob != instEnd)
{
uint32_t *words = (uint32_t*) instBlob;
uint8_t tag = words[0] & 0xff;
if (tag & 0b00001000)
printf("{\n");
printf("# ");
for (int i = 0; i < 4; i++)
printf("%08x ", words[3 - i]); // low bit on the right
printf("\n");
if (tag & 0b01000000)
printf("}\n");
instBlob += 16;
}
}
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include "BlockInfo.h" #include "BlockInfo.h"
#include "Disasm.h"
bool ReadFile(std::vector<uint8_t> *fileData, std::string filename) bool ReadFile(std::vector<uint8_t> *fileData, std::string filename)
{ {
...@@ -66,25 +67,6 @@ void iprintf(unsigned indent, const char *format, ...) ...@@ -66,25 +67,6 @@ void iprintf(unsigned indent, const char *format, ...)
va_end(args); va_end(args);
} }
void DumpInstructions(unsigned indent, uint8_t* instBlob, uint32_t size)
{
uint8_t* instEnd = instBlob + size;
while (instBlob != instEnd)
{
uint32_t *words = (uint32_t*) instBlob;
uint8_t tag = words[0] & 0xff;
if (tag & 0b00001000)
printf("{\n");
printf("# ");
for (int i = 0; i < 4; i++)
printf("%08x ", words[3 - i]); // low bit on the right
printf("\n");
if (tag & 0b01000000)
printf("}\n");
instBlob += 16;
}
}
bool PrintBlocks(unsigned indent, uint8_t *data, size_t size); bool PrintBlocks(unsigned indent, uint8_t *data, size_t size);
bool PrintBlock(unsigned indent, uint8_t **data); bool PrintBlock(unsigned indent, uint8_t **data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment