niobium/fhetch_writer.h

Include: #include "niobium/fhetch_writer.h"

Text

niobium::fhetch::render_instruction

void render_instruction(const Instruction &inst, std::string &out)

Append one instruction's line to out, without the newline.

Appending rather than returning is what lets a caller stream a program through a single reused buffer instead of allocating per instruction.

niobium::fhetch::render_instruction

std::string render_instruction(const Instruction &inst)

Convenience form. Prefer the appending overload in a loop.

niobium::fhetch::render_header

std::string render_header(const TraceMetadata &metadata, size_t instruction_count, size_t modulus_count)

The leading # comment block, newline-terminated. instruction_count and modulus_count are passed rather than read from metadata because they describe what is actually being written, which is the authority — a metadata block carried over from an earlier program may disagree.

niobium::fhetch::render_modulus_table

std::string render_modulus_table(const std::vector<uint64_t> &table)

The modulus_count line and the m[i] 0xHEX entries, newline-terminated.

niobium::fhetch::write_fhetch_text

bool write_fhetch_text(const std::filesystem::path &path, const Program &program)

Write a whole program as .fhetch. Returns false if the file could not be opened; nothing is partially written in that case.

Binary

niobium::fhetch::write_fhetch_binary

bool write_fhetch_binary(const std::filesystem::path &path, const Program &program, FhetchSpec spec=kFhetchSpec)

Write a whole program as .fhex, beside or instead of the text.

Something not looking right? Suggest a change on GitHub.