CPU::Z80::Assembler::Program - Represents one assembly program
use CPU::Z80::Assembler::Program; my $program = CPU::Z80::Assembler::Program->new( symbols => {}); $program->parse($input); $program->link; my $bytes = $program->bytes;
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.
Nothing.
Creates a new object, see Class::Struct.
Each child is one CPU::Z80::Assembler::Segment object, in the order found in the program.
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.
Hash to map segment names to the segment objects in the child array.
Hash of macro names to CPU::Z80::Assembler::Macro objects for all defined macros.
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.
cur_segment
$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.
z80lexer
$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.
$program->add(@opcodes);
Adds the opcodes to the current segment.
$program->link;
Resolve all labels and build object code.
$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.
See CPU::Z80::Assembler.
CPU::Z80::Assembler CPU::Z80::Assembler::Segment CPU::Z80::Assembler::Parser Class::Struct
To install CPU::Z80::Assembler, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CPU::Z80::Assembler
CPAN shell
perl -MCPAN -e shell install CPU::Z80::Assembler
For more information on module installation, please visit the detailed CPAN module installation guide.