ST20-C1 STMICROELECTRONICS [STMicroelectronics], ST20-C1 Datasheet - Page 51

no-image

ST20-C1

Manufacturer Part Number
ST20-C1
Description
Instruction Set Reference Manual
Manufacturer
STMICROELECTRONICS [STMicroelectronics]
Datasheet
A C function is used for purposes of illustration. For simplicity, it is assumed that the
single result can be returned in the evaluation stack:
One of the loading sequences described earlier may be required if the expressions
returned in the registers contain evaluations.
4.10.4 Calling a function
The first three par ameters should be loaded into the evaluation stack before the fcall
instruction. These parameters can be stored as local variables after the workspace
pointer has been moved down, to make the best use of the work space cache. The
remainder of the parameters passed should be loaded into the work space before fcall
is executed.
When the function returns, the results whose addresses were passed will already
have been stored so all that remains is to store up to 2 results returned in the evalua-
tion stack.
For example the function call
could be compiled by
The compiler must have already allocated sufficient workspace for the parameters that
are stacked explicitly.
Single result functions
In most programming languages, a function that returns a single result can be used in
an expression as well as in an assignment.
A common form of function returns a single value contained in a word — the
mechanism described above will return this in Areg. When compiling expressions,
(using the algorithm described in section C.3 in Appendix C) the depth of such a
function call should be taken as being infinite — i.e. deeper than any other form of
expression. This is because the function call will always lose any other information in
the registers. By giving it infinite depth the expression compilation algorithm will never
call a function while another expression result is being held in a register.
ajw -local_variables-1;
P;
E;
ldl local_variables;
ajw local_variables+1;
jab;
V = F ( E
E
E
stl V;
3
2
; stl 0; . . . ; E
; E
1
; static_link; fcall F;
1
, . . . , E
n
; stl (n-3);
n
)
4 Using ST20-C1 instructions
51/205

Related parts for ST20-C1