about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornc <nc@charliethe.ninja>2019-04-18 21:51:18 -0400
committernc <nc@charliethe.ninja>2019-04-18 21:51:18 -0400
commit8aeecaf1be74f6e11f193ee129c8b1be41fd8ef3 (patch)
treeb87780ee5005e2479fd0b2fd0d1d2bcb41b70a3d
parent6ae6d3b4977f498c83da76382496ebb5792c07fe (diff)
downloadmu-8aeecaf1be74f6e11f193ee129c8b1be41fd8ef3.tar.gz
Add functionality to support labels as imm32 arguments to opcodes
-rw-r--r--subx/035labels.cc13
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(