Samsung S3C2440A User Manual

Page 116

Advertising
background image

S3C2440A RISC MICROPROCESSOR

ARM INSTRUCTION SET

3-59

INSTRUCTION SET EXAMPLES

The following examples show ways in which the basic ARM920T 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

Rn,#p

; If Rn=p OR Rm=q THEN GOTO Label.

BEQ

Label

CMP

Rm,#q

BEQ

Label

This can be replaced by

CMP

Rn,#p

CMPNE

Rm,#q

; If condition not satisfied try other test.

BEQ

Label

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

Rc,Ra,LSL#2

; Multiply by 4,

CMP

Rb,#5

;

Test

value,

ADDCS

Rc,Rc,Ra

; Complete multiply by 5,

ADDHI

Rc,Rc,Ra

; Complete multiply by 6.

Combining Discrete and Range Tests

TEQ

Rc,#127

;

Discrete

test,

CMPNE

Rc,# " "-1

; Range test

MOVLS

Rc,# ""

; IF Rc<= "" OR Rc=ASCII(127)

;

THEN

Rc:=

"."

Advertising