DIVXU (DIVide eXtend as Unsigned)
DIVXU
<Note: DIVXU Overflow>
Since the DIVXU instruction performs 16-bit ÷ 8-bit
→
8-bit division, an overflow will occur
if the divisor byte is equal to or less than the upper byte of the dividend. For example, H'FFFF
÷ H'01
→
H'FFFF causes an overflow. (The quotient has more than 8 bits.)
Overflows can be avoided by using a subprogram like the following. A work register is
required.
R0L
Divisor
R1
Dividend
R1
Remainder
Quotient
(*1)
R1
R2
H'00
Dividend (High)
(*2)
R1
Partial remainder
Dividend (Low)
R2
R1
R2
(*4)
Dividend
Partial remainder
Quotient(High)
Remainder
Quotient (Low)
Quotient
(*3)
DIVXU R0L, R1:
MOV.B #H'00, R2H
CMP.B R0L, R1H
BCC L1
DIVXU R0L, R1
(*1)
MOV.B R1L, R2L
BRA L2
L1
MOV.B R1H, R2L
(*2)
DIVXU R0L, R2
MOV.B R2H, R1H
(*3)
DIVXU R0L, R1
MOV.B R2L, R2H
MOV.B R1L, R2L
L2
RTS
(*4)
To perform
75
Содержание H8/300 Series
Страница 2: ...H8 300 Programming Manual...