Download i960 Jx Microprocessor Developer`s Manual

Transcript
PROCEDURE CALLS
Example 7-2. Parameter Passing Code Example
# Example of parameter passing . . .
# C-source:int a,b[10];
#
a = proc1(a,1,’x’,&b[0]);
#
assembles to ...
mov
r3,g0
# value of a
ldconst
1,g1
# value of 1
ldconst
120,g2
# value of “x”
lda
0x40(fp),g3
# reference to b[10]
call
_proc1
mov
g0,r3
#save return value in “a”
.
.
_proc1:
movq
g0,r4
# save parameters
.
.
# other instructions in procedure
.
# and nested calls
mov
r3,g0
# load return parameter
ret
7.4
LOCAL CALLS
A local call does not cause a stack switch. A local call can be made two ways:
•
with the call and callx instructions; or
•
with a system-local call as described in section 7.5, “SYSTEM CALLS” (pg. 7-15).
call specifies the address of the called procedures as the IP plus a signed, 24-bit displacement (i.e.,
-223 to 223 - 4). callx allows any of the addressing modes to be used to specify the procedure
address. The IP-with-displacement addressing mode allows full 32-bit IP-relative addressing.
When a local call is made with a call or callx, the processor performs the same operation as
described in section 7.1.3.1, “Call Operation” (pg. 7-6). The target IP for the call is derived from
the instruction’s operands and the new stack frame is allocated on the current stack.
7-14