C161U
System Programming
Preliminary Data Sheet
401
02.2000
PRELIMINARY
PRE
LI
M
INAR
Y
- E
XCE
RP
T
-
21
System Programming
To aid in software development, a number of features has been incorporated into the
instruction set of the C161U, including constructs for modularity, loops, and context
switching. In many cases commonly used instruction sequences have been simplified
while providing greater flexibility. The following programming features help to fully utilize
this instruction set.
Instructions Provided as Subsets of Instructions
In many cases, instructions found in other microcontrollers are provided as subsets of
more powerful instructions in the C161U. This allows the same functionality to be
provided while decreasing the hardware required and decreasing decode complexity. In
order to aid assembly programming, these instructions, familiar from other
microcontrollers, can be built in macros, thus providing the same names.
Directly Substitutable Instructions are instructions known from other microcontrollers
that can be replaced by the following instructions of the C161U:
Modification of System Flags is performed using bit set or bit clear instructions (BSET,
BCLR ). All bit and word instructions can access the PSW register, so no instructions like
CLEAR CARRY or ENABLE INTERRUPTS are required.
External Memory Data Access does not require special instructions to load data
pointers or explicitly load and store external data. The C161U provides a Von-Neumann
memory architecture and its on-chip hardware automatically detects accesses to internal
RAM, GPRs, and SFRs.
Multiplication and Division
Multiplication and division of words and double words is provided through multiple cycle
instructions implementing a Booth algorithm. Each instruction implicitly uses the 32-bit
register MD (MDL = lower 16 bits, MDH = upper 16 bits). The MDRIU flag (Multiply or
Divide Register In Use) in register MDC is set whenever either half of this register is
written to or when a multiply/divide instruction is started. It is cleared whenever the MDL
Substituted Instruction
C161U Instruction
Function
CLR
Rn
AND
Rn, #0
H
Clear register
CPLB
Bit
BMOVN
Bit, Bit
Complement bit
DEC
Rn
SUB
Rn, #1
H
Decrement register
INC
Rn
ADD
Rn, #1
H
Increment register
SWAPB
Rn
ROR
Rn, #8
H
Swap bytes within word