CPU::Z80::Disassembler::Memory - Memory representation for Z80 disassembler
use CPU::Z80::Disassembler::Memory; $mem = CPU::Z80::Disassembler::Memory->new; $mem->load_file($file_name, $addr, $opt_skip_bytes, $opt_length); $it = $mem->loaded_iter(); while (($min,$max) = $it->()) {} $byte = $mem->peek8u($addr); $byte = $mem->peek($addr); $byte = $mem->peek8s($addr); $word = $mem->peek16u($addr); $word = $mem->peek16s($addr); $str = $mem->peek_str( $addr, $length); $str = $mem->peek_strz($addr); $str = $mem->peek_str7($addr); $mem->poke8u($addr, $byte); $mem->poke($addr, $byte); $mem->poke8s($addr, $byte); $mem->poke16u($addr, $word); $mem->poke16s($addr, $word); $mem->poke_str( $addr, $str); $mem->poke_strz($addr, $str); $mem->poke_str7($addr, $str);
This module represents a memory segment being diassembled.
Creates a new empty object.
Loads a binary file to the memory. The argument $addr
indicates where in the memory to load the file, and defaults to 0. The argument $opt_skip_bytes
indicates how many bytes to skip from the start of the binary file and defaults to 0. This is useful to read .SNA
ZX Spectrum Snapshot Files which have a header of 27 bytes. The argument $opt_length
limits the number of bytes to read to memory and defaults to all the file after the header.
Returns an iterator to return each block of consecutive loaded addresses. $min
is the first address of the consecutive block, $max
is last address of the block.
Retrieves the byte (0 .. 255) from the given address. Returns undef
if the memory at that address was not loaded.
Same as peek8u
, but treats byte as signed (-128 .. 127).
Retrieves the two-byte word (0 .. 65535) from the given address, least significant first (little-endian). Returns undef
if the memory at any of the two addresses was not loaded.
Same as peek16u
, but treats word as signed (-32768 .. 32767).
Retrieves a string from the given address with the given length. Returns undef
if the memory at any of the addresses was not loaded.
Retrieves a zero-terminated string from the given address. The returned string does not include the final zero byte. Returns undef
if the memory at any of the addresses was not loaded.
Retrieves a bit-7-set-terminated string from the given address. This string has all characters with bit 7 reset, execept the last character, where bit 7 is set. The returned string has bit 7 reset in all characters. Returns undef
if the memory at any of the addresses was not loaded.
Stores the unsigned byte (0 .. 255) at the given address, and signals that the address was loaded.
Same as poke8u
, but treats byte as signed (-128 .. 127).
Stores the two-byte word (0 .. 65535) at the given address, least significant first (little-endian), and signals that the address was loaded.
Same as poke16u
, but treats word as signed (-32768 .. 32767).
Stores the string at the given start address, and signals that the addresser were loaded.
Stores the string at the given start address, and adds a zero byte, and signals that the addresses were loaded.
Stores the string at the given start address and sets the bit 7 of the last character, and signals that the addresses were loaded.