diff --git a/zasm/include/zasm/program/program.hpp b/zasm/include/zasm/program/program.hpp
index e9c4931..6710437 100644
--- a/zasm/include/zasm/program/program.hpp
+++ b/zasm/include/zasm/program/program.hpp
@@ -263,6 +263,20 @@ namespace zasm
/// Node for which the label is bound to or null if the label is invalid or not bound
Node* getNodeForLabel(const Label& label);
+ ///
+ /// Returns the current assigned label name, returns nullptr if the label is invalid or has no name.
+ ///
+ /// Label
+ /// Label name or nullptr
+ const char* getLabelName(const Label& label) const noexcept;
+
+ ///
+ /// Assigns a name to a label.
+ ///
+ /// Label
+ /// The new name, pasing nullptr will clear the name, the string will be copied
+ void setLabelName(const Label& label, const char* name);
+
public:
///
/// Creates a new section that can be used to segment code and data.
diff --git a/zasm/src/zasm/src/program/program.cpp b/zasm/src/zasm/src/program/program.cpp
index 031cec9..ddcb651 100644
--- a/zasm/src/zasm/src/program/program.cpp
+++ b/zasm/src/zasm/src/program/program.cpp
@@ -110,6 +110,54 @@ namespace zasm
return entry.node;
}
+ const char* Program::getLabelName(const Label& label) const noexcept
+ {
+ if (!label.isValid())
+ {
+ return nullptr;
+ }
+
+ const auto entryIdx = static_cast(label.getId());
+ if (entryIdx >= _state->labels.size())
+ {
+ return nullptr;
+ }
+
+ auto& entry = _state->labels[entryIdx];
+ if (entry.nameId != StringPool::Id::Invalid)
+ {
+ return _state->symbolNames.get(entry.nameId);
+ }
+
+ return nullptr;
+ }
+
+ void Program::setLabelName(const Label& label, const char* name)
+ {
+ if (!label.isValid())
+ {
+ return;
+ }
+
+ const auto entryIdx = static_cast(label.getId());
+ if (entryIdx >= _state->labels.size())
+ {
+ return;
+ }
+
+ auto& entry = _state->labels[entryIdx];
+ if (entry.nameId != StringPool::Id::Invalid)
+ {
+ _state->symbolNames.release(entry.nameId);
+ entry.nameId = StringPool::Id::Invalid;
+ }
+
+ if (name != nullptr)
+ {
+ entry.nameId = _state->symbolNames.aquire(name);
+ }
+ }
+
Node* Program::getNodeForSection(const Section& section)
{
if (!section.isValid())