
C165H
System Programming
Data Sheet
435
2001-04-19
PRELMNARY
multiple bit shift instructions. This provides similar performance compared to instructions
directly supporting BCD data types, while no additional hardware is required.
-EXCERPT-
division. The old MDC contents must be popped from the stack before the RETI
instruction is executed.
For a division the user must first move the dividend into the MD register. If a 16/16-bit
division is specified, only the low portion of register MD must be loaded. The result is also
while the high portion (MDH) contains the remainder.
The following instruction sequence performs a 32 by 16-bit division:
MOV
MOV
DIV
JMPR
MOV
MOV
MDH, R1
MDL, R2
R3
cc_V, ERROR
R3, MDH
R4, MDL
;Move dividend to MD register. Sets MDRIU
;Move low portion to MD
;Divide 32/16 signed, R3 holds divisor
;Test for divide overflow
;Move remainder to R3
;Move integer result to R4. Clears MDRIU
Whenever a multiply or divide instruction is interrupted while in progress, the address of
the interrupted instruction is pushed onto the stack and the MULIP flag in the PSW of the
interrupting routine is set. When the interrupt routine is exited with the RETI instruction,
this bit is implicitly tested before the old PSW is popped from the stack. If MULIP=’1’ the
multiply/divide instruction is re-read from the location popped from the stack (return
address) and will be completed after the RETI instruction has been executed.
Note:
The MULIP flag is part of the
context of the interrupted task
. When the
interrupting routine does not return to the interrupted task (eg. scheduler switches
to another task) the MULIP flag must be set or cleared according to the context of
the task that is switched to.
BCD Calculations
No direct support for BCD calculations is provided in the C165H. BCD calculations are
performed by converting BCD data to binary data, performing the desired calculations
using standard data types, and converting the result back to BCD data. Due to the
enhanced performance of division instructions binary data is quickly converted to BCD
data through division by 10
D
. Conversion from BCD data to binary data is enhanced by
20.1
Stack Operations
The C165H supports two types of stacks. The system stack is used implicitly by the
controller and is located in the internal RAM. The user stack provides stack access to the
user in either the internal or external memory. Both stack types grow from high memory
addresses to low memory addresses.