pTAL Conversion Guide

pTAL Built-In Routines
pTAL Conversion Guide527302-002
18-9
$ASCIITOFIXED
qvaluein input
FIXED(*):value
is a value that $ASCIITOFIXED adds to the result of converting the bytes at
bufferaddr. $ASCIITOFIXED multiples qvaluein by 10 for each digit it converts
from ASCII to FIXED. After it converts the last digit at bufferaddr,
$ASCIITOFIXED adds qvaluein to the result of the conversion to establish the
value that it returns qvalueout.
qvalueout output
FIXED(*):variable
is a quadrupleword integer value that holds the final result of the conversion.
$ASCIITOFIXED converts a string of ASCII-coded digits at bufferaddr to a
binary-coded FIXED value, adds qvaluein times 10
n
, where n is the number of
digits converted, and stores the result in qvalueout.
If a nondigit ASCII code is encountered, $ASCIITOFIXED ends the conversion.
$ASCIITOFIXED converts only the digits before the nondigit ASCII code. CCG
indicates that $ASCIITOFIXED converted only part of the ASCII number; CCE
indicates $ASCIITOFIXED converted the entire string. Overflow is set if the result is
greater than 2
63
-1 or less than -2
63
. If $OVERFLOW is true, qvalueout is
undefined.
$ASCIITOFIXED alters the condition code and $OVERFLOW.
Figure 18-1. TAL Code Equivalent to $ASCIITOFIXED Routine
STACK bufferaddr, maxdigits, qvaluein;
CODE(CAQV);
STORE qvalueout, remainingdigits, bufferaddr;
Example 18-1. Call to $ASCIITOFIXED Routine
LITERAL buffer_len = 100;
STRING .buffer[ 0:buffer_len - 1 ]; ! Buffer to convert
STRING .ptr := @buffer; ! Pointer to buffer
INT maxdigits;
INT remainingdigits;
FIXED qvaluein;
FIXED qvalueout;
$ASCIITOFIXED (@ptr, maxdigits, remainingdigits,
qvaluein, qvalueout);