Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors


Manual Reference Pages  - reg_load_text (5)

NAME

reg/load() - Read sections of text or byte strings

CONTENTS

Synopsis
Description
Indirect Addressing
Error Handling
Examples
See Also
Author

SYNOPSIS

reg/load write, ([text], #offset)

DESCRIPTION

Reads 32 bits (4 bytes) at the given offset position within the text argument and returns as a PSUNIT_TYPE_RAWIDX, where #0 represents the first byte position, #1 the second byte position, and so on. If there are less than 4 bytes available at the given offset, the remaining bytes will be padded with zeroes. An out of range error occurs if offset is beyond the end of the text data.

The text argument can be a register of type PSUNIT_TYPE_PALTEXT or PSUNIT_TYPE_STRING. The offset may be a PSUNIT_TYPE_RAWIDX, or a psInteger encoded as a PSUNIT_TYPE_XVALUE.

INDIRECT ADDRESSING

Using parentheses ( ) with the reg/load instruction invokes the indirect addressing behaviour described above when the second argument is a text or byte string.

See the reg_load(5) manual page for a description of other functionality available with this command.

ERROR HANDLING

A runtime error is generated if the requested offset is beyond the end of the text data or if an argument provided is of the wrong type.

EXAMPLES

The following displays a text string in 32-bit hexadecimal sequences:

.main  
% Prepare string to read
reg/load P0,
    [The quick brown fox jumps over the lazy dog.]

% Obtain the length of the string reg/xload P1, (P0)
% Prepare loop counter reg/load P2, #0
% Prepare output reg/load P10, ![.prose.sys.io] reg/load P11, [psStreamOut]
.loop   % Load the next 32-bit sequence reg/load P3, (P0, P2) reg/conv P4, P3, #16
% Load the text associated with the 32-bit sequence reg/copy P5, [....] reg/save P5, (P3, #0)
% Display index and associated text attr/mvadd P10, P11, P4, [\t], P5, [\n]
% Increment the loop counter by 4 bytes op/add P2, P2, #4
% Test to see if loop counter has reached text length reg/cmp P2, P1 reg/jmpeq &[.loop], SCMP, #2
func/rtn

SEE ALSO

pal_commands(5), pal_registers(5), pal_indices(5), pal_macros(5), reg_load(5), reg_xload(5), reg_save(5), reg_scan(5), reg_copy(5), reg_conv(5),
PROSE Assembly Language at prose.sourceforge.net.

AUTHOR

Copyright (c) 2002-2018 Mark R. Bannister <cambridge@users.sourceforge.net>.

This is free software and can be downloaded from prose.sourceforge.net; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


PAL 1.0 reg_load_text (5) 3 January 2018
Generated by manServer 1.07 from man5/reg_load_text.5 using man macros.