Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors
reg/copy - Copy or concatenate text arguments
Synopsis
Description
Indirect Addressing
Error Handling
Examples
See Also
Author
reg/copy write, read <, read ... >
reg/copy write, ([text], #offset)
reg/copy write, ([text], #offset, #nbytes)
reg/copy write, (#index, #offset)
reg/copy write, (#index, #offset, #nbytes)
In the first synopsis form, concatenates the given read arguments and saves in a new byte string which is returned in the write register. This is a new memory structure that can be released using reg/clr.
This instruction will concatenate text strings of type PSUNIT_TYPE_PALTEXT and byte strings of type PSUNIT_TYPE_STRING.
If a raw index is provided as a read argument (type PSUNIT_TYPE_RAWIDX), it will be converted to a text representation using base-10 (decimal). Note that the reg/conv instruction may be used for better control over numeric conversions.
If an object reference of the form ![target] or a register containing type PSUNIT_TYPE_NODE is provided as a read argument, it will be converted to a text representation of the target path.
If a walker structure is provided as a read argument (type PSUNIT_TYPE_WALKER), it will be converted to a text representation of the path to the node being walked. See reg_load_walker(5).
If an object edit structure is provided as a read argument (type PSUNIT_TYPE_OBJEDIT), it will be converted to a text representation of the path to the node being edited. See obj_edit(5).
If a class or attribute definition is provided as a read argument (type PSUNIT_TYPE_CLASSDEF or PSUNIT_TYPE_ATTRDEF), it will be converted to the text name of the class or attribute. See class_load(5) and attr_load(5).
If an encoded data value is provided as a read argument (type PSUNIT_TYPE_XVALUE), the data value will be duplicated as a byte string and concatenated. See attr_def(5).
In the second and third synopsis forms, copies the bytes at the given offset position within a text argument or byte string, where #0 represents the first byte position, #1 the second byte position and so on, storing them in a new byte string which is returned in the write register. This is a new memory structure that can be released using reg/clr. The number of bytes copied can be limited by the nbytes argument. If nbytes is zero then this will produce an empty string. If nbytes is greater than the length of text it will be adjusted automatically to fit the rest of the string precisely. The offset and nbytes arguments may also be a psInteger type expressed as a PSUNIT_TYPE_XVALUE.
In the fourth and fifth synopsis forms, converts the given index into a string representation (using a base 10 conversion), and then proceeds to copy the byte offset positions in the same way as if the number had been provided as a text argument.
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.
reg/copy P0, [Midsomer] Sets up a new string containing the text "Midsomer". The string will be stored in register P0 and can be released again using reg/clr. reg/copy P0, P0, [ Murders] Concatenates the text " Murders" onto the end of the string in register P0. The memory taken by the original string in P0 will be released. reg/copy PUSH, [The number is ], #42 Concatenates the text "The number is " and the decimal number 42 to a new string which will be pushed to the stack. The string can be released again using reg/clr. reg/copy P0, (P0, #9) Copies from the 10th character position (offset 9) to the end of the string in register P0, overwriting the original string. The memory taken by the original string in P0 will be released.
pal_commands(5), pal_registers(5), pal_indices(5), pal_macros(5), reg_clr(5), reg_load_text(5), reg_save(5), reg_conv(5),
PROSE Assembly Language at prose.sourceforge.net.
Copyright (c) 2002-2017 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_copy (5) | 28 September 2017 |