0% found this document useful (0 votes)
33 views18 pages

Chapter 2

The document contains assembly language code with instructions like LDI, ADD, SUB, MOV, INC, and DEC. It loads values into registers, performs arithmetic operations by adding and subtracting register values, and moves data between registers. The code examples demonstrate how to use assembly language instructions to manipulate data in registers and perform basic arithmetic.

Uploaded by

Hadi Sleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views18 pages

Chapter 2

The document contains assembly language code with instructions like LDI, ADD, SUB, MOV, INC, and DEC. It loads values into registers, performs arithmetic operations by adding and subtracting register values, and moves data between registers. The code examples demonstrate how to use assembly language instructions to manipulate data in registers and perform basic arithmetic.

Uploaded by

Hadi Sleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

chop② :

AUR Architect
and
Assembly longnose
program,
GPI

R3fy
3g Registers : Ro -

Rs : 8 bits ✓

IDI Lool Immediate

LDIRol.hr#=sRol=hr
✓ : 8 bits =)
0000 oooo I T f 1111 1111

OX 00 4 f X FF
f
o

o E hr 255
f

161 ol f 31

I : LD I RIG , I

= , RIG = I =) RIG = 0000 0001

LD I RIP ,
0113A

⇒ RIP = 0×38 = 0011 tooo

L DI R2 o
,
ox 125 ⇒ X
-

> 8 bit
>
0×255
>
255
DI RIO
L
, 5 =3 X
T

162015131
ADD "
-

ADD Rot

AS
,

⇒ Rot = Rot t Rs

A : ADD R4
,
R2 's

⇒ R2 , = RL , t R2 3

write to add 5 to
⇐ on assembly program
37 and store the result in R2 o

SI : L DI RIO
,
5 ; ⇒ R 20=5

LD I R 16 37 i ⇒ RIG : 37
,

ADD RIO R 16
,

SUB :
-

SUB Rot , Rs

⇒ Rot = Rot -
RS

Trace the
E program
LDI RIG 20
,

LD I R 17
, 4
SUB RIG , RH

soy ① R 16=20

② R 17=4
RIG R 17
③ RIG
-

= 16
= 20 -

4
MoU "
-

Mov Rot ,
RS

⇒ Rot = Rs

e write on osvnbly program to subtnt 4 from


17 and store the result in RL
,

Soy LD I R 16 ,
4
LD I RH , 17

RI 't R 16
SUB ,

Mov
Rly Rtt
,

INI : Incat

INC Rot =) Rot =


Rotted

L
⇐ DI R 17,4 ; R 17--9
INC R It j R 17=5

DEI :
Dent

DEC Rot ⇒ Rot = Rd -


2

Come : Complement

Com Rot ⇒ Rot = Rot


E L DI RIG ,
0412

Com R 16
① =) RIG = 0×12=0002 0010

COM
② RIG =) RIG : RIT = 0×12

= 1110
1101
⇒ RIG : OX ED

NEI :
Negotiate
NEG Rot ⇒ Role -

Rot
= RI t I

⇐ LDI RIO ,
0×53

NEG RIO

R2o= ?

soy ① R2u= 0×53=010/0011


RIT t t
② R2o= Redo :
-

R2o : 0101 0011

RIO :
1010 1100

RIO tl : 1010 1101

=3 RIO = 10 to
1101
=
OX AD
AVR outa memory
-

outa RAM
memory :

Rum
Cook
nervy
i

X 000

?
O

Resists
o X o I F R 31

0×20
I/o merry special function registers

( SFR ) ( will be seen btw )
OXSF
0×60
Intent RAM

( GPR AAM )

OX FFF

ohh
LDL : Lord fun -

spoon newry

cos R " RAM

.
n

Rot I
Store into ohh
STI :
nervy space

STS hi Rs

rise
,

I add the Content of the


newly locution ox zoo

to He Contents
of the boutin ox
newry 400

and store the result in ox Soo

Self LDS RIO


,
o X 300

LDS Rtl , o X 400

ADD RIO ,
RH
I

STS 0×500 RIO


,
ohh relieve
real Oubley
o X I O
o X 00

IN and out
-

/
0×20

I/o
merry
o x SF

OX 5 F o X 3 F

relive oohing = real whims -


ox do

IN ⇐ LDS

IN Rot ,
relieve odds .

-
) OUT ⇒ STS

ou T tubtiue odds ,
Rs
redoubles RAM attire why

::F÷÷
0×3

Ei : R6 ← PINB

① LDS RIG
,
0×23

② IN RIG ,
0×3

③ IN RIG ,
PINB

Rtt → PORTS

① STS 0×25 ,
RI 't

0×5 RI 't
② OUT ,

out PORTB OR 17
③ ,
the Content of Pine to PORTB
Ey move

soy IN ,R to ,
P INC

OUT PORTB , R to

INVsL#ouTVs
① IN '
-
2 Bytes
LDS :
4 Bytes

