CPU::Z80::Assembler::Program - Represents one assembly program
use CPU::Z80::Assembler::Program; my $program = CPU::Z80::Assembler::Program->new( symbols => {}, macros => {}); $program->parse($input); $segment = $program->segment; $segment = $program->segment("CODE"); $segment = $program->split_segment; $program->add_opcodes(@opcodes); $program->add_label($name, $line); $program->org($address); $bytes = $program->bytes; $list_output = CPU::Z80::Assembler::List->new(input => \@input, output => \*STDOUT); $bytes = $program->bytes($list_output);
This module defines the class that represents one assembly program composed of CPU::Z80::Assembler::Segment.
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 of macro names to CPU::Z80::Assembler::Macro objects for all defined macros.
$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 z80lexer.
z80lexer
Get/Set the current segment. The current segment is the one where new opcodes are added.
When called without arguments returns a CPU::Z80::Assembler::Segment object of the current segment.
When called with a $name, it sets the segment with the given name as current. If no such segment exists, a new segment with that name is appended to the list and set current.
Splits the current segment at the current position, creating a new segment, inserting it just after the current one and setting it as current.
Returns the new current segment.
As a special case, if the current is empty, then nothing is done.
This is used to split one segment in two after a second ORG statement.
Adds the opcodes to the current segment.
Add a new label at the current position with given name and line. The line is used for error messages and assembly listing.
It is an error to add a label twice with the same name.
Splits the current segment with split_segment() and sets the start address of the new current segment.
Allocate addresses for all child segments, starting at the first segment's address (defined by a "org" instruction), or at 0.
address
Computes the bytes of each segment, and concatenates them together. Returns the complete object code.
Gaps between segments are filled with $CPU::Z80::Assembler::fill_byte.
$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.