Skip to content

Commit

Permalink
Merge pull request #5 from danoost/master
Browse files Browse the repository at this point in the history
wobj accepts arguments in any order, and shows printable characters beside .word directives
  • Loading branch information
gizmoguy committed Jun 6, 2019
2 parents 4be1fc6 + 435dec6 commit 87a230a
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions objectViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,46 +192,38 @@ int main(int argc, char *argv[])
int i;
bool display_object = true;
bool display_dissasemble = false;

char output_filename[300] = {0};

if (argc < 2)
usage(argv[0]);

// Here we must parse the arguments
char *input_filename = NULL;

for (i = 2; i < argc; i++)
for (i = 1; i < argc; i++)
{
///cout << "testing : " << argv[i] << endl;
// Is this an option
if (argv[i][0] == '-')
{
// This is the only valid option for now
// This is the only valid option
if (strcmp(argv[i], "-d") == 0)
{
display_dissasemble = true;
//i++;
}
else
usage(argv[0]);
}
else
{
usage(argv[0]);
// Otherwise it is a filename
if (argv[i] == NULL)
{
usage(argv[0]);
}
input_filename = argv[i];
}
}

// Otherwise it is a filename
input_filename = argv[1];


if (output_filename[0] == '\0')
{
// default to link.out
strcpy(output_filename, "link.out");
}

file_type file;

// Read in the data from all the files
Expand Down Expand Up @@ -489,7 +481,17 @@ int main(int argc, char *argv[])
}
currLabel = currLabel->next;
}
cout << "\t.word\t0x" << setw(8) << setfill('0') << hex << file.segment[DATA][i] << endl;

// If the .word contains a value in the printable character range,
// add a comment that shows the character.
if (file.segment[DATA][i] >= 20 && file.segment[DATA][i] < 127)
{
cout << "\t.word\t0x" << setw(8) << setfill('0') << hex << file.segment[DATA][i] << "\t# '" << (char)file.segment[DATA][i] << "'" << endl;
}
else
{
cout << "\t.word\t0x" << setw(8) << setfill('0') << hex << file.segment[DATA][i] << endl;
}
}

cout << endl << ".bss # size: 0x" << setw(5) << setfill('0') << hex << file.file_header.bss_seg_size << endl;
Expand Down

0 comments on commit 87a230a

Please sign in to comment.