0% found this document useful (0 votes)
6 views10 pages

Assembly Language Program for BCD Conversion

The document contains assembly language programs for various tasks, including converting packed BCD numbers to ASCII, adding numbers, and performing multiplication. It also explains branching instructions and their ranges, as well as directives like ORG and EQU. Additionally, it discusses data definitions and memory allocation in assembly language.
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)
6 views10 pages

Assembly Language Program for BCD Conversion

The document contains assembly language programs for various tasks, including converting packed BCD numbers to ASCII, adding numbers, and performing multiplication. It also explains branching instructions and their ranges, as well as directives like ORG and EQU. Additionally, it discusses data definitions and memory allocation in assembly language.
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

Q.

Jo
3(c)| e an ALP do inet a cpacked BCD umben nto boo ASCI)

Mov A, #29 ;4:0# packad 6co


MOV P5, A
-02 -
ANL A, #OFH
; Make an 4sc, A 394
MOV R6, 4 ; kave t (Rs 394 AScu cha)
MOV A ,R5
3A 944, qet thu Blghal data
NL A,#OF0H
RR A

RR A
RR A
RR A
ORL A, +30H 3 A 32H, Aseu. chan '9)
MOU R2, A
END
[Link] pocked BcD hu mba
sC, Oath an ALP 0 conyat A blnay Numke o
cbínany BcD umber
CAexaduimal lo daimal).he packed at 50h nd 5th
fntenol RAM loatin.

