You are on page 1of 8

CODE CONVERSIONS

AIM: To write an 8085 assembly language program that executes the following conversions i) BCD TO B !"#$. ii) Binary to BCD iii) Binary to "%C iv) "%C to Binary "&&"#"T'% #()' #(D* 8085 microprocessor +it, &ower supply"./O# T01* BCD TO BINARY: %tep 2* nitiali3e stac+ pointer %tep 4* nitiali3e 0. register pair with a source pointer%tep 4* nitiali3e BC register pair with a 5estination pointer%tep 6* 1ove contents of memory pointer to accumulator%tep 7* Call subroutine BCD B !%tep 5* %tore the content of "ccumulator in 5estination pointer%tep 8* (n5 of execution%'B#O'T !(* 2- &ush the content of BC 9 D( register pair to stac+ pointer4- .ogically "!D the number 0: with accumulator to get .%B 6- "gain logically "!D the number :0with accumulator an5 rotate the content to the right four times to get 1%B 7- 1ultiply the 1%B with 0" an5 a55 with .%B

Memory Location 7200 7206 7208 720< 720" 720D 720(

Machine code 62,::,7: 42, 00, 74 02,00,76 =( CD, 0:,72 04 =8

Labe

Mnemonic! .; %&, 7::: .; 0, 7400 .; B 7600 1O> ",1 C".. BCD B! %T"; B 0.T

Comment nitiali3e stac+ pointer nitiali3e 0. register pair with a source pointer .oa5 BC register pair with 5estination pointer 1ove ?1@ to "ccumulator Call sub routine BCD B ! %tore the Binary number in the 5estination location (n5 of execution

%'B#O'T !( Memory Location 720: 7220 7222 7224 7227 7225 7228 7228 722B 722C Machine code C5 D5 7= (8,0: 7: =8 (8,:0 C",48,72 0: 0: Labe BCD B! Mnemonic! &'%0 B &'%0 D 1O> B," "! 0: 1O> C," 1O> ",B "! :0 AB BCD ##C ##C Comment &ush ?B C @ into stac+ pointer &ush ?D (@ into stac+ pointer 1ove ?"@ to B register "n5 imme5iate the accumulator with 0: 1ove?"@ to C register 1ove?B@ to "ccumulator "n5 imme5iate accumulator with :0 Aump on 3ero to BCD loop #otate accumulator content to right #otate accumulator content to right

722D 722( 722: 7240 7242 7246 7247 7245 7248 724< 724" 724B

0: 0: 5= ": 2(, 0" 86 25 C4,46,72 82 D2 C2 C<

##C ##C 1O> D," ;#" " 1> (, 0" "DD ( DC# D A!B %'1 "DD C &O& D &O& B #(T

%'1

BCD

#otate accumulator content to right #otate accumulator content to right 1ove ?"@ to D register Clear accumulator 1ove 0" to ( register "55 ( with accumulator content Decrement D registerAump on no 3ero to sum "55 C to accumulator #etrieve the content of D from stac+ #etrieve the content of B from stac+ #eturn to main program

b) Binary to BCD*C "lgorithm* %tep 2* nitiali3e stac+ pointer %tep 4* nitiali3e the register pair as memory pointer%tep 6* 1ove Binary number to accumulator %tep 7* Call subroutine 2 %tep 5*(n5 of the execution %'B#O'T !( 2* %tep 2* .oa5 0. register pair with 1& %tep 4* %tore 87h in B register%tep 6* Call subroutine 4%tep 7* %tore 0"h in B register 9 call subroutine4 %tep 5* %tore accumulator contents in next memory location %tep 8* #eturn to 1ain program%'B #O'T !( 4* %tep 2* Clear 1emory location %tep 4* %ubtract the B register from accumulator %tep 6* f the subtraction results a carry a55 B register content with accumulator an5 increment memory pointer%tep 7* return to subroutine2

Memory Location 7200 7206 7208 720= 720"

Machine code 62,::,7: 42, 00, 74 =( CD, 0B,72 =8

Labe

Mnemonic! .; %&, 7::: .; 0,7400 1O> ",1 C".. &D#T(! 0.T

Comment nitiali3e stac+ pointer nitiali3e 0. register pair with a source pointer 1ove ?1@ to "ccumulator Call sub routine &D#T(! (n5 the execution

%ubroutine 2 Memory Location 720B 720( 7220 7226 7225 7228 722< Machine code 42,00,76 08,87 CD,2",72 08,0" CD,2",72 == C< Labe Mnemonic! Comment .oa5 0. register pair with 7600 1ove 87h to B register Call subroutine B ! BCD 1ove 0" to B register Call subroutine B ! BCD 1ove?"@ to memory location #eturn to main program

&D#T(! .; 0, 7600 1> B,87 C".. B ! BCD 1> B,0" C".. B ! BCD 1O> 1," #(T %ubroutine 4

Memory Location 722" 722C 722D 722(

Machine code 68,:: 67 <0 D4, 2C, 72

Labe B! BCD !;TB':

Mnemonic! 1> 1, :: !# 1 %'B B A!C !;T

Comment 1ove ::h to memory location ncrement memory pointer %ubtract B from accumulator Aump on no carry to !;T

7242 7244

80 46

B': "DD B !; 0 #(T

B': "55 the content of B register with accumulator ncrement memory pointer #eturn to subroutine2

7246 C< c) Binary to "%C "./O# T01*

nitiali3e stac+ pointer nitiali3e register pair as source pointer nitiali3e D( register pair with 5estination pointer 1ove contents of memory pointer to accumulator %hift higher or5er nibble to lower or5er nibble by rotating the accumulator contents to right for 7 times Call subroutine %tore the converte5 number in memory location 7600 an5 7602 (n5 of execution %'B#O'T !( "n5 imme5iately the binary 5ata with 0:h 9 mas+ the higher or5er bit 9 store it in the accumulatorCompare the accumulator content with 0= f caryt results a55 60h to the number else a55 6=h to the number #eturn to main program Machine code 62,::,7: 42, 00, 74 22,00,76 =( 7= 0: Labe Mnemonic! .; %&, 7::: .; 0,7400 .; D 7600 1O> ",1 1O> B," ##C Comment nitiali3e stac+ pointer nitiali3e 0. register pair with a source pointer nitiali3e D( reg pair with 5estination pointer 1ove 1 to accumulator 1ove " to B register #otate the accumulator content to right

Memory Location 7200 7206 7208 720< 720" 720B

720C 720D 720( 720: 7224 7226 7227 7225 7228 722<

0: 0: 0: CD,2",72 24 26 =8 CD,2", 72 24 =8

##C ##C ##C C".. %'B %T"; D E !; D 1O> ",B C".. %'B %T"; D 0.T

#otate the accumulator content to right #otate the accumulator content to right #otate the accumulator content to right Call subroutine %'B %tore the first "%C value in 7600 ncrement memory pointer 1ove B to accumulator Call subroutine %'B %tore the secon5 "%C value in 7602 (n5 of execution

%'B#O'T !( Memory Location 722" 722C 722( 7242 7246 7245 Machine code (8,0: :(,0" D", 46, 72 C8,0= C8,60 C< Labe %'B Mnemonic! "! 0: C& 0" AC loop "D 0= "D 60 #(T Comment 1as+ higher or5er nibble Compare " with 0" Aump on carry loop "55 imme5iately 0= "55 imme5iately 60 with accumulator #eturn to main program

.oop

5- "%C to Binary "./O# T01* nitiali3e stac+ pointer nitiali3e register pair as source pointer nitiali3e D( register pair with 5estination pointer 1ove contents of memory pointer to accumulator Call subroutine %tore the result in 5estination a55ress (n5 of execution %'B#O'T !( %ubtract 60h from accumulator f the result is less that 0", return to main program (lse subtract 0=h from the result #eturn to main program Memory Location 7200 7206 7208 720< 720" 720D 720( Machine code 62,::,7: 42, 00, 74 22,00,76 =( CD,0:,72 24 =8 Labe Mnemonic! .; %&, 7::: .; 0,7400 .; D 7600 1O> ",1 C".. %'B %T"; D 0.T Comment nitiali3e stac+ pointer nitiali3e 0. register pair with a source pointer nitiali3e D( reg pair with 5estination pointer 1ove 1 to accumulator Call subroutine %'B %tore the result in 7600 (n5 of execution

%'B#O'T !( Memory Location Machine code Labe Mnemonic! Comment

720: 7222 7226 7227 7228

D8,60 :(,0" D8 C8,0= C<

%'B

%' 60 C& 0" #C %' 0= #(T

%ubtract 60h from accumulator Compare 0" with accumulator content 1ove the smallest number to memory location %ubtractiimme5iately 0= #eturn to main program

#esult* Thus the assembly language program for co5e conversion li+e BCD to binary, Binary to BCD, Binary to "%C an5 "%C to Binary were performe5-

You might also like