User’s Manual
C166S V1 SubSystem
Central Processing Unit
User’s Manual
3-83
V 1.6, 2001-08
•
Explicit Stack Pointer Updating
Neither the RET nor POP instruction is capable of correctly using a new SP register
value, which is to be updated by an immediately preceding instruction. Thus, in order to
use the new SP register value without erroneously performed stack accesses, at least
one instruction must be inserted between an instruction that explicitly writes to SP, and
any of the afore mentioned subsequent instructions that implicitly use the SP, as shown
in the following example:
I
n
:MOV SP,#0FA40H
;select a new top of stack
I
n+1
:....
;must not be an instruction popping operands
;from the system stack
I
n+2
:POP R0
;pop word value from new top of stack into R0
Furthermore none of the RETI, RETS or RETP instructions are capable of correctly using
a new SP register value, which is to be updated by one or both of the two immediately
preceding instructions. Thus, in order to use the new SP register value without
erroneously performed stack accesses, at least two instructions must be inserted
between an instruction that explicitly writes to SP, and any of the afore mentioned
subsequent instructions that implicitly use the SP, as shown in the following example:
I
n
:MOV SP,#0FA40H
;select a new top of stack
I
n+1
:....
;must not be an instruction popping operands
;from the system stack
I
n+2
:....
;must not be an instruction popping operands
;from the system stack
I
n+3
:RETP R0
;return from subroutine and pop word value from
;new top of stack into R0
Most of the potential conflicts, if a change of SP value is immediately followed by a
writing to the stack (instructions PUSH, CALL, SCXT, TRAP) are solved internally by
CPU logic. The only exceptions are CALLS and PCALL instructions, which require one
preceding instruction not using updated SP, as shown below:
I
n
:MOV SP,#0FA40H
;select a new top of stack
I
n+1
:....
;must not be an instruction using
;the new address of system stack
I
n+2
:PCALL R3,sub_addr ;push R3 value and return address at the new
;top of stack and call subroutine
Содержание C166S V1 SubSystem
Страница 10: ...User s Manual C166S V1 SubSystem User s Manual I 6 V 1 6 2001 08...
Страница 16: ...User s Manual C166S V1 SubSystem Introduction User s Manual 1 6 V 1 6 2001 08...
Страница 126: ...User s Manual C166S V1 SubSystem Central Processing Unit User s Manual 3 96 V 1 6 2001 08...
Страница 178: ...User s Manual C166S V1 SubSystem Memory Organization User s Manual 4 52 V 1 6 2001 08...
Страница 206: ...User s Manual C166S V1 SubSystem Instruction Set User s Manual 5 28 V 1 6 2001 08...
Страница 306: ...User s Manual C166S V1 SubSystem Detailed Instruction Set User s Manual 6 100 V 1 6 2001 08...
Страница 362: ...User s Manual C166S V1 SubSystem The External Bus Interface User s Manual 8 40 V 1 6 2001 08...
Страница 452: ...User s Manual C166S V1 SubSystem General Purpose Timer Unit User s Manual 12 44 V 1 6 2001 08...
Страница 454: ...User s Manual C166S V1 SubSystem Instruction Index User s Manual 13 2 V 1 6 2001 08...
Страница 459: ......