diff options
author | Kartik Agaram <github@akkartik.com> | 2019-04-18 21:03:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-18 21:03:07 -0700 |
commit | c1bde77095f53c237765f15c23d27f0b7a691d92 (patch) | |
tree | b87780ee5005e2479fd0b2fd0d1d2bcb41b70a3d /subx | |
parent | 6ae6d3b4977f498c83da76382496ebb5792c07fe (diff) | |
parent | 8aeecaf1be74f6e11f193ee129c8b1be41fd8ef3 (diff) | |
download | mu-c1bde77095f53c237765f15c23d27f0b7a691d92.tar.gz |
Merge pull request #19 from akkartik/label-imm32-arg
Add functionality to support labels as imm32 arguments to opcodes
Diffstat (limited to 'subx')
-rw-r--r-- | subx/035labels.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/subx/035labels.cc b/subx/035labels.cc index 575bcec2..2d1c752e 100644 --- a/subx/035labels.cc +++ b/subx/035labels.cc @@ -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 { @@ -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( |