embedded system lect6
TRANSCRIPT
-
8/18/2019 Embedded System Lect6
1/26
Embedded System
Spring, 2011
Lecture 6: Branch, Call and Time Delay Loop
Eng. Wazen M. Shair
-
8/18/2019 Embedded System Lect6
2/26
2IUG- Embedded System
Today’s Lecture
Branch in!truction! and looping
-
8/18/2019 Embedded System Lect6
3/26
3
Branch in!truction! and looping
Looping in "#C
Loop in!ide loop
$ther conditional %ump!
&ll conditional ranche! are !hort %ump! Calculating the !hort ranch addre!!
'nconditional ranch in!truction
-
8/18/2019 Embedded System Lect6
4/26
4
Looping in "#C
(epeat a !e)uence o* in!truction! or a certain
numer o* time!
T+o +ay! to do looping
'!ing DECS- in!truction '!ing B-/B- in!truction!
-
8/18/2019 Embedded System Lect6
5/26
5
DECS- in!truction
Decrement *ile regi!ter, !0ip the ne1t in!truction i*
the re!ult i! e)ual 2
DECS- *ile(e*, d
3$T$ in!truction *ollo+! DECS-
-
8/18/2019 Embedded System Lect6
6/26
6
-
8/18/2019 Embedded System Lect6
7/26
7
E1ample
Write a program to
a4 Clear W(E3
4 &dd 5 to W(E3 ten time! and place the
re!ult in S( "$(TB
-
8/18/2019 Embedded System Lect6
8/26
8
Solution
C$'T EQU 217
MOVL d8928
MOV! C$'T
MOVL 2 &3 "##L 5
#E$!S% C$'T,
&OTO &3MOV! "$(TB
-
8/18/2019 Embedded System Lect6
9/26
9
Solution
-
8/18/2019 Embedded System Lect6
10/26
10
'!ing B-/B- in!truction!
Supported y "#C9 *amilie!
Early *amilie! !uch a! "#C96 and "#C9 doe!n;t
!upport the!e in!truction
The!e in!truction! chec0 the !tatu! *lag
Bac0
-
8/18/2019 Embedded System Lect6
11/26
11
E1ample
Write a program to
a4 Clear W(E3
4 &dd 5 to W(E3 ten time! and placethe re!ult in S( "$(TB
-
8/18/2019 Embedded System Lect6
12/26
12
Solution
C$'T EQU 217
MOVL d8928MOV! C$'T
MOVL 2 &3 "##L 5
#E$! C$'T,
'(% &3MOV! "$(TB
-
8/18/2019 Embedded System Lect6
13/26
13
Solution
-
8/18/2019 Embedded System Lect6
14/26
14
E1ample
What i! the ma1imum numer o* time! that
the loop can e repeated=
&ll location! in the ile(eg are >it
The ma1. loop !ize i! 77 time
-
8/18/2019 Embedded System Lect6
15/26
15
Loop in!ide a loop
Write a program to
a4 Load the "$(TB S( regi!ter +ith the ?alue 77@
4 Complement "$(TB )00 time!
Solution(9 EQU 217
( EQU 216
C$'TA9 EQU d8928
C$'TA EQU d828
*+1
-
8/18/2019 Embedded System Lect6
16/26
16
Solution
MOVL 2177
MOV! "$(TB
MOVL C$'TA9
MOV! (9
L$"A9 MOVL C$'TA
MOV! (
L$"A $OM-! "$(TB,
DECF R2, F
BNZ LOP_2
DECF R1, F
BNZ LOP_1
Address Data
25H
(R1) 10
26H
(R2) 70
…
…
F81H(PO
RTB) 55
-
8/18/2019 Embedded System Lect6
17/26
17
Looping 922,22o time!
Becau!e t+o regi!ter! gi?e u! a ma1imum
?alue o* 6727, +e can u!e three regi!ter!
to get up to more 96 million iteration!
-
8/18/2019 Embedded System Lect6
18/26
18
-
8/18/2019 Embedded System Lect6
19/26
19
$ther conditional %ump!
-
8/18/2019 Embedded System Lect6
20/26
20
B- Branch i* -94
The - *lag i! chec0ed #* it high it %ump! to the target addre!!.
or e1ample
$E( "$(TB, W F- $E(
#n thi! e1ample , i* "$(TB i! zero, it %umpe to the
lael $E(
-
8/18/2019 Embedded System Lect6
21/26
21
E1ample 5>7
Write a program to determine i* the loc. 2152
contain! the ?alue 2. i* !o, put 77@ in it.
Solution:
M.LO$ EG' $152MOV! MHL$C,
'(% EIT
MOVL 2177
MOV! MHL$CEIT ...
-
8/18/2019 Embedded System Lect6
22/26
22
BC ranch i* no carry4
The carry *lag it in the !tatu! regi!ter i! u!ed toma0e the deci!ion +hether to %ump.
#* it c24, the C"' !tart! to *etch and e1ecute
in!truction! *rom the addre!! o* the lael.
#* it c94, the C"' +ill e1ecute the in!truction elo+BC
-
8/18/2019 Embedded System Lect6
23/26
23
E1ample
ind the !um o* the ?alue! J@, 7@, andE@. "ut the !um in *ile(eg loc. 7@ and
6@.
-
8/18/2019 Embedded System Lect6
24/26
24
-
8/18/2019 Embedded System Lect6
25/26
25
Guiz
-
8/18/2019 Embedded System Lect6
26/26
26IUG- Embedded System 26
(e*erence!
Fie @u , ECE6J Emedded ComputingSy!tem! , all 292.
PIC Microcontroller And Embedded Systems:
using Assembly and C for PIC 18 , M. Mazidi, (.
McKinlay and D. Cau!ey, "rentice all, 22.
Eng. @u!am &lza), Embedded System Course,
IUG, !1!