From 8aeecaf1be74f6e11f193ee129c8b1be41fd8ef3 Mon Sep 17 00:00:00 2001 From: nc Date: Thu, 18 Apr 2019 21:51:18 -0400 Subject: Add functionality to support labels as imm32 arguments to opcodes --- subx/035labels.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'subx') 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 } 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( -- cgit 1.4.1-2-gfad0