INSTRUCTION SET
S3C2500B
3-60
Division and Remainder
A number of divide routines for specific applications are provided in source form as part of the ANSI C library
provided with the ARM Cross development toolkit, available from your supplier. A short general purpose divide
routine follows.
; Enter with numbers in Ra and Rb.
MOV
Rcnt,#1
; Bit to control the division.
Div1
CMP
Rb,#0x80000000
; Move Rb until greater than Ra.
CMPCC
Rb,Ra
MOVCC
Rb,Rb,ASL#1
MOVCC
Rcnt,Rcnt,ASL#1
BCC
Div1
MOV
Rc,#0
Div2
CMP
Ra,Rb
; Test for possible subtraction.
SUBCS
Ra,Ra,Rb
; Subtract if ok,
ADDCS
Rc,Rc,Rcnt
; Put relevant bit into result
MOVS
Rcnt,Rcnt,LSR#1
; Shift control bit
MOVNE
Rb,Rb,LSR#1
; Halve unless finished.
BNE
Div2
; Divide result in Rc, remainder in Ra.
Overflow Detection in the ARM9TDMI
1. Overflow in unsigned multiply with a 32-bit result
UMULL
Rd,Rt,Rm,Rn
; 3 to 6 cycles
TEQ
Rt,#0
; +1 cycle and a register
BNE
overflow
2. Overflow in signed multiply with a 32-bit result
SMULL
Rd,Rt,Rm,Rn
; 3 to 6 cycles
TEQ
Rt,Rd ASR#31
; +1 cycle and a register
BNE
overflow
3. Overflow in unsigned multiply accumulate with a 32 bit result
UMLAL
Rd,Rt,Rm,Rn
; 4 to 7 cycles
TEQ
Rt,#0
; +1 cycle and a register
BNE
overflow
4. Overflow in signed multiply accumulate with a 32 bit result
SMLAL
Rd,Rt,Rm,Rn
; 4 to 7 cycles
TEQ
Rt,Rd, ASR#31
; +1 cycle and a register
BNE
overflow
Содержание S3C2500B
Страница 2: ...S3C2500B 32 BIT RISC MICROPROCESSOR USER S MANUAL Revision 1 ...
Страница 17: ......
Страница 25: ......
Страница 80: ...PRODUCT OVERVIEW S3C2500B 1 46 NOTES ...
Страница 296: ...MEMORY CONTROLLER S3C2500B 5 60 NOTES ...
Страница 531: ...GDMA CONTROLLER S3C2500B 12 24 NOTES ...
Страница 593: ...I O PORTS S3C2500B 15 12 NOTES ...