|
NAMECPU::Z80::Assembler::Expr - Represents one assembly expression to be computed at link timeSYNOPSISuse 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); DESCRIPTIONThis module defines the class that represents one assembly expression to be computed at link time.EXPORTSNothing.FUNCTIONSnewCreates a new object, see Class::Struct.typeThe 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:
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. childList of tokens composing the expression.lineGet/set the line - text, file name and line number where the token was read.parse$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. evaluate$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). build$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$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". BUGS and FEEDBACKSee CPU::Z80::Assembler.SEE ALSOCPU::Z80::Assembler Asm::Preproc::Line Class::StructAUTHORS, COPYRIGHT and LICENCESee CPU::Z80::Assembler.
Visit the GSP FreeBSD Man Page Interface. |