
User Manual
C166S V2
Central Processing Unit
User Manual
2-40
V 1.7, 2001-01
2.4.2
Local Register Bank
C166S V2 CPU has two local register banks with sixteen independent GPRs each. Both
local register banks are
not memory mapped
. After a switch to a local register bank, the
GPRs are directly accessible. There are two different ways to access an activated local
register bank.
Short 4-Bit GPR Addresses
(mnemonic: Rw or Rb) specify addresses in the local
register banks. The local register bank is selected by the
BANK
bitfield of the PSW.
Depending on whether a relative word (Rw) or byte (Rb) GPR address is specified, the
short 4-bit GPR address is either multiplied by two or not before it is used to physically
access the local register bank. Thus, both byte and word GPR accesses are possible in
this way.
Note: If GPRs are used as indirect address pointers, they are always accessed
wordwise.
For some instructions, only the first four GPRs can be used as indirect address pointers.
These GPRs are specified via short 2-bit GPR addresses. The respective physical
address calculation is identical with the one for the short 4-bit GPR addresses.
Short 8-Bit Register Addresses
(mnemonic: reg or bitoff) within a range from F0
H
to
FF
H
interpret the four least significant bits as short 4-bit GPR address, while the four
most significant bits are ignored. The respective physical GPR address calculation is
identical with the one for the short 4-bit GPR addresses. For single bit accesses on a
GPR, the GPR
’
s word address is calculated as just described, but the position of the bit
within the word is specified by a separate additional 4-bit value.
For a summary of all addressing modes usable to access GPRs, please see
Table 2-3
and
Table 2-4
.
2.4.3
Context Switch
An interrupt service routine or a task scheduler of an operating system usually saves into
the stack all the used registers and restores them before returning. The more registers
a routine uses, the more time is wasted with saving and restoring. There are two ways
to change a context in the C166S V2 core:
Switching the context by changing the selected register banks.
Switching the context of the global register bank by changing the context pointer CP.
2.4.3.1
Changing the selected Physical Register Bank
The switch between the three physical register banks is the fastest possible context
switch. It is possible to switch between the current memory-mapped GPR bank located
in the global register bank and the two not memory-mapped local register banks. The
BANK
bit field of the PSW register determines the selected bank.