Binary arithmetic operators – Echelon Neuron C User Manual
Page 73
Neuron C Reference Guide
53
s32_type some_number = {0, 0, 0, 4};
// initialized to 4 on reset
s32_type another_number = {-1, -1, -1, -16};
// initialized to -16
A number of constants are defined for use by the application if desired. s32_zero,
s32_one, s32_minus_one represent the numbers 0, 1, and -1.
If other constants are desired, they can be converted at runtime from ASCII
strings using the function s32_from_ascii( ).
Example:
s32_type one_million;
when(reset) {
s32_from_ascii("1000000", one_million);
}
Because this function is fairly time consuming, it could be advantageous to pre-
compute constants with the NXT Neuron C Extended Arithmetic Translator
utility. This program accepts an input file with declarations using standard
integer initializers, and creates an output file with Neuron C initializers. See
Using the NXT Neuron C Extended Arithmetic Translator
on page 69.
For example, if the input file contains the following statement:
const s32_type one_million = 1000000;
then the output file contains the following:
const s32_type one_million = {0x00,0x0f,0x42,0x40}
/* 1000000 */;
Users of the NodeBuilder tool can use Code Wizard to create initializer data for
s32_type network variables and configuration properties. The NodeBuilder
Neuron C debugger can display signed 32-bit integers through the s32_type
shown above.
The Neuron C debugger can display signed 32-bit integers as raw data at a
specific address. To examine the value of one or more contiguous signed 32-bit
integer variables, enter the address of the first variable into the raw data
evaluation window, select Raw Data at Address, Data Size as quad, Count as the
number of variables that you want to display, and Format as Dec. The data is
displayed as unsigned, even if it is negative. To view the data as signed, click on
the value field, and the Modify Variable window shows the data in both formats.
You can also modify signed 32-bit integer variables by clicking on the value field,
and entering new data in the usual format for integers.
The signed 32-bit integer arguments are all passed to the support functions as
addresses of structures. The calling function or task is responsible for declaring
storage for the arguments themselves. Argument lists are ordered so that input
arguments precede output arguments. In all cases, any of the signed 32-bit
integer input arguments can be reused as output arguments to facilitate
operations in place.
Binary Arithmetic Operators
Table 13 on page 54 lists the binary arithmetic operator functions.