You are on page 1of 11

3.

a) SMALLEST OR LARGEST NUMBER IN AN ARRAY Aim: To write an 8085 assembly language program that finds the smallest (or largest number in an array and execute the program using microprocessor kit. Apparatus required: 8085 Microprocessor kit !ower supply Al !rit"m: Smallest number in an array "tep #: "tep (: "tep +: "tep ,: "tep 5: "tep .: "tep1: "tep 8: Mem!r# L!$ati!% ,#00 ,#0+ ,#0, ,#05 ,#0. ,#01 ,#08 ,#0: ,#06 ,#02 ,#09 ,### ,##( $nitiali%e &' register pair with a memory pointer. )et the count to * register and decrement the count. $ncrement the memory pointer Mo-e contents of memory pointer to accumulator. $ncrement memory pointer and compare the contents with accumulator. $f carry won/t result mo-e the contents of memory pointer to 0ccumulator 2ecrement the count $f count becomes %ero increment the memory pointer and store contents of accumulator to that memory location. Ma$"i%e La&el M%em!%i$s '!mme%t $!de (# 00 ,( ,. 05 (+ 19 (+ *9 20 02 ,# 19 05 6( 01 ,# (+ 11 '3$ & ,(00 $nitiali%e &' register pair with a memory pointer M45 * M Transfer the count to * register 267 * $83 & M45 0 M
'44!( $83 &

2ecrement * register $ncrement memory pointer )et first number to accumulator $ncrement memory pointer 6ompare the contents of memory location with accumulator Mo-e <M= to accumulator 2ecrement the count

6M! M ;6

'44!# $f <0=><M= go to '44!#

M45 0 M '44!# 267 *

