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


Manual Reference Pages  - opo_maths (5)

NAME

opo_maths - Basic maths operations, result to variable object

CONTENTS

Synopsis
Description
Error Handling
Examples
See Also
Author

SYNOPSIS

Addition/subtraction:

opo/add ![target], read, read, <, read ... >
opo/add attribute, ![target], read, read, <, read ... >

opo/sub ![target], read, read, <, read ... >
opo/sub attribute, ![target], read, read, <, read ... >

Multiplication/division:

opo/mult ![target], read, read, <, read ... >
opo/mult attribute, ![target], read, read, <, read ... >

opo/div ![target], read, read, <, read ... >
opo/div attribute, ![target], read, read, <, read ... >

opo/mod ![target], read, read, <, read ... >
opo/mod attribute, ![target], read, read, <, read ... >

Bitwise operations:

opo/not ![target], read
opo/not attribute, ![target], read

opo/and ![target], read, read, <, read ... >
opo/and attribute, ![target], read, read, <, read ... >

opo/or ![target], read, read, <, read ... >
opo/or attribute, ![target], read, read, <, read ... >

opo/xor ![target], read, read, <, read ... >
opo/xor attribute, ![target], read, read, <, read ... >

opo/shl ![target], read, read, <, read ... >
opo/shl attribute, ![target], read, read, <, read ... >

opo/shr ![target], read, read, <, read ... >
opo/shr attribute, ![target], read, read, <, read ... >

opo/rol ![target], read, read, <, read ... >
opo/rol attribute, ![target], read, read, <, read ... >

opo/ror ![target], read, read, <, read ... >
opo/ror attribute, ![target], read, read, <, read ... >

DESCRIPTION

Performs mathematical operations on registers, raw indices, variable objects and encoded attribute values.

In all cases the first argument ![target] is an object reference (or register containing an object reference) pointing to a variable object in which to store the result of the computation, see var_def(5). The remaining read arguments are operands to compute.

To take an existing value in a variable object, perform a computation on it and store the result back in the same object, set the target and first read argument to the same object.

The attribute to update within the target variable object is selected by searching the attribute list for the first attribute with super-type psVariable. If an attribute meeting this criteria cannot be found, the class list is searched for the first class with super-class psVariable and the attribute of the same name is selected.

Alternatively, if an attribute argument is provided before the target, this will be the text name of the attribute to update within the target object, or alternatively a register containing the type PSUNIT_TYPE_ATTRDEF returned by the attr/load instruction.

The semantics of the read arguments are identical to those documented in op_maths(5), except that the data target type is determined by the syntax of the target attribute and there is no intermediate type.

ERROR HANDLING

A runtime error is generated if the target object has no suitable attribute for storing the result (or no class assigned that would permit the creation of a suitable attribute), if a read argument is not the correct type, if a referenced object does not exist, or if an object or encoded attribute value does not support maths operations.

EXAMPLES

The following code example creates a local variable object called ’i’ and performs some maths operations on it:

.main  
% i=51
var/local P0, [psIndex], [i], #51

% i=i/10 opo/sub P0, P0, #10
% j=i+3 var/local PUSH, [psIndex], [j] opo/add PULL, P0, #3

SEE ALSO

pal_commands(5), pal_registers(5), pal_indices(5), op_incr(5), op_maths(5), opa_maths(5), opx_maths(5), attr_load(5), var_def(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 opo_maths (5) 28 December 2017
Generated by manServer 1.07 from man5/opo_maths.5 using man macros.