Modern C++ wrapper for Asar 65816 assembler integration. More...
#include <asar_wrapper.h>
Public Member Functions | |
AsarWrapper () | |
~AsarWrapper () | |
AsarWrapper (const AsarWrapper &)=delete | |
AsarWrapper & | operator= (const AsarWrapper &)=delete |
AsarWrapper (AsarWrapper &&)=default | |
AsarWrapper & | operator= (AsarWrapper &&)=default |
absl::Status | Initialize () |
Initialize the Asar library. | |
void | Shutdown () |
Clean up and close the Asar library. | |
bool | IsInitialized () const |
Check if Asar is initialized and ready. | |
std::string | GetVersion () const |
Get Asar version information. | |
int | GetApiVersion () const |
Get Asar API version. | |
absl::StatusOr< AsarPatchResult > | ApplyPatch (const std::string &patch_path, std::vector< uint8_t > &rom_data, const std::vector< std::string > &include_paths={}) |
Apply an assembly patch to a ROM. | |
absl::StatusOr< AsarPatchResult > | ApplyPatchFromString (const std::string &patch_content, std::vector< uint8_t > &rom_data, const std::string &base_path="") |
Apply an assembly patch from string content. | |
absl::StatusOr< std::vector< AsarSymbol > > | ExtractSymbols (const std::string &asm_path, const std::vector< std::string > &include_paths={}) |
Extract symbols from an assembly file without patching. | |
std::map< std::string, AsarSymbol > | GetSymbolTable () const |
Get all available symbols from the last patch operation. | |
std::optional< AsarSymbol > | FindSymbol (const std::string &name) const |
Find a symbol by name. | |
std::vector< AsarSymbol > | GetSymbolsAtAddress (uint32_t address) const |
Get symbols at a specific address. | |
void | Reset () |
Reset the Asar state (clear errors, warnings, symbols) | |
std::vector< std::string > | GetLastErrors () const |
Get the last error messages. | |
std::vector< std::string > | GetLastWarnings () const |
Get the last warning messages. | |
absl::Status | CreatePatch (const std::vector< uint8_t > &original_rom, const std::vector< uint8_t > &modified_rom, const std::string &patch_path) |
Create a patch that can be applied to transform one ROM to another. | |
absl::Status | ValidateAssembly (const std::string &asm_path) |
Validate an assembly file for syntax errors. | |
Private Member Functions | |
void | ProcessErrors () |
Process errors from Asar and store them. | |
void | ProcessWarnings () |
Process warnings from Asar and store them. | |
void | ExtractSymbolsFromLastOperation () |
Extract symbols from the last Asar operation. | |
AsarSymbol | ConvertAsarSymbol (const void *asar_symbol_data) const |
Convert Asar symbol data to AsarSymbol struct. | |
Private Attributes | |
bool | initialized_ |
std::map< std::string, AsarSymbol > | symbol_table_ |
std::vector< std::string > | last_errors_ |
std::vector< std::string > | last_warnings_ |
Modern C++ wrapper for Asar 65816 assembler integration.
This class provides a high-level interface for:
Definition at line 48 of file asar_wrapper.h.
yaze::core::AsarWrapper::AsarWrapper | ( | ) |
Definition at line 17 of file asar_wrapper.cc.
yaze::core::AsarWrapper::~AsarWrapper | ( | ) |
Definition at line 19 of file asar_wrapper.cc.
References initialized_, and Shutdown().
|
delete |
|
default |
|
delete |
|
default |
absl::Status yaze::core::AsarWrapper::Initialize | ( | ) |
Initialize the Asar library.
Definition at line 25 of file asar_wrapper.cc.
References initialized_.
void yaze::core::AsarWrapper::Shutdown | ( | ) |
Clean up and close the Asar library.
Definition at line 41 of file asar_wrapper.cc.
References initialized_.
Referenced by ~AsarWrapper().
|
inline |
Check if Asar is initialized and ready.
Definition at line 76 of file asar_wrapper.h.
References initialized_.
std::string yaze::core::AsarWrapper::GetVersion | ( | ) | const |
Get Asar version information.
Definition at line 48 of file asar_wrapper.cc.
References initialized_.
int yaze::core::AsarWrapper::GetApiVersion | ( | ) | const |
Get Asar API version.
Definition at line 61 of file asar_wrapper.cc.
References initialized_.
absl::StatusOr< AsarPatchResult > yaze::core::AsarWrapper::ApplyPatch | ( | const std::string & | patch_path, |
std::vector< uint8_t > & | rom_data, | ||
const std::vector< std::string > & | include_paths = {} |
||
) |
Apply an assembly patch to a ROM.
patch_path | Path to the .asm patch file |
rom_data | ROM data to patch (will be modified) |
include_paths | Additional include paths for assembly files |
Definition at line 68 of file asar_wrapper.cc.
References yaze::core::AsarPatchResult::crc32, yaze::core::AsarPatchResult::errors, ExtractSymbolsFromLastOperation(), initialized_, last_errors_, last_warnings_, ProcessErrors(), ProcessWarnings(), Reset(), yaze::core::AsarPatchResult::rom_size, yaze::core::AsarPatchResult::success, symbol_table_, yaze::core::AsarPatchResult::symbols, and yaze::core::AsarPatchResult::warnings.
Referenced by ApplyPatchFromString(), ExtractSymbols(), and ValidateAssembly().
absl::StatusOr< AsarPatchResult > yaze::core::AsarWrapper::ApplyPatchFromString | ( | const std::string & | patch_content, |
std::vector< uint8_t > & | rom_data, | ||
const std::string & | base_path = "" |
||
) |
Apply an assembly patch from string content.
patch_content | Assembly source code as string |
rom_data | ROM data to patch (will be modified) |
base_path | Base path for resolving includes |
Definition at line 130 of file asar_wrapper.cc.
References ApplyPatch().
absl::StatusOr< std::vector< AsarSymbol > > yaze::core::AsarWrapper::ExtractSymbols | ( | const std::string & | asm_path, |
const std::vector< std::string > & | include_paths = {} |
||
) |
Extract symbols from an assembly file without patching.
asm_path | Path to the assembly file |
include_paths | Additional include paths |
Definition at line 160 of file asar_wrapper.cc.
References ApplyPatch(), and initialized_.
std::map< std::string, AsarSymbol > yaze::core::AsarWrapper::GetSymbolTable | ( | ) | const |
Get all available symbols from the last patch operation.
Definition at line 179 of file asar_wrapper.cc.
References symbol_table_.
std::optional< AsarSymbol > yaze::core::AsarWrapper::FindSymbol | ( | const std::string & | name | ) | const |
Find a symbol by name.
name | Symbol name to search for |
Definition at line 183 of file asar_wrapper.cc.
References symbol_table_.
std::vector< AsarSymbol > yaze::core::AsarWrapper::GetSymbolsAtAddress | ( | uint32_t | address | ) | const |
Get symbols at a specific address.
address | Memory address to search |
Definition at line 191 of file asar_wrapper.cc.
References symbol_table_.
void yaze::core::AsarWrapper::Reset | ( | ) |
Reset the Asar state (clear errors, warnings, symbols)
Definition at line 201 of file asar_wrapper.cc.
References initialized_, last_errors_, last_warnings_, and symbol_table_.
Referenced by ApplyPatch().
|
inline |
Get the last error messages.
Definition at line 153 of file asar_wrapper.h.
References last_errors_.
|
inline |
Get the last warning messages.
Definition at line 159 of file asar_wrapper.h.
References last_warnings_.
absl::Status yaze::core::AsarWrapper::CreatePatch | ( | const std::vector< uint8_t > & | original_rom, |
const std::vector< uint8_t > & | modified_rom, | ||
const std::string & | patch_path | ||
) |
Create a patch that can be applied to transform one ROM to another.
original_rom | Original ROM data |
modified_rom | Modified ROM data |
patch_path | Output path for the generated patch |
Definition at line 210 of file asar_wrapper.cc.
absl::Status yaze::core::AsarWrapper::ValidateAssembly | ( | const std::string & | asm_path | ) |
Validate an assembly file for syntax errors.
asm_path | Path to the assembly file |
Definition at line 225 of file asar_wrapper.cc.
References ApplyPatch().
|
private |
Process errors from Asar and store them.
Definition at line 243 of file asar_wrapper.cc.
References last_errors_.
Referenced by ApplyPatch().
|
private |
Process warnings from Asar and store them.
Definition at line 254 of file asar_wrapper.cc.
References last_warnings_.
Referenced by ApplyPatch().
|
private |
Extract symbols from the last Asar operation.
Definition at line 265 of file asar_wrapper.cc.
References yaze::core::AsarSymbol::address, yaze::core::AsarSymbol::comment, yaze::core::AsarSymbol::file, yaze::core::AsarSymbol::line, yaze::core::AsarSymbol::name, yaze::core::AsarSymbol::opcode, and symbol_table_.
Referenced by ApplyPatch().
|
private |
Convert Asar symbol data to AsarSymbol struct.
Definition at line 285 of file asar_wrapper.cc.
|
private |
Definition at line 181 of file asar_wrapper.h.
Referenced by ApplyPatch(), ExtractSymbols(), GetApiVersion(), GetVersion(), Initialize(), IsInitialized(), Reset(), Shutdown(), and ~AsarWrapper().
|
private |
Definition at line 182 of file asar_wrapper.h.
Referenced by ApplyPatch(), ExtractSymbolsFromLastOperation(), FindSymbol(), GetSymbolsAtAddress(), GetSymbolTable(), and Reset().
|
private |
Definition at line 183 of file asar_wrapper.h.
Referenced by ApplyPatch(), GetLastErrors(), ProcessErrors(), and Reset().
|
private |
Definition at line 184 of file asar_wrapper.h.
Referenced by ApplyPatch(), GetLastWarnings(), ProcessWarnings(), and Reset().