NAME
CPU::Z80::Assembler::Program - Represents one assembly program
SYNOPSIS
use CPU::Z80::Assembler::Program;
my $program = CPU::Z80::Assembler::Program->new(
symbols => {});
$program->parse($input);
$program->link;
my $bytes = $program->bytes;
DESCRIPTION
This module defines the class that represents one assembly program composed of CPU::Z80::Assembler::Segment.
This class extends the class CPU::Z80::Assembler::Node.
EXPORTS
Nothing.
FUNCTIONS
new
Creates a new object, see Class::Struct.
child
Each child is one CPU::Z80::Assembler::Segment object, in the order found in the program.
symbols
Hash of all symbols defined in the program. The key is the symbol name, and the value is either a scalar for a constant, a CPU::Z80::Assembler::Expr for an expression, or a CPU::Z80::Assembler::Opcode for a label.
segment_map
Hash to map segment names to the segment objects in the child array.
macros
Hash of macro names to CPU::Z80::Assembler::Macro objects for all defined macros.
cur_segment
my $segment = $program->cur_segment();
my $segment = $program->cur_segment($segment_name);
Get/Set the current segment with the given name.
The cur_segment
is changed to point to the segment with the given name. If it does not exist, it is created and added to the child array.
parse
$program->parse($input);
Parse the assembly program and collect the opcodes into the object. $input is a stream of tokens as retrieved by CPU::Z80::Assembler::Lexer z80lexer
.
org
$program->org($address, $token);
Changes the start address of the current segment. It is a fatal error to try to change the address after some opcodes have been compiled.
$token is the location of the ORG instruction used for error messages.
add
$program->add(@opcodes);
Adds the opcodes to the current segment.
link
$program->link;
Resolve all labels and build object code.
bytes
$bytes = $program->bytes($list_output);
Computes the bytes of each segment, and concatenates them together. Returns the complete object code.
$list_output is an optional CPU::Z80::Assembler::List object to dump the assembly listing to.
BUGS and FEEDBACK
See CPU::Z80::Assembler.
SEE ALSO
CPU::Z80::Assembler CPU::Z80::Assembler::Segment CPU::Z80::Assembler::Parser Class::Struct
AUTHORS, COPYRIGHT and LICENCE
See CPU::Z80::Assembler.