pTAL Conversion Guide

pTAL Built-In Routines
pTAL Conversion Guide527302-002
18-19
$COUNTDUPS
srcaddr input,output
EXTADDR:variable
is an extended memory address. Starting at srcaddr, $COUNTDUPS scans 16-
bit words until it encounters two adjacent words that are not equal. At the end of
the operation, srcaddr points to the word that differs from the first word and
which, therefore, terminated the scan. If there are no duplicates in the buffer,
srcaddr points immediately after the last two words it compared—that is, at the
first word $COUNTDUPS did not examine.
maxwords input,output
uINT:variable
is the maximum number of 16-bit words to scan at srcaddr. At the end of the
operation, maxwords contains:
0 if $COUNTDUPS scanned the entire buffer
The number of words $COUNTDUPS did not scan because it found a
nonduplicate pair.
maxwords must be an INT variable; it cannot be a STRING, UNSIGNED, or USE
variable or a bit field.
duplicationcount input,output
uINT:variable
holds an initial value. At the end of the operation, duplicationcount contains
its original value plus the number of duplicate words found by $COUNTDUPS.
duplicationcount must be an INT variable; it cannot be a STRING,
UNSIGNED, or USE variable or a bit field.
$COUNTDUPS scans an extended memory buffer from left to right until it encounters
two adjacent unequal words or until it reads maxwords words.
Figure 18-3. TAL Code Equivalent to $COUNTDUPS Routine
STACK source, maxwords, duplication_count;
CODE(CDX);
STORE duplication_count, maxwords, source;