Download User Manual - v8.8 C166/ST10 C Compiler

Transcript
Appendix D
D−6
.
.
mov
Rn, #SOF __RETURN_LABEL
mov
[−R0], Rn
mov
Rn, [Rx+#_fp]
jmpi CC_UC, [Rn]
__RETURN_LABEL:
.
.
code
size
min.
state
times
4
2
4
2
2
2
4
4
−−
12
−−
12
It is obvious that the code, needed to return from a near function, is
always the same, because the function does not know whether it is called
directly or indirectly. See the previous section for the code the C compiler
generates to return from a near function.
USER STACK MODEL
2.3 INDIRECT INTER−SEGMENT JUMPS USING THE
EXTENDED INSTRUCTION SET
Because the extended instruction set is available (e.g. C167) the system
stack can be used for indirect inter−segment jumps. Because with the
extended instruction ATOMIC the standard PEC interrupts and class A
hardware trap can be disabled for a specified number of instructions.
To perform an indirect inter−segment jump the segment number and
segment offset are pushed on the system stack and a RETS instruction is
executed. Then the execution resumes at the inter−segment address
pushed on the system stack. To avoid that these instructions are
interrupted they are protected with an ATOMIC instruction.
The following assembly listing shows the code for an indirect
inter−segment jump using the ATOMIC instruction. Rseg and Rsof contain
the inter−segment address to jump to.
atomic #3
push Rseg
push Rsof
rets
;
;
;
;
;
;
;
;
code can be read as :
mov CSP, Rseg
mov IP, Rsof
protect against interrupts
(SP) <− (SP) − 2 ; ((SP)) <−
(SP) <− (SP) − 2 ; ((SP)) <−
(IP) <− ((SP))
; (SP)
<−
(CSP)<− ((SP))
; (SP)
<−
Rseg
Rsof
(SP) + 2
(SP) + 2