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


Manual Reference Pages  - reg_cmp (5)

NAME

reg/cmp - Compare registers

CONTENTS

Synopsis
Description
Error Handling
Examples
See Also
Author

SYNOPSIS

reg/cmp cmp1, cmp2 <, cmp1, cmp2 ... >

DESCRIPTION

Compares registers or indices storing the result of each comparison in the SCMP and SFLG registers.

If either register is of type PSUNIT_TYPE_NULL, PSUNIT_TYPE_LOCK, PSUNIT_TYPE_INTLOCKL or PSUNIT_TYPE_INTLOCKF then a type comparison is performed, i.e. the result will be PSCMP_EQUAL if both cmp1 and cmp2 contain the same type. Note that the stack lock markers PSUNIT_TYPE_LOCK, PSUNIT_TYPE_INTLOCKL and PSUNIT_TYPE_INTLOCKF are all considered the same type for the purposes of the comparison.

If both registers are of either type PSUNIT_TYPE_STRING or PSUNIT_TYPE_PALTEXT then a string text comparison is performed. The result can be PSCMP_LESS, PSCMP_EQUAL or PSCMP_GREATER.

If both registers are of type PSUNIT_TYPE_RAWIDX then a numeric comparison is performed. The result can be PSCMP_LESS, PSCMP_EQUAL or PSCMP_GREATER.

Registers containing other data types are subject to the rules below:

PSUNIT_TYPE_WALKER
  The result is PSCMP_EQUAL if both walkers are open on the same node. A comparison with PSUNIT_TYPE_NODE is PSCMP_EQUAL if it refers to the same node being walked. See reg_load_walker(5).
PSUNIT_TYPE_OBJEDIT
  The result is PSCMP_EQUAL if both buffers are editing the same node. A comparison with PSUNIT_TYPE_NODE is PSCMP_EQUAL if it refers to the same node being edited. See obj_edit(5).
PSUNIT_TYPE_READSEG
  The result is PSCMP_EQUAL if reading the same data segment. A comparison with PSUNIT_TYPE_PALDATA is PSCMP_EQUAL if it refers to the same data segment being read. See reg_load_segment(5).
PSUNIT_TYPE_READTAB
  The result is PSCMP_EQUAL if reading the same data table. A comparison with PSUNIT_TYPE_RAWIDX is PSCMP_EQUAL if it refers to the same table number being read. See reg_load_table(5).
PSUNIT_TYPE_READCLASS
  The result is PSCMP_EQUAL if both class read structures have the same list of classes (in any order). This will be true if both read structures were initialised from the same object, or from two different objects that contained the same class list. See class_load(5).
PSUNIT_TYPE_READATTR
  The result is PSCMP_EQUAL if both attribute read structures have the same list of attributes (in any order). This will be true if both read structures were initialised from the same object, or from two different objects that contained the same attribute list. See attr_load(5).
PSUNIT_TYPE_READVAL
  The result is PSCMP_EQUAL if both attribute copy structures are processing the same attribute type. A comparison with PSUNIT_TYPE_ATTRDEF is PSCMP_EQUAL if it refers to the same attribute type as the copy structure. See attr_copy(5).
PSUNIT_TYPE_XVALUE
  If both registers for comparison are of this type, then the comparison is performed on the encoded values as if attr/cmp had been used.

If the first register is of type PSUNIT_TYPE_STRING or PSUNIT_TYPE_PALTEXT, then the second register will be converted to a PSUNIT_TYPE_STRING representation before a string text comparison is performed.

If the second register is of type PSUNIT_TYPE_STRING or PSUNIT_TYPE_PALTEXT, then this register will be converted to the same attribute syntax as the first register and compared as if attr/cmp had been used.

If the other register is of type PSUNIT_TYPE_RAWIDX and if the back-end syntax supports the PSAPI_CMPINDEX entry-point, then the two data values will be compared directly and the result can be PSCMP_LESS, PSCMP_EQUAL or PSCMP_GREATER.

PSUNIT_TYPE_LIST
  The result is PSCMP_EQUAL if both list sequences contain identical data, otherwise the result is PSCMP_NOTEQUAL.

Any other combinations result in PSCMP_EQUAL if cmp1 and cmp2 contain the same data type and point to the same data object, otherwise the result is PSCMP_NOTEQUAL.

ERROR HANDLING

A runtime error will occur if a register is of a type for which comparison is not supported, or if a referenced object does not exist.

EXAMPLES

reg/cmp #10, #11, [Text1], [Text2]
  Tests two numbers and two strings. The SCMP register will contain the result of the last compare (the strings) while the lowermost 2 bits of the SFLG register will tell you whether either comparison tested true for equality.

SEE ALSO

pal_commands(5), pal_registers(5), pal_indices(5), reg_jmpeq(5), reg_lcmp(5), obj_cmp(5), attr_cmp(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_cmp (5) 1 November 2017
Generated by manServer 1.07 from man5/reg_cmp.5 using man macros.