019 ooh
mov,dptr#40h
moV ofoh, t064
dfy a b
fnc dpt
mgVx dpti,a
mova, Dfoh
moV ofoh,# bah
dlvab;
Puc aptr
MOV X( dpt,a
u dptr
mov a, otoh
movx dptz,a
mp huae
end.
ALP to fnd conqatt
ot N numbt
Sol9: CoUNT
- (o mas ls
Equals 3oH Mem ovs locahon whee N(Qu)
i's sto td.
NUmGEps Aquals uoH
ResULT Equals sOH mlmo y locahon to store ae
Cngest number
Op oO0OH
i davt pam al memoy lotaha,bo od
STAPT: MOV Po, (oU(oad add ol (oONT :Mo Do
Mov A, lo ; load vale ok (oUNTato A
MOV D2, A
Coy to
MMOV R, Num8£Rs loads te add Numse ps
to
MOV A, QR
MON B, A

LooP:
Cinohaly Sngar
Po: nt to ne- number
MUV A, G loud 06l nD
CJNE A, B, CHE CK ; Compate A th B
8Jmp NEXT
CHECK' 4 Cvent no is Smaller Skp
Mov B, A
NEXT ! DJNZ 2e, LOop DecTement loop Counta R
peat
MOV A,B tte
Sangut number tate
MoV Do, PFSUT: Loucl tte add
RESOLT
FELSCTRONNCS MoV Clo, A
to Ro
Store tu
KLS VOIT Sangut LT

HALIYAL.
END
END
prgs.
lerite an ALp to add (6 b:t numbrss
Sfore
MSB to Lss - 10mar ks.

Soln: Assume (6 bit number CHiqh :loobyt)

Ruult wll be gtove d CMSA: Middle:

Con td:
MoV A, Ro load
ADD A, Ad
Mov Pu, A ) Store
Aceumul alo
Mov A, 4DoH j Cecas
tsom LSB Cud&nbon
JNC No. CAPeY; Jump no
ÎNC A to aceocat tor Ca
NO_CARY:
Mov A, R load MSB of s t no

Aopc A, Ra Ad 2 no T

MOv Rs, A, Stoy e middle byte oh AQetlo


MOV A, # och ) cleas a tor
JNC
cog
NO_ CALRy2 Jump t no
adl: hon.
îNC A ;
byteoc ment
No. CApey2:
MOV R6, A Shorc

ENO.
(sb) Niu au ALP to convet a packed BCD numbu íto tw o
AsCIT mlmbls tort tau reult in RS R6 Tipdivey
mov A # 29b
mov RS A
ANL AoFh

mov R6,A

ANL A,oFoh

RR
RR SWAR A.
RR A
D
A Depariment
Head of the
ORL A, 4306
mov R2, A
End
(4b) wt au ALP to convwt a Binay nunbu to pacted BeD lnencbu
ie ttortd at foh lo(atin
Thexa to deumal). Ttu binay nuRube
Ctot telocatian.
onvakd paskec' BcD Nunb at soh y sahitinal

ANL A oFb

mov Ai 40hb
A i# OF Dh
3Cc) trite to add two
on assembly (anguageR1 ROpronam
and R3R, Store the
(b lort numbers loaded io
esult in RG R5 and R4 from MSB to LSB

ORG oh
MOV + 20h
MOV # 30h
A
ADO
Mov
inc Ri
inc Ro
Mov
ADDC A (a Ro
Mov
MOV g«# #<
9
A

ADO C A 9

MoV
SJMP START
4Cc) rite an assembly language program to maltipy a
16 brt numbtrLoaded to Ri Ro (multipltcand ) oith an
8 bit numbty loaded in R2 Cmultiplier). StoYL the
resltant prodat in RG,R5 and R4 fYom MSB to L5B.

MOV DPTR, tt 1234 H


MOV B t 56 H
MOV Ra yB O 4M

MOV A DPL
MUL AB
MOV
MoV
MOV A 9 DPH
MOV B
MUL AB
ADD A
MOV o2M
Mov A, B
ADDC A ttoOH
MOV Re gA
END
D ite a note on branchinq instructrons defnina thelr
range
J UMP OPERAttON:
LJMP - long jump: The LJMP causes the progvom to
o2 ranch to a destination address defined by the 16- bit operand
in the jump nstruction. BeLause 1G bit address is used, the
instuctibn can ause a jump to any toatmn ithin the 64Byte
program space.
SIMP- Short jump: 5JMP uses a smqle by address
This ocddress is a siqned %bit numbeY ahd atto ws the
Lo2M4
Py °qram to bY anch to a distance (o -133) enge) and
Vito -la3) 9ronge
AJUMP - Absolute jump: AJMP uSes an 8bt destonatnon
addres, based on velative addresng twithm he range
of -12 8to t12 byte.
CALL OPERATION!
o2
M
LCALL - Lon Call i tCALL Tmstuction Ts und to Call
a suboutthe ct a specifted acldy. The oLdde s l6
ba long so the tall can be mode to cny tocation
Cithinthe 6KByte memovy space .
ACALL - Absolute Call: ACALL nstuctton is eeel to cal
a subYotne located at the specified addYLIS. Catls a
Subvoutine in the maximum adess range of ak Byte
ange.
RET- Retuun : The Petuun fom sub outme ts achieued
LUsmg the ReT instruettoo
4a) Define asenble diuive, with esam ple explan all tay ajebley
di utis pponted by gos1 miuocont olel.
e A serblu d i i e ateola to do someing
ella
fattion'
otel than cuating tae ma chine cocle fo toanfndicate tu
O ORG (oigin): Tu oRG dietive ie eLud
4ating cLddres. T cau be ded only cohen fhe -pg am
Cocud ea needs to be changed . The neimbu that Comes
aHea OeG cau be ethe in hex ade imal or in deimal.
9 oo00h 3 t PC to 0000
Ex
) fQU Coyuat) without oocup
Ttis diui'ue a eud tb dfe a coniaut
-ying a memouy docaton, Tu EQV diutie do. FQU
diuti dos not t andu ctora fura ttorage ter
etora q for data ikm but atocetel a cone teut
Nau with a data tabel eo that co eut t u label
in puogeam.
CoUNT EQU as
nov

ti) DBC ooi B-fu) u DB ciulive i kuud to defin an


S-6l data i cwluch intial zu memouy with 8-6it vauey
nenethel cuu bein de°mal, bihay: hexadecimal or
Tae foy 3' a fleu the deunal
in AscrT fovnals. hexadeunal.'o &
NUubu e oplio nal, but toy binauy y
CLe
PB 48 deim al
DATO 3
AsCII
DATA 4 : Ds'50 'Covona';
(iv) FD:

diuin
apprarf ofta yae ENDaHemblu,
file th
fext tn te areuoly ENDeatmut miing teu
tquoud . Tf e i
ik
wil geuuad to pacted BCD
nenbu

You might also like