assembly programs of 8085 microprocessor, there are many programs related to the computer architecture that will helpful for the programming in the assembly language. like addition of two 8bit number , subtraction, multiplication, division and table for 8085, array,etc ....
Also written all the proc...
assembly programs of 8085 microprocessor, there are many programs related to the computer architecture that will helpful for the programming in the assembly language. like addition of two 8bit number , subtraction, multiplication, division and table for 8085, array,etc ....
Also written all the procedure to write the programs in practical notebook for the practical exams in the colleges or universities.
Size: 964.63 KB
Language: en
Added: Nov 26, 2022
Slides: 29 pages
Slide Content
Assembly language programs
8085
8085 program to find maximum and
minimum of 10 numbers
In CMP instruction:
If Accumulator > Register then carry and zero
flags are reset
If Accumulator = Register then zero flag is set
If Accumulator < Register then carry flag is set
Assumption –List of numbers from 2050H to
2059H and output at 2060H and 2061H.
9/8/2022 7:34 AM 2
Program
2000H LXI H, 2050H
Load starting
address of list
2003H MOV B, M Store maximum
2004H MOV C, M Store minimum
2005H MVI D, 0AH
Counter for 10
elements
2007H LOOP MOV A, M
Retrieve list
element in
Accumulator
2008H CMP B
Compare element
with maximum
number
9/8/2022 7:34 AM 4
2009H JC MIN
Jump to MIN if not
maximum
200CH MOV B, A
Transfer contents
of A to B as A > B
200DH MIN CMP C
Compare element
with minimum
number
200EH JNC SKIP
Jump to SKIP if not
minimum
2011H MOV C, A
Transfer contents
of A to C if A <
minimum
2012H SKIP INX H Increment memory
9/8/2022 7:34 AM 5
2013H DCR D
Decrement
counter
2014H JNZ LOOP
Jump to LOOP if D
> 0
2017H LXI H, 2060H
Load address to
store maximum
201AH MOV M, B
Move maximum to
2060H
201BH INX H
Increment
memory
201CH MOV M, C
Move minimum to
2061H
201DH HLT Halt
9/8/2022 7:34 AM 6
SMALLEST NUMBER IN A DATA ARRAY
Algorithm
1)LoadtheaddressofthefirstelementofthearrayinHLpair
2)MovethecounttoB–reg.
3)Incrementthepointer
4)GetthefirstdatainA–reg.
5)Decrementthecount.
6)Incrementthepointer
7)ComparethecontentofmemoryaddressedbyHLpairwiththatofA-reg.
8)Ifcarry=1,gotostep10orifCarry=0gotostep9
9)MovethecontentofmemoryaddressedbyHLtoA–reg.
10)Decrementthecount
11)CheckforZeroofthecount.IfZF=0,gotostep6,orifZF=1gotonextstep.
12)Storethesmallestdatainmemory.
13)Terminatetheprogram.
9/8/2022 7:34 AM 8
Program
LXI H,4200 Set pointer for array
MOV B,M Load the Count
INX H Set 1st element as largest data
MOV A,M
DCR B Decrementedthe count
LOOP: INX H
CMP M If A-reg< M go to AHEAD
JC AHEAD
MOV A,M Set the new value as smallest
AHEAD:DCR B
JNZ LOOP Repeat comparisons till count = 0
STA 4300 Store the largest value at 4300
HLT
9/8/2022 7:34 AM 9
Largest number in an array
9/8/2022 7:34 AM 10
9/8/2022 7:34 AM 11
9/8/2022 7:34 AM 12
Sort an array in ascending order
9/8/2022 7:34 AM 13
9/8/2022 7:34 AM 14
9/8/2022 7:34 AM 15
9/8/2022 7:34 AM 16
Sort an array in ascending order
Algorithm:
1. Initialize HL pair as memory pointer
2. Get the count at 4200 into C -register
3. Copy it in D -register (for bubble sort (N-1) times
required)
4. Get the first value in A -register
5. Compare it with the value at next location
6. If they are out of order, exchange the contents of A -register
and Memory
7. Decrement D -register content by 1
8. Repeat steps 5 and 7 till the value in D-register become
zero
9. Decrement C -register content by 1
10. Repeat steps 3 to 9 till the value in C -register becomes
zero
9/8/2022 7:34 AM 17
Result
Input:
Data 0: 05H in memory location 5000 -->array size
Data 1: 05H in memory location 5001
Data 2: 04H in memory location 5002
Data 3: 03H in memory location 5003
Data 4: 02H in memory location 5004
Data 5: 01H in memory location 5005
Output:
Data 0: 05H in memory location 5000 --> array size
Data 1: 01H in memory location 5001
Data 2: 02H in memory location 5002
Data 3: 03H in memory location 5003
Data 4: 04H in memory location 5004
Data 5: 05H in memory location 5005
9/8/2022 7:34 AM 19
To add numbers in an array
Problem–Writeanassemblylanguageprogram
toaddhexadecimalnumbersstoredin
continuousmemoryorinanarray.
Assumption–Supposethesizeofthearrayis
storedatmemorylocation2050andthebase
addressofthearrayis2051.Thesumwillbe
storedatmemorylocation3050andcarrywill
bestoredatlocation3051.
9/8/2022 7:34 AM 21
Program
2000 LDA 2050 A <-[2050]
2003 MOV B, A B <-A
2004 LXI H, 2051H <-20 and L <-51
2007 MVI A, 00 A <-00
2009 MVI C, 00 C <-00
200B ADD M A <-A+M
200C INR M M <-M+1
200D JNC 2011
2010 INR C C <-C+1
2011 DCR B B <-B-1
2012 JNZ 200B
2015 STA 3050 3050 <-A
9/8/2022 7:34 AM 23
2018 MOV A, C A <-C
2019 STA 3051 3051 <-A
201C HLT
Terminates the program
9/8/2022 7:34 AM 24
Square of a Number Using Look Up
Table
Algorithm
1.InitializeHLpairtopointLookuptable.
2.Getthedata.
3.Checkwhetherthegiveninputislessthan9.
4.Ifyesgotonextstepelsehalttheprogram.
5.Addthedesiredaddresswiththe
accumulatorcontent.
6.Storetheresult
9/8/2022 7:34 AM 26
Program and Result
LXIH,5000;InitialsieLookuptableaddress
LDA5050 ;Getthedata
CPI0A ;Checkinput>9
JCAFTER ;ifyeserror
VIA,FF ;ErrorIndication
STA5051
HLT
AFTER:MOVC,A ;AddthedesiredAddress
MVIB,00
DADB
MOVA,M
STA5051 ;Storetheresult
HLT ;Terminatetheprogram
9/8/2022 7:34 AM 27