Skip to content

Commit

Permalink
listing
Browse files Browse the repository at this point in the history
  • Loading branch information
ogamespec committed Sep 15, 2023
1 parent 726d27c commit 92c442a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 15 additions & 2 deletions Tools/Breakasm/asm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,18 +593,19 @@ static void assemble_text(char* text)
{
oplink* opl;
line l;
int listing = 0;

while (1) {
if (*text == 0) break;
parse_line(&text, l);

//printf ( "%s: \'%s\' \'%s\'\n", l.label, l.cmd, l.op );

// Add label
if (strlen(l.label) > 1) {
add_label(l.label, org);
}

long org_before = org;

// Execute command
if (strlen(l.cmd) > 1) {
opl = optab;
Expand All @@ -622,6 +623,18 @@ static void assemble_text(char* text)
}
if (stop) break;
}

// Listing
if (listing) {
printf("0x%08X: ", org_before);
int num_bytes = org - org_before;
for (int i = 0; i < num_bytes; i++) {
printf("%02X ", PRG[org_before + i]);
}
printf("%s: \'%s\' \'%s\'\n", l.label, l.cmd, l.op);
printf("\n");
}

nextline();
}
}
Expand Down
6 changes: 4 additions & 2 deletions Tools/Breakasm/asmexpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ static node_t * evaluate (std::list<node_t*>& tree, node_t * expr, long *lvalue,
}
else {
label_s* label = label_lookup(token->string);
if (label) {
if (label && label->orig != UNDEF) {
mvalue = label->orig;
}
else {
Expand Down Expand Up @@ -583,7 +583,9 @@ long eval_expr(char* text, bool debug, bool quiet)
// Execute the tree

long result = 0;
evaluate(tree.nodes, root->rvalue->rvalue, &result, quiet);
if (root) {
evaluate(tree.nodes, root->rvalue->rvalue, &result, quiet);
}

if (debug)
printf("Source expression: %s, result: %d (0x%08X)\n", text, result, result);
Expand Down

0 comments on commit 92c442a

Please sign in to comment.