The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CPU::Z80::Disassembler::Memory - Memory representation for Z80 disassembler

SYNOPSIS

  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);

DESCRIPTION

This module represents a memory segment being diassembled.

FUNCTIONS

new

Creates a new empty object.

load_file

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.

loaded_iter

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.

peek, peek8u

Retrieves the byte (0 .. 255) from the given address. Returns undef if the memory at that address was not loaded.

peek8s

Same as peek8u, but treats byte as signed (-128 .. 127).

peek16u

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.

peek16s

Same as peek16u, but treats word as signed (-32768 .. 32767).

peek_str

Retrieves a string from the given address with the given length. Returns undef if the memory at any of the addresses was not loaded.

peek_strz

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.

peek_str7

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.

poke, poke8u

Stores the unsigned byte (0 .. 255) at the given address, and signals that the address was loaded.

poke8s

Same as poke8u, but treats byte as signed (-128 .. 127).

poke16u

Stores the two-byte word (0 .. 65535) at the given address, least significant first (little-endian), and signals that the address was loaded.

poke16s

Same as poke16u, but treats word as signed (-32768 .. 32767).

poke_str

Stores the string at the given start address, and signals that the addresser were loaded.

poke_strz

Stores the string at the given start address, and adds a zero byte, and signals that the addresses were loaded.

poke_str7

Stores the string at the given start address and sets the bit 7 of the last character, and signals that the addresses were loaded.

AUTHOR, BUGS, FEEDBACK, LICENSE AND COPYRIGHT

See CPU::Z80::Disassembler.