S3C4510B
INSTRUCTION SET
INSTRUCTION SET EXAMPLES
The following examples show ways in which the basic ARM7TDMI instructions can combine to give efficient
code. None of these methods saves a great deal of execution time (although they may save some), mostly they
just save code.
USING THE CONDITIONAL INSTRUCTIONS
Using Conditionals for Logical OR
CMP
BEQ
CMP
BEQ
Rn,#p
Label
Rm,#q
Label
; If Rn=p OR Rm=q THEN GOTO Label.
This can be replaced by
CMP
CMPNE
BEQ
Rn,#p
Rm,#q
Label
; If condition not satisfied try other test.
Absolute Value
TEQ
Rn,#0
; Test sign
RSBMI
Rn,Rn,#0
; and 2's complement if necessary.
Multiplication by 4, 5 or 6 (Run Time)
MOV
CMP
Rc,Ra,LSL#2
Rb,#5
; Multiply by 4,
; Test value,
ADDCS
ADDHI
Rc,Rc,Ra
Rc,Rc,Ra
; Complete multiply by 5,
; Complete multiply by 6.
Combining Discrete and Range Tests
TEQ
CMPNE
MOVLS
Rc,#127
Rc,# ” ”-1
Rc,# “”
; Discrete test,
; Range test
; IF Rc<= ”” OR Rc=ASCII(127)
; THEN Rc:= ” ”
3-59