when we use IN ( out ) we will
use less in the Cole
nervy C Rum )
space
② In ( out
) needs less clock cycles

then Las ( STs )

③ we con we money when we be

IN ( out )
Stotts register
-

7 6 S 4 3 2 I 0

I T H S V W 2 C

no
long
worry I
c : :

be
we
Guy
lost result is not zen
To
:

2 : Zone .

↳ I .

.
11 11 is Zeke

'

I I is not Neytue
To
-
' I

N : Neyfve
Y 2
'

.
11 11 is Negative
we don't heowfbw
ctocppo
:

v : overflow =

be
is s : we
oufbw
rterslti positive
go
:
s :
Sign = N to ✓

\
) 2
'

.
II it 11 Negative .


0111¥
H :
Holf long .

.

Ii setup ,

T :
Copy for a bit
⇐ wht 's the uke of the stilts register if we why

X Sc to 0×64

←n
o
pH
c
p
-

④ ① I

soy ox 9C lool 1100

it
i
.

011 ol 00
OX 6L ,
i o

C
-

- I
I a
zero ⇒ 2=2
N
H = I

V -

-
C
① Cp = I ⑤ I = o

s V ⑦ N ⑤

Ins
O
-

= -
°

N 2 C

⇒ Notes agile o o I o o 0 I I

=
ox 23

Dotefornt

front
St of the mbe
Heli ox or in

LDE Rtb ,
OX 13

0001 0011
=) RIG =
0×13 =

Mbr
binny ob in front of the .

LD I R 16 ,
ob lol o ol ol
-

⇒ RIG = to to 0101
= ox AS
decimal 't wit th
front
we own in
omg .g
:

of the wise

LD I R 16 to
,

=) RIG = to = 0000 to to
= OX u A

AS '

'

" "
< be R 23
,
2


R2 3 =
ite Asci .
Cole of the

Chono Ite 32
.
2 : o x

Directives :
-

.co#:Eqw1e..E0nuEent--ox2S

:
:

L DI R2 I
,
but

SEI : Sin .hn to -

Eon in but tte

Vole toter
on be
reassigned
while when eau Ween 't
wig
.

the value
Sorge .
.

Ort origin
we tell the one she where to store the
instructor the Rom
meet in progun
. OR G O X I 00

I 2

I 2
. o R L O X 200

I 3

:
pconoltleprg-nmpc.pro
cont odours net risk Am
pm of
-

to acute -

instructors
if to
prawn is electing the

of odds of to⇒ p c =
odds of Izz

in Aur each lock-on in the Rum is 2


byts that
.
-

IF
olds 225 if 16 bit ←

Rom

the me
size of Pc = 22 bit
"
⇒ me
supported Rom =
2 look on

= 2£ 220 locka
-

4 M ( 2 Bytsl
= 8 M Bytes .
lots in the Ron
program

-
.

IDI :

LD I Rd
KL
,

8 bit litho Wsbk hrshrzbrihr


'

I 6.
fol
E 31

01301201 do = ol -

16
,

R④
E Wile LD I 0×31 in Her .

'otsKg
4th Kshb 's ko
Sd ) hr : o X 31 = 0011 000 I

01301201 , ol .
=
ol -
16 = 18 -
16=2
= 0010


o X E 3 21
Ey wit Lns RIG ox 25 nitty
,

0101
Soy hr = 0/125 = 0010

01301201 , do 16 -
16=0 = oooo
=

1110 0010 oooo ol ol

=) ox EL 05

ADI : ADD Rot Ra


,

t.EE#
-
⇐ wite ADD RIB ,
RIP in Her .

Sey ol = 16 =
01401301201 , do

0010C
000€
oil
pl
=

r = If = 24 rgrzr ,
no

= I

⇒ oxo F O 2
STS

wite
Kr
I.ie:447 , R②
-

E in Her STS OX 300 , R3

N =3 =3 24
SMJ rzrzr.ir = u
: ,

hr =
OX 300 = 0000 O OIL Oooo oooo

1001 0010 0011 0000


0000 U u 11 0000 oooo

⇒ ox 9230
OX O 300

i'
'
Ii

I wite in Her LDS Rho 011200


,

01=20
Soy

I
=3 01401301201 do ,
:

0001
hr =
0000 00/0 0000 0000

=3 1001 0100 0000

0000 O o ( O 0000 Oooo

=3 OX SIL ,
o

OA O 2 0 O
k

IN Rot relttue why


the :
,

.io#bT-sAsaAoreltveoobhy:AsAhAsAzAiAo

ol : 014 01301201 do
,

E wite in Her ,
IN RIO PINB
,

PINB : others : O X 23

reltiucoolb : ox 3

toooo
my
=3 As Ah Az AZA ,
Au = Oo 0011

01=10 =3 01401301201 ,
ol
,
=
O 1010

⇒ ox Bo A 3

out out
nellie , R2

isn't

You might also like