;8? '44!( $f <*= is not e@ual to %ero go to '44! ( $83 & $ncrement memory pointer M45 M 0 Mo-e the smallest number to memory location

,##+

1.

&'T

9nd execution

Sample i%put a%d !utput: 2ataset # Memory location 2ata

2ataset ( Memory location 2ata

Largest number in an array "tep #: "tep (: "tep +: "tep ,: "tep 5: "tep .: "tep1: "tep 8: $nitiali%e &' register pair with a memory pointer. )et the count to * register and decrement the count. $ncrement the memory pointer Mo-e contents of memory pointer to accumulator. $ncrement memory pointer and compare contents with accumulator. $f carry results mo-e the contents of memory pointer to 0ccumulator 2ecrement the count $f count becomes %ero increment the memory pointer and store contents of accumulator to that memory location

Mem!r# L!$ati!%

Ma$"i%e $!de La&el M%em!%i$s

'!mme%t

,#00 ,#0+ ,#0, ,#05 ,#0. ,#01 ,#08 ,#0: ,#06 ,#02 ,#09 ,### ,##( ,##+

(# 00 ,( ,. 05 (+ 19 (+ *9 20 02 ,# 19 05 6( 01 ,# (+ 11 1.

'3$ & ,(00 $nitiali%e &' register pair with a memory pointer M45 * M Transfer the count to * register 267 * $83 & M45 0 M $83 & 6M! M 2ecrement * register $ncrement memory pointer )et first number to accumulator $ncrement memory pointer 6ompare the contents of memory location with accumulator Mo-e <M= to accumulator 2ecrement the count $f <*= is not e@ual to %ero go to '44! ( $ncrement memory pointer

;86 '44!# $f <0=A<M= go to '44!# M45 0 M '44!# 267 * ;8? '44!( $83 &

M45 M 0 Mo-e the smallest number to memory location &'T 9nd execution

Sample i%put a%d !utput Mem!r# L!$ati!% (ata

Result: Thus an 8085 assembly language program that finds the smallest (or largest number in an array was written and executed using microprocessor kit.

bB SORTING O) NUMBERS IN AN ARRAY AIM: To write an 8085 assembly language program that sorts the gi-en array in ascending order (or descending orderB and execute the program using microprocessor kit. Apparatus required: 8085 Microprocessor kit !ower supply

Al !rit"m As$e%di% !rder "tep #: "tep (: "tep +: "tep ,: "tep 5: "tep .: "tep 1: "tep 8: "tep :: su&r!uti%e: "tep #: "tep (: "tep +: "tep ,: "tep 5: Mo-e the contents of memory location to accumulator. $ncrement memory pointer and compare it with the contents of accumulator. $f carry does not exist swap the contents of accumulator and memory pointer. 2ecrement the count if count is not %ero go to step (. 9lse return to main program. $nitiali%e &' register pair as memory pointer. )et the count and decrement it. $ncrement memory pointer !ush the memory location and the count to stack pointer. 6all subroutine. )et the count and memory location from stack pointer. Mo-e the contents of accumulator to memory location 2ecrement the count if it is not %ero go to step +. 9lse end the execution

Mem!r# L!$ati!% ,#00 ,#0+ ,#0, ,#05 ,#0. ,#01 ,#08 ,#0* ,#06 ,#02 ,#09 ,##D ,##(

Ma$"i%e $!de (# 00 ,( ,. 05 (+ 95 65 62 #+ ,# 6# 9# 11 05 6( 05 ,# 1.

La&el M%em!%i$s '3$ & ,(00 M45 * M 267 * '44!# $83 & !C"& & !C"& * 60'' !4! * !4! & "ub

'!mme%t $nitiali%e &' register pair with a memory pointer Transfer the count to * register 2ecrement * register $ncrement memory pointer !ush the contents of &' register pair to stack pointer !ush the contents of * register to stack pointer 6all subroutine to find the smallest number 7etrie-e the contents of * from stack 7etrie-e the contents of &' register pair from stack Mo-e the smallest number to memory location 2ecrement register *

M45 M 0 267 *

;8? '44! # $f <*= is not e@ual to %ero go to '44! # &'T 9nd execution

"C*74CT$89 Mem!r# L!$ati!% ,##+ ,##, ,##5 ,##. ,##: ,##0 ,##* ,##6 ,##2 ,#(0 Ma$"i%e $!de La&el 19 (+ *9 2( #6 ,# 5. 11 10 05 6(* +,* ,# 6: M%em!%i$s '!mme%t M45 0 M Transfer the contents of memory location to accumulator '44! ( $83 & 6M! M ;6 $ncrement memory pointer 6ompare the contents of memory location with accumulator

'44!# $f <0=><M= go to '44!#

M45 2 M Mo-e <M= to 2 register M45 M 0 Mo-e the contents of accumulator to memory location M45 0 2 Mo-e the <2= to accumulator '44!# 267 * 2ecrement count $f <* is not e@ual to %ero go to '44! ( 7eturn to main program ;8? '44!( 79T

. Sample i%put a%d !utput Mem!r# L!$ati!% (ata

(es$e%di% !rder: "tep #: "tep (: "tep +: "tep ,: "tep 5: "tep .: "tep 1: "tep 8: "tep :: su&r!uti%e: "tep #: "tep (: "tep +: "tep ,: "tep 5: Mo-e the contents of memory location to accumulator. $ncrement memory pointer and compare it with the contents of accumulator. $f carry exists swap the contents of accumulator and memory pointer. 2ecrement the count if count is not %ero go to step (. 9lse return to main program $nitiali%e &' register pair as memory pointer. )et the count and decrement it. $ncrement memory pointer !ush the memory location and the count to stack pointer. 6all subroutine. )et the count and memory location from stack pointer. Mo-e the contents of accumulator to memory location 2ecrement the count if it is not %ero go to step +. 9lse end the execution

Mem!r# L!$ati!% ,#00 ,#0+ ,#0, ,#05 ,#0. ,#01 ,#08 ,#0* ,#06

Ma$"i%e $!de (# 00 ,( ,. 05 (+ 95 65 62 #+ ,# 6# 9#

La&el M%em!%i$s '3$ & ,(00 M45 * M 267 * '44!# $83 & !C"& & !C"& * 60'' !4! * !4! & "ub

'!mme%t $nitiali%e &' register pair with a memory pointer Transfer the count to * register 2ecrement * register $ncrement memory pointer !ush the contents of &' register pair to stack pointer !ush the contents of * register to stack pointer 6all subroutine to find the smallest number 7etrie-e the contents of * from stack 7etrie-e the contents of &' register pair from stack

,#02 ,#09 ,##D ,##(

11 05 6( 05 ,# 1.

M45 M 0 267 *

Mo-e the smallest number to memory location 2ecrement register *

;8? '44! # $f <*= is not e@ual to %ero go to '44! # &'T 9nd execution

"C*74CT$89 Mem!r# L!$ati!% ,##+ ,##, ,##5 ,##. ,##: ,##0 ,##* ,##6 ,##2 ,#(0 Ma$"i%e $!de La&el 19 (+ *9 2( #6 ,# 5. 11 10 05 6(* +,* ,# 6: M%em!%i$s '!mme%t M45 0 M Transfer the contents of memory location to accumulator '44! ( $83 & 6M! M ;86 '44!# $ncrement memory pointer 6ompare the contents of memory location with accumulator $f <0=A<M= go to '44!#

M45 2 M Mo-e <M= to 2 register M45 M 0 Mo-e the contents of accumulator to memory location M45 0 2 Mo-e the <2= to accumulator '44!# 267 79T * 2ecrement count 7eturn to main program ;8? '44!( $f <* is not e@ual to %ero go to '44! (

Sample i%put a%d !utput Mem!r# L!$ati!% (ata

Result: Thus an 8085 assembly language program that sorts the gi-en array in ascending order (or descending orderB was written and executed using microprocessor kit.

$). BLO'- TRANS)ER

Aim: To Erite an assembly language that transfer a block of data from one set of memory locations to other set of locations and test the program using 8085 microprocessor kit. Apparatus required: 8085 Microprocessor kit !ower supply Al !rit"m: "tep #: $nitiali%e the count -alue.

"tep (: "tep +: "tep ,: "tep 5: "tep .: "tep 1: "tep 8:

$nitiali%e the source memory pointer. $nitiali%e the destination memory pointer. Mo-e the contents of source memory to accumulator. "tore the accumulator contents to destination memory location. $ncrement the source and the destination memory pointers. 2ecrement the count if count is not %ero go to step ,. 9lse stop.

Mem!r# L!$ati!% ,#00

Ma$"i%e $!de 0. 05

La&el M%em!%i$s '!mme%t M5$ * 05 $nitiali%e a count

,#0( ,#05

(# 00 ,( ## 00 ,+

'3$ & ,(00 $nitiali%e &' register pair as source memory pointer '3$ 2 ,+00 $nitiali%e 29 register pair as 2estination memory pointer

,#08 ,#0: ,#00 ,#0* ,#06 ,#02 ,##0

19 #( (+ #+ 05 6( 08 ,# 1.

'44! M45 0 M Mo-e the contents from source location to accumulator "T03 2 $83 & $83 2 267 &'T * "tore the contents of accumulator to destination location $ncrement memory pointer $ncrement 29 register pair 2ecrement the count 9nd execution

;8? '44! $ncrement memory pointer

$nput "ource location ,(00 ,(0# 2ata

4utput 2estination location ,+00 ,+0# 2ata

,(0+ ,(0, ,(05

,+0( ,+0+ ,+0,

Result: Thus an assembly language that transfer a block of data from one set of memory locations to other set of locations was written and tested using 8085 microprocessor kit. .uesti!%s a%d A%s/ers: #. 2efine: $nstruction cycle Machine cycle TFstate (. Ehat are 8085 interruptsG 2iscuss in detail. Eith suitable examples explain in detail about the following instructions a. "T03 2 b. '203 * c. "!&' d. !C"& * ,. Ehat is stack pointerG 5. 9xplain the steps in execution in 60'' instruction. 93976$"9 #. 0 block of data is stored in the memory locations from 3355& to 3350&. Transfer the data to locations 3380& to 3385 & in the re-erse order (. 2ata bytes are stored in memory locations from 3350 & to 335D&. To insert an additional fi-e data bytes it is necessary to shift the data string by fi-e memory locations. Erite a program to store the data string from 3355& to 33.,&. +. Erite a program to find the mode and median of a set of #0 numbers stored from location 33.0. +.

You might also like