Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors
Increment/decrement numeric component by 1
Synopsis
Description
Incrementing Values
Decrementing Values
Error Handling
Examples
See Also
Author
op/incr
op/incr register <, register ... >
op/incr ![object] <, ![object] ... >
op/incr attribute, ![object] <, attribute, ![object] ... >op/decr
op/decr register, <, register ... >
op/decr ![object] <, ![object] ... >
op/decr attribute, ![object] <, attribute, ![object] ... >
Increments or decrements a numeric component by 1. The instructions can work with registers, raw indices, variable objects or encoded attribute values. Argument types may be mixed with a single instruction.
If no arguments are provided, increments or decrements the value in the Accumulator by 1.
Each register argument may be a register containing one of the following types:
PSUNIT_TYPE_RAWIDX A raw index. PSUNIT_TYPE_NODE An object reference pointing to a variable object, described below. PSUNIT_TYPE_XVALUE An encoded attribute value, see attr_def(5). Each object argument may be an object reference pointing to a variable object, see var_def(5). If an attribute definition has previously been supplied or selected, this attribute will be used again. If no previous attribute has been selected, the first attribute with the super-type psVariable is selected. If no attribute with a psVariable super-type can be found, the first class with the super-class psVariable is located and the attribute of the same name will be selected. If the attribute currently has no value, it will be treated as if it is currently set to 0.
The attribute argument may be used to specify which attribute should be selected from subsequent variable objects. This is supplied as a text argument containing the name of the object attribute, or a register containing the type PSUNIT_TYPE_ATTRDEF returned by the attr/load instruction.
The op/incr instruction increments raw indices, variable objects or encoded attribute values by 1. The values can be stored in, or referred to by registers pointed to by successive arguments.
E.g. reg1++(, reg2++, ...regN++)
The op/incr instruction can also increment variable objects that are referred to by object references.
E.g. var1++(, var2++, ...varN++)
If no arguments are provided, increments the value in the Accumulator by 1.
E.g. A++
The op/decr instruction decrements raw indices, variable objects or encoded attribute values by 1. The values can be stored in, or referred to by registers pointed to by successive arguments.
E.g. reg1--(, reg2--, ...regN--)
The op/decr instruction can also decrement variable objects that are referred to by object references.
E.g. var1--(, var2--, ...varN--)
If no arguments are provided, decrements the value in the Accumulator by 1.
E.g. A--
A runtime error is generated if a register argument is not a register containing the correct type, or a referenced object or attribute does not exist, or if an object or attribute does not support maths operations.
The following demonstrates the use of op/incr on different types:
.main % Load the number 25 into a register (P0) reg/load P0, #25
% Encode using psIndex syntax (P1) attr/load P8, [psIndex] attr/def P1, P8, P0
% Create a local variable called i (P2) var/local P2, P8, [i], #25
% Increment P0, P1 and P2 op/incr P0, P1, P2
% Compare each, they should be the same attr/index P3, P1 attr/index P4, P2, P8 reg/cmp P0, P3, P0, P4 reg/jmpeq &[.end], SFLG, #3
% They are not the same, something is wrong obj/dump P0, P1, P2
.end reg/clr P1 func/rtn
pal_commands(5), pal_registers(5), pal_indices(5), op_maths(5), opa_maths(5), opo_maths(5), opx_maths(5), attr_load(5), attr_def(5), var_def(5), ps_classes(5), ps_attributes(5),
PROSE Assembly Language at prose.sourceforge.net.
Copyright (c) 2002-2010 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 | op_incr (5) | 15 April 2010 |