Overview of the functions, Abs16 (absolute value, 16 bit) – Echelon Neuron User Manual
Page 170

Overview of the Functions
The Neuron firmware provides certain functions for common programming tasks
that can make Neuron assembly language programming easier to write and
maintain. This chapter describes these system-provided functions.
For each of the system-provided functions, the arguments and return values are
described as a series of byte values on the data stack, listed in order with top of
stack (TOS) first, following the rules and guidelines described in Chapter 4,
Interfacing with a Neuron C Application, unless explicitly stated otherwise. A
function’s description explicitly mentions if the function uses the return stack.
Unless otherwise specified, all arguments to a function are consumed by the
function.
Some functions return Boolean results. For example, the _equal16 function
returns true if two 16-bit operands are equal. For those functions, “true” is
reported as one, and “false” is reported as zero.
For each function, the description includes a representation of how the function
affects the data stack, its relative location in program memory, and the registers
it affects:
•
Stack Transformation: Stack affect and stack transition comments follow
the recommendations provided in Documenting Changes to the Stack.
Location: For each function, a location is given as either “near” or “far”.
For “near” locations, you can call the function with the either the CALL
or CALLF instruction. For “far” locations, you must use the CALLF
instruction to call the function. A function is designated as “far” if it is
“far” on any platform. For a specific platform, if the function address is
less than h’2000 (as determined by the generated .sym file), then you
could use the CALL instruction, but you must consider that using this
instruction will not allow your code to be portable, nor is it guaranteed to
work for future system images on the same platform.
•
Registers Affected: Certain functions affect registers, such as P0 or R1.
Most functions have no affect on system registers.
_abs16 (Absolute Value, 16 Bit)
This function returns the absolute value of a signed 16-bit integer.
Stack Transformation: (a(2) --|a(2)|)
Location: Near
Registers Affected: None
Example:
This example returns the absolute value of -8.
pushd #-d’8 ; (-d’8, -d’1)
call _abs16 ; (d’8, 0)
160
System-Provided Functions