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


Manual Reference Pages  - reg_conv (5)

NAME

reg/conv - Convert between raw indices and strings

CONTENTS

Synopsis
Description
Error Handling
Examples
See Also
Author

SYNOPSIS

reg/conv write, #index
reg/conv write, #index, #base
reg/conv write, #index, #base, #pad

reg/conv write, [text]
reg/conv write, [text], #base

DESCRIPTION

In the first three synopsis forms, converts from a 32-bit raw index number to a string (PSUNIT_TYPE_STRING), returning the new string in the write register. This is a new memory structure that can be released using reg/clr.

In the fourth and fifth synopsis forms, converts from a text string of type PSUNIT_TYPE_PALTEXT or a byte string of type PSUNIT_TYPE_STRING to a 32-bit raw index number.

The optional base argument identifies the numeric base to use for the conversion. When converting from an index number to a string, the base may be 2 (binary), 8 (octal), 10 (decimal) or 16 (hexadecimal). If the base argument is not supplied, the default is base 10.

When converting from a string to an index number, the base may be between 2 and 36. If the base argument is not supplied, it will be determined automatically as follows: a string beginning 0b will be base 2 (binary), 0x will be base 16 (hexadecimal), 0 will be base 8 (octal), and anything else base 10.

The optional pad argument requests that the resulting number is padded with leading zeroes if required so that the final string has at least this many digits.

If the write register is also provided as a read argument and is a register containing the type PSUNIT_TYPE_STRING, then this memory structure will be released before the register is overwritten. This allows for strings to be converted in an existing register.

ERROR HANDLING

A runtime error is generated if the requested base is not supported or if an argument provided is of the wrong type.

EXAMPLES

reg/conv P0, #65535, #16
  Sets up a new string containing the text "ffff", which is the decimal number 65535 in hexadecimal form (base 16). The string will be stored in register P0 and can be released again using reg/clr.
reg/conv PUSH, #65535, #16, #8
  Sets up a new string containing the text "0000ffff" and pushes the result onto the program stack.
reg/conv P0, [42]
  Converts the text "42" to an index number 42 using the default base (10).

SEE ALSO

pal_commands(5), pal_registers(5), pal_indices(5), pal_macros(5), reg_clr(5), reg_load_text(5), reg_save(5), reg_copy(5), attr_index(5),
PROSE Assembly Language at prose.sourceforge.net.

AUTHOR

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_conv (5) 31 December 2017
Generated by manServer 1.07 from man5/reg_conv.5 using man macros.