Skip to content

Commit 0c5d3a8

Browse files
allow use of labels in x86 .address and .data directives
1 parent 7b9597f commit 0c5d3a8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/Emulators/X86Emulator.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4822,14 +4822,22 @@ X86Emulator::AssembleResult X86Emulator::Assembler::assemble(const string& text,
48224822
}
48234823
si.op_name.clear();
48244824
} else if (si.op_name == ".address") {
4825-
si.fixed_address = stoul(line, nullptr, 16);
4825+
try {
4826+
si.fixed_address = this->fixed_labels.at(line);
4827+
} catch (const out_of_range&) {
4828+
si.fixed_address = stoul(line, nullptr, 16);
4829+
}
48264830
si.op_name.clear();
48274831
} else if (si.op_name == ".binary") {
48284832
si.assembled_data = parse_data_string(line);
48294833
si.op_name.clear();
48304834
} else if (si.op_name == ".data") {
48314835
StringWriter w;
4832-
w.put_u32l(stoul(line, nullptr, 0));
4836+
try {
4837+
w.put_u32l(this->fixed_labels.at(line));
4838+
} catch (const out_of_range&) {
4839+
w.put_u32l(stoul(line, nullptr, 0));
4840+
}
48334841
si.assembled_data = std::move(w.str());
48344842
si.op_name.clear();
48354843
} else if (si.op_name == ".include") {

0 commit comments

Comments
 (0)