Prepend address to disassembler output to enable easier debugging

This commit is contained in:
Jeremiah Orians 2017-06-16 14:33:46 -04:00
parent 9e2d807553
commit 2af3d78744
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
1 changed files with 4 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include <string.h>
FILE* binary_file;
int32_t address;
/* Unpacked instruction */
struct Instruction
@ -1344,6 +1345,7 @@ void decode_HALCODE(struct Instruction* c)
void eval_instruction(struct Instruction* c)
{
fprintf(stdout,"%08X\t", address);
switch(c->raw0)
{
case 0x01: /* Integer 4OP */
@ -1414,6 +1416,7 @@ int main(int argc, char **argv)
binary_file = fopen(argv[1], "r");
struct Instruction* current;
current = calloc(1, sizeof(struct Instruction));
address = 0;
int32_t byte;
byte = fgetc(binary_file);
@ -1423,6 +1426,7 @@ int main(int argc, char **argv)
{
read_instruction(current);
eval_instruction(current);
address = address + 4;
byte = fgetc(binary_file);
ungetc(byte, binary_file);
}