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


Manual Reference Pages  - opa_maths (5)

NAME

opa_maths - Basic maths operations with Accumulator

CONTENTS

Synopsis
Description
Add/subtract
Multiply/divide
Bitwise Operations
Error Handling
Examples
See Also
Author

SYNOPSIS

Addition/subtraction:

opa/add read, <, read ... >
opa/sub read, <, read ... >

Multiplication/division:

opa/mult read, <, read ... >
opa/div read, <, read ... >
opa/mod read, <, read ... >

Bitwise operations:

opa/not
opa/and read, <, read ... >
opa/or read, <, read ... >
opa/xor read, <, read ... >
opa/shl read, <, read ... >
opa/shr read, <, read ... >
opa/rol read, <, read ... >
opa/ror read, <, read ... >

DESCRIPTION

Performs mathematical operations on the number in the Accumulator. Each read argument may be a raw index or a register containing a raw index.

ADD/SUBTRACT

The following instructions can be used to perform addition or subtraction with the Accumulator:

opa/add
  Add the read arguments to the value in the Accumulator in the order provided.
E.g. A = A + arg1 (+ arg2... + argN)
opa/sub
  Subtract the read arguments from the value in the Accumulator in the order provided.
E.g. A = A - arg1 (- arg2... - argN)

MULTIPLY/DIVIDE

The following instructions can be used to perform multiplication and division with the Accumulator:

opa/mult
  Multiply the value in the Accumulator by each read argument in the order provided.
E.g. A = A * arg1 (* arg2... * argN)
opa/div
  Divide the value in the Accumulator by each read argument in the order provided. The result will be rounded down to the nearest whole number.
E.g. A = A / arg1 (/ arg2... / argN)
opa/mod
  Divide the value in the Accumulator by the read arguments in the order provided returning the remainder each time.
E.g. A = A % arg1 (% arg2... % argN)

BITWISE OPERATIONS

The following instructions can be used to perform bitwise operations with the Accumulator:

opa/not
  Perform a bitwise NOT operation on the value in the Accumulator. Bits that are set will be cleared, and bits that are clear will be set.
E.g. A = A ^ 0xffffffff
opa/and
  Perform a bitwise AND operation on the value in the Accumulator with the read arguments in the order provided. Only the bits that are set in the Accumulator and all argument values will remain set in the result.
E.g. A = A & arg1 (& arg2... & argN)
opa/or
  Perform a bitwise OR operation on the value in the Accumulator with the read arguments in the order provided. All bits that are set in the Accumulator or any of the argument values will be set in the result.
E.g. A = A | arg1 (| arg2... | argN)
opa/xor
  Perform a bitwise exclusive OR operation on the value in the Accumulator with the read arguments in the order provided. Bits are toggled on and off in the Accumulator when set in successive argument values.
E.g. A = A ^ arg1 (^ arg2... ^ argN)
opa/shl
  Perform a bitwise shift left operation on the value in the Accumulator, shifting bits by the sum of the read arguments.
E.g. A = A << arg1 (<< arg2... << argN)
opa/shr
  Perform a bitwise shift right operation on the value in the Accumulator, shifting bits by the sum of the read arguments.
E.g. A = A >> arg1 (>> arg2... >> argN)
opa/rol
  Perform a bitwise rotate left operation on the value in the Accumulator, rolling bits by the sum of the read arguments.
E.g. A = (A << (arg1 + arg2... + argN)) |
  (A >> (32 - arg1 + arg2... + argN))
opa/ror
  Perform a bitwise rotate right operation on the value in the Accumulator, rolling bits by the sum of the read arguments.
E.g. A = (A >> (arg1 + arg2... + argN)) |
  (A << (32 - arg1 + arg2... + argN))

ERROR HANDLING

A runtime error is generated if a read argument is not a number (raw index) or a register containing one.

EXAMPLES

opa/add #620, #50, #25, #20, #5
  Add 720 to the value in the Accumulator.
opa/mod P0
  Divide the value in the Accumulator by P0, storing the remainder back in the Accumulator.
opa/shl #4
  Shift the value in the Accumulator left by four bit positions. This is equivalent to multiplying the Accumulator by 8 (with a 32-bit limit).

SEE ALSO

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