Fixed-Point Math Processor

Overview

The Fixed-Point Math Processor is an optional NCS/e expansion module providing fixed-point arithmetic and advanced mathematical operations beyond the native integer arithmetic supported by the CPU.

The module communicates through the EXT bus and operates directly on NCL integer values and registers.

Programs using these verbs require a compatible Fixed-Point Math Processor to be installed.


Fixed-point representation

Fixed-point values use a scale factor of 1000, providing three decimal places of precision.

Integer Fixed-point value
1 0.001
100 0.100
1000 1.000
1250 1.250
-500 -0.500
3142 3.142

Because fixed-point values are stored as ordinary 32-bit signed integers, they may be stored in integer registers and manipulated by native NCL instructions.

Addition, subtraction, negation, comparison, minimum, maximum, and similar operations do not require fixed-point-specific instructions.

-- 1.250 + 2.500 = 3.750
ADD r0 1250 2500
-- > r0 = 3750

Operations that require scaling, such as multiplication and division, are provided by the module.


Internal calculation

The Fixed-Point Math Processor uses fixed-point integers for its NCL interface.

Some operations, particularly powers, square roots, and trigonometric functions, may temporarily convert operands to floating-point values internally. Results are then converted back to the module's fixed-point representation before being returned to the CPU.

This implementation detail does not change the representation used by NCL programs, but may introduce small rounding differences. Unless otherwise specified, results should be treated as accurate to the module's fixed-point precision rather than as exact mathematical values.


Constants

MATH.PI — Pi

The module provides π in its native fixed-point representation:

MATH.PI = 3142

Arithmetic

MATH.FMUL — Fixed-Point Multiply

MATH.FMUL <dst> <lhs> <rhs>

Multiplies two fixed-point values and stores the fixed-point result.

MATH.FMUL r0 1500 2000
-- > r0 = 3000
-- > 1.500 × 2.000 = 3.000

MATH.FDIV — Fixed-Point Divide

MATH.FDIV <dst> <numerator> <denominator>

Divides one fixed-point value by another and stores the fixed-point result.

MATH.FDIV r0 3000 2000
-- > r0 = 1500
-- > 3.000 / 2.000 = 1.500

MATH.FPOW — Fixed-Point Power

MATH.FPOW <dst> <base> <exponent>

Raises a fixed-point value to a power.


MATH.FSQRT — Fixed-Point Square Root

MATH.FSQRT <dst> <val>

Calculates the square root of a fixed-point value.

MATH.FSQRT r0 2000
-- > approximately 1414
-- > √2.000 ≈ 1.414

Distance

MATH.DIST — Distance

MATH.DIST <dst> <x1> <y1> <x2> <y2>

Calculates the Euclidean distance between two two-dimensional points.

MATH.DIST r0 0 0 3000 4000
-- > r0 = 5000
-- > distance = 5.000

DIST may be composed to calculate distances in additional dimensions.

-- Calculate the XY distance.
MATH.DIST r0 x1 y1 x2 y2

-- Incorporate the Z dimension.
MATH.DIST r0 0 z1 r0 z2

The result may be repeatedly fed back into DIST to incorporate any number of dimensions.

Because each intermediate result is represented to three decimal places, repeated composition may accumulate rounding error.


Trigonometry

The Fixed-Point Math Processor provides trigonometric operations using fixed-point values.

Planned operations include:

MATH.SIN
MATH.COS
MATH.TAN
MATH.ASIN
MATH.ACOS
MATH.ATAN
MATH.ATAN2

Exact signatures and angle conventions are to be specified.