he
what u he ue
working
o] þuh bnd po? MOv
Jollo the
A stack ü a inean data stxuwe
that MOL
dast in, Fiyat-ot ico) Prinble. 4t
u wed in vai ss CMP
aplicattev induding andros todl management, eroai on BLE
maim MUL
evalttovM, and tback trackiig algovíthmi. The
8ue
Oheratieu auouated with a štack
B.
(" PusH - Adda an elemMeut to the top the Btack
Mov
xo m the tob to tte Atack,
d oP - : Remove the eletment
EN
WovPing 9) PUsH INSIRVCTIO
{uaualy aled totþ) u in oemsnt to out Li
ihe stadk þornte
to the nexk emsty þoxction.
he
nted to by Bit
The new element u placed in the oaittovn boi
bit
He stak poindoA
WorEing 9
PopIN STRUCTON
by the stack poivdon
is D
Ihe elemet at the þoattí en pointed. to bit
aueemed. bo H
The stock þointo deoemented to point te the brevteur cleneat.
Exa
Example
the
8uppoie we hae an embty tack and we
ollouing opuations. Rand
1 PuSH 10.
Sinaement to -1to
> Plo ce 0 to boat!
m
>Relrteve oo jom pokition 1 bac
1 to 0. CoY
>Deoumt top jrom
num bey ond a toxe
l ubile an, ALP to ind doctoniat o givon
the qatt in 9cqulo'R3.
MDV RO, 45;
MOv RI +13
MOv Ra, RO ;
CMP RO,#1 ;
BLE END L00P;
MUL RI, RIR2
BUB Ro, Ra,tl3
B.fAcT0RIALLooP;
ov R3, RI
END
aLit bit Yevd loqical (nabyuc ion and eaplacn themy Apeuty
thels sange o) a ddes o r theae inalrucios.
Bit Devel logical inatruons opuate on the individual
data.
biu o biniy
AND!
D
oanda
.Eoch
a bituine AND open ation betwen two
Duyorms
the sewt u at to the CorY eponding bit in
bi in
I
D.
oþe and as4e 9heuhe
l
,it iu Aet to
bo
Examþle
h
and
.
B' Heatt in a bit uhee eah bit u the logical AND
A
D the cory eponding bit o A and B.
Ronqe:
apie to meguku memory lolations Rhcije d by
gptaity
ie iwfrudion
Putovm a bilwine De obgn ation bekuecn tuug ohoiands,
Eah bit in the 9u t ú 34 te at leas t he
bit in the obonond iu!
Correponding
UAually in owa negukou by memovy locationa degned by
he iuruction,
3xOR
orm bitue xOR oheaken bwen tuo ohnand -
Eah bit
a
in the sut u &t to I Hhe Coru nding
it
et
u.
po
opuondu ase diyennt "Dthuuite
bit in the
the
AxOR *B'll in a bit uheue eoch oit u
Dpeuatu
the
on
Coeupon ding
memoy
A ando.
Doti od ,
NOT
a bituie NDT DþeH ati en, tich invota ale bib o
ut u det to the opþoai te
the, obuand. bit in the
Each
bit in the
Nalue o) he
Correponding ,olporend
an be a
to a Single o þoon, uhth
TprCald appued Do Catiowu. RE
oY a mmbry to
by a Abecid
operand to the lt
shifu all bit
in Hhe
an dularded,'and
þoatios. Bit Buted out
mumber o poitiow.
at inte the vacated
Zuor ited loation and an immediate
involwe'a equkn memovy
Uaually
value.
to the uiqt by a sþer lied he
8hitu all bit in the
opoand o4
tut ane dixlan oled. The behaiox
PoRrkB. Bit hijted 1
the vacated biti depend Bn S em. te
Rotater all biu în the openond to the eyt by
numbe,)
4efntrodute
poaitten. Bia
en the
tht sit
8ROR
Rotala al bit in the opeand to the u ght by a speciliel
ase eintoduced he
aDiy brenttade betwen CALL and TUNP. Ex plan the kyba oj
CALLS and speuly the iange.
CALL nd JVMP (OY JMO)
9n auaemblg Aanguage pograamig,Hhe
aue inthulon utd o deting
in a bY 0qYam,
CALL JUMP
used to Call a Subs0utne. 9tDivetly txajuu Control te
Baves he adds
adrus o the next
iutrudion (the sesn adduu)eALL, it does not Rave the
Bn the stack bejore tyan fooning
byoutine.
Meusn ds.
ad
Control to the
|Alkeu euting the Aubroudine ,a Theie ú no Otomatic sehon
RET (Hekon) inutrucion u wedto He ovtgínal. loatton, a
Cncon d'ionl
jncton, Heuwing
4he iutution îmmediaty Dy Con dthitnal brancaing.
Bate
ng thu taLe
olla ui
ued to man aqe
ied Conditiernal, chd
Comnnguly
Code, ntvov ing miodudaty ond
rbduloasrky oye
hsu ontvol yow
ontvol opattons.
eue.
Ca iutrutieu
Thene aue
icol JNean tall
Tranlor londro
u
wu'h Same Regeut
demined by thd aize
. He olact witthin
el Fau Cade
a
TYant lu Control to
an ae any adduwable "oadiod in the memorH, a t
ivolea leg nant and et.
3txþlain fa addouing u'th examples
modes
Adbuuing odes au
techhique ued in alenmbly languag
Thy Pro lauoy
detoumine houw the proeu
hthe
þroqramndt'ng to aheiy the oboaud (dala) or the itrudey
ihatrutu
tdeout
the
mods
Opoand data. Hue su puw Comman adduuing
DTmediate Adduuing Mode
4u immediate adduung mode, Hhe Dhoand u shijied
The data is
oivecty in tHhe inetucion.
Example
6 inte egiuto Ax
immediat Value
Mov Ax, 5;Move the
Requtos Addbuu ing Mode
An icgitu addainq mode, the dpoand u oated in a keqütor,
The inu uctien Apei kes' the Hequtr uhe the ofoaan d it
txambu:
Hoy Ax,Bx Move Hhe vaue in aequta Bx inte egutu Hx
J Direc
'
Adduuing mode
ad doex u heked diveuy in the iutrudi
The oheanda'k addou
addun eau to o memory lo caion'chee He actual
adduted
data iu dved
Ex amplk: oy Ax, [123uh) ; Move the Value at Memory addun 34,h
inte the eguta fAk.
Tndiy et Addouuing
modle
a)
o odlduu b the opvond a held in,a autr.
Megutn. Ths iutructen
tont ains He the
Abeifie te gegut that
Dþeond,
Ex ample MOV AX [BxJ Move Hhe vale at the memoy addus
stored in Bx îMto Hqutin Ax.
JBvily aplain u sithmehie and loqrcar
twstrutin
8051.
e 5he li asthmete iutution o 8051
D ADD to the
Adds 4he Conkuta a aequta o oY mumovy location
aulator (A)
Exonnþlu: ADD.A, R
D SU BB
Subtroct the condeuti o a Pianutrmemovy oy lo tation and
the Cauy Nag jvom tu aeimulator.
txampu : BUB8. A,R2
Nultple the Contti o) a Megi kn oY rmumory oat'on
n B
he aulatov A and igh
bytt toved
4DIV -bit value iy
Di vtde hec' whiqned value in auumtatoy by the
n AAthe, umainn gkocd
he B aequto he aotient uxcol
in:the B'
Examle: DIv AB
The u D805/
logtal ttvuckion alnlaoy
:
AND LOqide Puorm a bithint AND obtuotien blw
he Aut in A,
the
toru
Qnd the owce vobuond then a
Exompl ANL A, #OFH
234h OR Logical a bituie De opnati on b|w thi aiunulto
and the ot
:Pogorn
opuand, then tovu the eutin A.
Exomiph ORL PI,A
RR: Ro t atea Hh bit o] th alumlat bY Dhe þouiien to tte
tigut
nRrtatu the bi4 o) the aumultoy bne poatHen to
uction
Tduti|y the adcwuinq mpde tor, he oa 8J
Exhlain thi inahudion and they 'addauuia RA
OR
N deaed addrusing Mode to the
Thi fntvuion nover a byte vom ktoid By
Hu adding theMU
Quumulatoy (A). The Bouce' adobs Mo
Content 0 acaumlatoy(A) ahd
the
he dala
data þofnt'([Link]
addoww a
NoC intyutien we
the Cade meahd 1 Ond the
DPTR.
o! "A and DPTR.
Aþuikcd au the Sum y the (onnta
WMOV B,H0FPH
tmediate Addouuing iode D
Ihüuinatrution move'thuimimediale value OFFH (a55 in duimal
inte Hegutn B. The iwmeoiate oddoun
) EN
the dala in Hhe natrui.
ing 9. modle direty hesies aE
Im 6UBB A, 45H &D5
Ihe
Dired adduui ng Mode
i inilrucion btyact the Contta o) the memory loadiêu usH diyu
Oynd Hh asoy Hag Yom thu aumlao(A)The add>ii 4SH diyecy H
ocatrsn, t
Heleyte an ittnal RAN Code
Extuhal lndiret Addouing Made.
Thu inetuti on movea om the alanal data memory
bte poided hane
a
to by the data (Dee) inte'Hhe'auumulatby 4). The MoVx ( ta thei
i wtd to aceu extvenal memoyy, and th addbe a Apeujcd 8h
indivecty thvough DPre. Rang
13it Addouing Mode pllo
Re intr uction leans the Cay tag cc). The bit addening
Exl
mode is ued to
divealy manbudate Aingle -bit lgs
Within the Apeial unon Requtsu (sFR). 8iq
iitudiom
8 uste an ALp to bYawe aa block )data om exkhal
RAN to Intonal RAM
Mov R0,t10H
the
adding the Mov DPIR,+ 3000H3
(oPre). The
Mov
Mov RI tooH;
oddruu Movy ,DPTR;
'
A
R.
INC DPTR
INCRI
DJNZ Ro,TRAN SFER -LOOP
in duima) END
The 8051 ubpor ta 2vaal type o jum inutrud'on ,
cach th
the
[Link] Hanje o) jump ivstuion typially oehudi om the
mode bnd the Aize D) te dabacament it Cai
daphcement
rMemory böided
Oddeeuing
handle Heu . the
the aumain
main yba og jum diom and itu
Moyx rittda heir ang.
Short Zum (s74p)
t1a bytu
kongei-198 te +1a?
om the addaus Hhe inituttan
pllouing 8JMP
in he 4ange
o8
Exblanatien:The SJHP Snatyution u wed
Helative
7TucheK H
Joy
to the
shoyt jumb
Cuunt progam
oPLode and the
& uith
Exambh 3JNP LABEL
Absolude Jumb (AJHP) Exorl
Ranqei Svo(u-t addsuu seng) LAL (long cas)
AJHP iwtrudon (an jump any addren
Ronqp 3Enre buk
to
bxplanation: he is
MuMoYu.T idtruction
tunt oKB þage ol Epiohaion: girmis
u thithe -bit addout
Obyte long with the ohode 'ond a
txanlui AJMP LABEL Examle
Ranqe: Enire bukB Code apae' ond Comunnd
tx plon ation; he LJNP inatYu dion an jump to oddws
wrthn the eutive
6LLKB Code apoe he g051,"44 a A,t# 65H
Moy
3-byte iutrutio; He opcode and A 46- bit adden,
Exompl: LJMP 9000H Ri,#&H
4 Con ditenal
Rang: -133te
Jumþs
192 byto
a mlu: TC,JNC, JZ,INZ,TB,JN
from the oddusn o)
B,J8)
inatmton plann
140V
CL A
DONZ Ri,CoM?L
DJNZ R0, Co MPL
the
tuCondiHonal JuNP.
834P
Elanatton. Condi Honal umþs dahend en peife condit onsdch woy e,t
au the atakua 4 the Cay ag (c),Zow tag (ž),oy bee 83uP CoMPLEM
bit in a Heqtr oY
ENO
Example :
JNC 1ABtL (oumþ
no Cuuy)
JZ LABtL ump alumuotoy iu zou)
JNZ LABtLJunm umlaoy u not Zuu)
JB Bn,ABEL CJum Bit ld)
UNB Bn,LABEL CJump ) Bit u not tu)
JBC BIT, LABEL Jump a Bit i let,then dear Bit)
5 Jumpto kubyoudíne (ACALL and LCALL)
ACALL Abaote Ca
kang: KB (i-bit, addeu ange)
dine iPhln
Exblanakon: 8imilan to AJMP, ACALL Con cal a BubYD
Ane cuunt avB þage.4+ ia a - byte inutvuon.
AcALL 80B ROUTINE
Exarnblu
LCALL (ong al)
Range Entre bukB Code þale
Exhlohaiow: 8inilan to LJMP,LAL (an Gel4 a BubYouttne ahyuhere
uh thu bukB Code ebae.44 u a 3- byte futsucion.
Examþle LOALL 80BROUTINE
1D Devlop ALP to load aumuiater with the Value s54
ound Lompument the Conthti o acumlatoy 900 time.
ORtG OH
Moy A,t 65H
Mov Ro,#3
MoV RI,+8LH
CPL A
DJNZ RlCOMPLEMENT -Loop
bJNZ RO, CO MPLEMENT- Loop-RELOAD
3JMP
Mov RI,+84H
8JuP CoMPLEMENT_LOOP
ENO