Skip to content

Commit

Permalink
Merge pull request #19 from akkartik/label-imm32-arg
Browse files Browse the repository at this point in the history
Add functionality to support labels as imm32 arguments to opcodes
  • Loading branch information
akkartik committed Apr 19, 2019
2 parents 6ae6d3b + 8aeecaf commit c1bde77
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions subx/035labels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ void replace_labels_with_displacements(segment& code, const map<string, int32_t>
}
else if (has_operand_metadata(curr, "disp32")) {
emit_hex_bytes(new_inst, displacement, 4);
} else if (has_operand_metadata(curr, "imm32")) {
emit_hex_bytes(new_inst, code.start + get(byte_index, curr.data), 4);
}
}
else {
Expand Down Expand Up @@ -291,6 +293,17 @@ void test_multiple_labels_at() {
);
}

void test_loading_label_as_imm32() {
transform(
"== 0x1\n"
"label:\n"
"be/copy-to-ESI label/imm32");
CHECK_TRACE_CONTENTS(
"transform: label 'label' is at address 1\n"
"transform: instruction after transform: 'be 01 00 00 00'\n"
);
}

void test_duplicate_label() {
Hide_errors = true;
transform(
Expand Down

0 comments on commit c1bde77

Please sign in to comment.