| CPU-Z80-Assembler documentation | Contained in the CPU-Z80-Assembler distribution. |
CPU::Z80::Assembler::JumpOpcode - Represents one jump assembly instruction to be computed at link time
use CPU::Z80::Assembler::JumpOpcode;
$opcode = CPU::Z80::Assembler::Opcode->new(
short_jump => CPU::Z80::Assemble::Opcode->new( ... JR instr ...),
long_jump => CPU::Z80::Assemble::Opcode->new( ... JP instr ...));
$opcode->address;
$opcode->line;
$dist = short_jump_dist($address, \%symbol_table);
$bytes = $opcode->bytes($address, \%symbol_table);
$size = $opcode->size;
This module defines the class that represents one jump instruction to be added to the object code. The object contains both the short jump form and the long jump form.
During address allocation all short jumps that are out of range are replaced by long jumps.
Nothing.
Creates a new object.
Address where this opcode is loaded, computed at link time.
Returns the CPU::Z80::Assembler::Opcode object representing the short jump.
Returns the CPU::Z80::Assembler::Opcode object representing the long jump.
Get/set the line - text, file name and line number where the token was read.
Gets the short jump distance, in relation to the address of the next instruction.
Returns more than 127 or less than -128 if the short jump is out of range.
$bytes = $opcode->bytes($address, \%symbol_table);
Computes all the expressions in the short jump and returns the bytes string with the result object code.
$size = $opcode->size;
Return the number of bytes that the short_jump opcode will generate.
See CPU::Z80::Assembler.
See CPU::Z80::Assembler.
| CPU-Z80-Assembler documentation | Contained in the CPU-Z80-Assembler distribution. |
# $Id: JumpOpcode.pm,v 1.10 2010/11/21 16:37:05 Paulo Exp $ package CPU::Z80::Assembler::JumpOpcode; #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ use strict; use warnings; our $VERSION = '2.13'; use Asm::Preproc::Line; sub new { my($class, %args) = @_; bless [ $args{short_jump} || CPU::Z80::Assembler::Opcode->new(), # short jump opcode $args{long_jump} || CPU::Z80::Assembler::Opcode->new(), # long jump opcode ], $class; } sub short_jump { defined($_[1]) ? $_[0][0] = $_[1] : $_[0][0] } sub long_jump { defined($_[1]) ? $_[0][1] = $_[1] : $_[0][1] } # address and line : read from short_jump, write to short_jump and long_jump sub address { my($self, $address) = @_; if (defined $address) { $self->short_jump->address($address); $self->long_jump->address($address); return $address; } else { return $self->short_jump->address; } } sub line { my($self, $line) = @_; if (defined $line) { $self->short_jump->line($line); $self->long_jump->line($line); return $line; } else { return $self->short_jump->line; } } #------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------ sub short_jump_dist { my($self, $address, $symbol_table) = @_; # expr in a short jump is always second byte my $dist = $self->short_jump->child->[1]->evaluate($address, $symbol_table); return $dist; } #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ sub bytes { my($self, $address, $symbol_table) = @_; return $self->short_jump->bytes($address, $symbol_table); } #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ sub size { my($self) = @_; return $self->short_jump->size; } #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ 1;