GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
CPU::Z80::Assembler::Expr(3) User Contributed Perl Documentation CPU::Z80::Assembler::Expr(3)

CPU::Z80::Assembler::Expr - Represents one assembly expression to be computed at link time

  use CPU::Z80::Assembler::Expr;
  my $node = CPU::Z80::Assembler::Expr->new( type => "sb" );
  $expr->parse($input);
  $new_expr = $expr->build($expr_text);
  $value = $expr->evaluate($address, \%symbol_table);
  $bytes = $expr->bytes($address, \%symbol_table);

This module defines the class that represents one assembly expression to be computed at link time.

Nothing.

Creates a new object, see Class::Struct.

The type string has to be defined before the "bytes" method is called, and defines how to code the value returned by "evaluate" into a byte string.

Type is one of:

"sb"
for signed byte - a 8 bit signed value. A larger value is truncated and a warning is issued.
"ub"
for unsigned byte - a 8 bit unsigned value. A larger value is truncated and a warning is issued.
"w"
for word - a 16 bit unsigned value in little endian format. A larger value is truncated, but in this case no warning is issued. The address part above 0xFFFF is considered a bank selector for memory banked systems.

A STRING value is computed in little endian format and only the first two characters are used. "ab" is encoded as ord("a")+(ord("b")<<8).

The text bytes used in defm / deft are a string of bytes in big endian format, not truncated. For example, 0x112233 is stored as the 3-byte sequence 0x11, 0x22 and 0x33.

A STRING value is encoded with the list of characters in the string. If the string is used in an expression, then the expression applies to the last character of the string. This allows expressions like "CALL"+0x80 to invert bit 7 of the last character of the string.

C-like escape sequences are expanded both in single- and double-quoted strings.

List of tokens composing the expression.

Get/set the line - text, file name and line number where the token was read.

  $expr->parse($input);

Parses an expression at the given $input stream (Iterator::Simple::Lookahead), leaves the stream pointer after the expression and updates the expression object. Dies if the expression cannot be parsed.

  $value = $expr->evaluate($address, $symbol_table)

Computes the value of the expression, as found at the given address and looking up any referenced symbols from the given symbol table.

The address is used to evaluate the value of '$'.

The symbol table is a hash of symbol names to values. The value is either a scalar value that is used directly in the expression, or a reference to a sub-expression that is computed recursively by calling its "evaluate" method.

Exits with a fatal error if the expression cannot be evaluated (circular reference, undefined symbol or mathematical error).

  $new_expr = $expr->build($expr_text)
  $new_expr = $expr->build($expr_text, @init_args)

Build and return a new expresion object with an expression based on the current object. The expression is passed as a string and is lexed by CPU::Z80::Assembler "z80lexer". The special token '{}' is used to refer to this expression.

For example, to return a new expression object that, when evaluated, gives the double of the current expression object:

  my $new_expr = $expr->build("2*{}");

@init_args can be used to pass parameters to the constructor of the new expression object.

  $bytes = $expr->bytes($address, \%symbol_table);

Calls "evaluate" to compute the value of the expression, and converts the value to a one or two byte string, according to the "type".

See CPU::Z80::Assembler.

CPU::Z80::Assembler Asm::Preproc::Line Class::Struct

See CPU::Z80::Assembler.
2019-07-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.