Echelon Neuron User Manual
Page 64
![background image](/manuals/735710/64/background.png)
next instructions, but this alternative implementation would use one more byte
of code.
In this example, it is assumed that the value for the remainingSize argument
resides on top of the return stack. The function fetches a copy of it with the non-
modifying push [rsp] instruction.
At this point, the value for the currentValue argument is now buried deep under
the set of arguments and the copies of the pointer register. The function uses
DSP-relative addressing to access this value. The offset for retrieving the value
is -4, that is, the currentValue variable is the 4th byte on the data stack following
NEXT (note that pData is a two-byte value). Thus, the function uses the push
[dsp][-4] instruction.
Important: When using DSP-relative addressing, you should frequently review
its use. As you modify the assembly implementation, the stack frames could
change, which could require you to recalculate the offset values used for DSP-
relative addressing. The Neuron Assembler provides no tools for to automate
this recalculation. You can declare symbols (with the EQU directive) to assist
with DSP-relative offsets, which can allow you to review symbol definitions
rather than specific offsets, but the process is nonetheless manual.
The assembly function finally calls the diagnosis function with a callf
%diagnosis function call, which pushes the instruction pointer (IP) onto the
return stack, and executes the diagnosis function. If you knew that the diagnosis
function would be located in nearby memory, this function call could have
perhaps been replaced by the more compact callr %diagnosis instruction, which
covers function calls in the -128..+127 distance range. However, you do not have
control over the placement of the Neuron C-coded function, and thus must use
the CALLF instruction.
Finally, when function processing is complete, the calling function restores the
previously preserved register with a popd [pData] instruction.
54
Interfacing with a Neuron C Application