SlideShare a Scribd company logo
1 of 29
Download to read offline
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
Algorithm
• Maximum number is stored in B register and minimum in C
register
• Load counter in D register
• Load starting element in Accumulator, B and C register
• Compare Accumulator and B register
• If carry flag is not set then transfer contents of Accumulator
to B. Else, compare Accumulator with C register, if carry
flag is set transfer contents of Accumulator to C
• Decrement D register
• If D>0 take next element in Accumulator and go to point 4
• If D=0, store B and C register in memory
• End of program
9/8/2022 7:34 AM 3
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
Explanation
• One by one all elements are compared with B and
C register.
• Element is compared with maximum, if it greater
than maximum then it is stored in B register. Else,
it is compared with minimum and if it is less than
minimum then it stored in C regiter.
• Loop executes 10 number of times.
• At the end of 10 iterations, maximum and
minimum are stored at 2060H and 2061H
respectively.
9/8/2022 7:34 AM 7
SMALLEST NUMBER IN A DATA ARRAY
Algorithm
1) Load the address of the first element of the array in HL pair
2) Move the count to B – reg.
3) Increment the pointer
4) Get the first data in A – reg.
5) Decrement the count.
6) Increment the pointer
7) Compare the content of memory addressed by HL pair with that of A - reg.
8) If carry = 1, go to step 10 or if Carry = 0 go to step 9
9) Move the content of memory addressed by HL to A – reg.
10) Decrement the count
11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.
12) Store the smallest data in memory.
13) Terminate the program.
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 Decremented the 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
Program
LXI H,5000 ;Set pointer for array
MOV C,M ;Load the Count
DCR C ;Decrement Count
REPEAT: MOV D,C
LXI H,5001
LOOP: MOV A,M ;copy content of memory location to Accumulator
INX H
CMP M
JC SKIP ;jump to skip if carry generated
MOV B,M ;copy content of memory location to B - Register
MOV M,A ;copy content of Accumulator to memory location
DCX H ;Decrement content of HL pair of registers
MOV M,B ;copy content of B - Register to memory location
INX H ;Increment content of HL pair of registers
SKIP: DCR D ;Decrement content of Register - D
JNZ LOOP ;jump to loop if not equal to zero
DCR C ;Decrement count
JNZ REPEAT ;jump to repeat if not equal to zero
HLT ;Terminate Program
9/8/2022 7:34 AM 18
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
Sort an array in descending order
START:MVI B, 00 ; Flag = 0
LXI H, 4150 ; Count = length of array
MOV C, M
DCR C ; No. of pair = count -1
INX H ; Point to start of array
LOOP:MOV A, M ; Get kth element
INX H
CMP M ; Compare to (K+1) th element
JNC LOOP 1 ; No interchange if kth >= (k+1) th
MOV D, M ; Interchange if out of order
MOV M, A ;
DCR H
MOV M, D
INX H
MVI B, 01H ; Flag=1
LOOP 1:DCR C ; count down
JNZ LOOP ;
DCR B ; is flag = 1?
JZ START ; do another sort, if yes
HLT ; If flag = 0, step execution
9/8/2022 7:34 AM 20
To add numbers in an array
Problem – Write an assembly language program
to add hexadecimal numbers stored in
continuous memory or in an array.
Assumption – Suppose the size of the array is
stored at memory location 2050 and the base
address of the array is 2051. The sum will be
stored at memory location 3050 and carry will
be stored at location 3051.
9/8/2022 7:34 AM 21
Algorithm
• Load the base address of the array in HL
register pair.
• Use the size of the array as a counter.
• Initialise accumulator to 00.
• Add content of accumulator with the content
stored at memory location given in HL pair.
• Decrease counter on each addition.
9/8/2022 7:34 AM 22
Program
2000 LDA 2050 A <- [2050]
2003 MOV B, A B <- A
2004 LXI H, 2051 H <- 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
Explanation –
LDA 2050: load accumulator with content of location 2050
MOV B, A: copy contents of accumulator to register B
LXI H, 2051: store 20 to H register and 51 to L register
MVI A, 00: store 00 to accumulator
MVI C, 00: store 00 to register C
ADD M: add accumulator with the contents of memory location given in HL register
pair
INR M: increase M by 1
JNC 2011: if not carry, jump to location 2011 otherwise to the location given in PC
INR C: increase content of register C by 1
DCR B: decrease content of register B by 1
JNZ 200B: if not zero, jump to location 200B otherwise to the location given in PC
STA 3050: store contents of accumulator to memory location 3050
MOV A, C: copy contents of register C to accumulator
STA 3051: store contents of accumulator to memory location 3051
HLT: terminates the program
9/8/2022 7:34 AM 25
Square of a Number Using Look Up
Table
Algorithm
1. Initialize HL pair to point Look up table.
2. Get the data .
3. Check whether the given input is less than 9.
4. If yes go to next step else halt the program.
5. Add the desired address with the
accumulator content.
6. Store the result
9/8/2022 7:34 AM 26
Program and Result
LXI H,5000 ;Initialsie Look up table address
LDA 5050 ;Get the data
CPI 0A ;Check input > 9
JC AFTER ;if yes error
VI A,FF ;Error Indication
STA 5051
HLT
AFTER: MOV C,A ;Add the desired Address
MVI B,00
DAD B
MOV A,M
STA 5051 ;Store the result
HLT ;Terminate the program
9/8/2022 7:34 AM 27
LOOKUP TABLE
5000 01
5001 04
5002 09
5003 16
5004 25
5005 36
5006 49
5007 64
5008 81
9/8/2022 7:34 AM 28
Result
Input:
Data: 05H in memory location 5050
Output:
Data: 25H (Square of 5) in memory location 5051
Input:
Data: 11H in memory location 5050
Output:
Data: FFH (Error Indication) in memory location 5051
9/8/2022 7:34 AM 29

More Related Content

What's hot

Boolean expression org.
Boolean expression org.Boolean expression org.
Boolean expression org.mshoaib15
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051SARITHA REDDY
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structureVardhil Patel
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked ListsJ.T.A.JONES
 
Addressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyAddressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyBinu Joy
 
Register introduction
Register introductionRegister introduction
Register introductionmaamir farooq
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Akhila Rahul
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor Mustapha Fatty
 
Clocked Sequential circuit analysis and design
Clocked Sequential circuit analysis and designClocked Sequential circuit analysis and design
Clocked Sequential circuit analysis and designDr Naim R Kidwai
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in cAbdelrahman Elewah
 
Sequential circuit multiplier
Sequential circuit multiplierSequential circuit multiplier
Sequential circuit multiplierSubhram
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionBadrul Alam
 

What's hot (20)

Boolean expression org.
Boolean expression org.Boolean expression org.
Boolean expression org.
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked Lists
 
Addressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyAddressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu Joy
 
Register introduction
Register introductionRegister introduction
Register introduction
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Programming with 8085
Programming with 8085Programming with 8085
Programming with 8085
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
 
Extensible hashing
Extensible hashingExtensible hashing
Extensible hashing
 
Clocked Sequential circuit analysis and design
Clocked Sequential circuit analysis and designClocked Sequential circuit analysis and design
Clocked Sequential circuit analysis and design
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
 
Sequential circuit multiplier
Sequential circuit multiplierSequential circuit multiplier
Sequential circuit multiplier
 
8086
80868086
8086
 
80386 Architecture
80386 Architecture80386 Architecture
80386 Architecture
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Shift Registers
Shift RegistersShift Registers
Shift Registers
 

Similar to 8085 program to find max and min using lookup table

Chapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional InstructionsChapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional Instructionscmkandemir
 
180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-dochomeworkping10
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!PRABHAHARAN429
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085techbed
 
Ee2356 lab manual
Ee2356 lab manualEe2356 lab manual
Ee2356 lab manualdhameee
 
Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Basil John
 
Programming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacingProgramming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacingAmitabh Shukla
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085 vijaydeepakg
 
Code Conversion in 8085 Microprocessor
Code Conversion in 8085 MicroprocessorCode Conversion in 8085 Microprocessor
Code Conversion in 8085 MicroprocessorMOHIT AGARWAL
 
8085 instruction set and Programming
8085 instruction set and Programming 8085 instruction set and Programming
8085 instruction set and Programming pooja saini
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3Sajan Agrawal
 
Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Swati Watve-Phadke
 
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSINTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSSwapnil Mishra
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Shubham Singh
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction setJLoknathDora
 

Similar to 8085 program to find max and min using lookup table (20)

Chapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional InstructionsChapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional Instructions
 
8085_Excercise.pptx
8085_Excercise.pptx8085_Excercise.pptx
8085_Excercise.pptx
 
180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085
 
8085 alp programs
8085 alp programs8085 alp programs
8085 alp programs
 
Ee2356 lab manual
Ee2356 lab manualEe2356 lab manual
Ee2356 lab manual
 
Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)
 
Programming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacingProgramming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacing
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085
 
Code Conversion in 8085 Microprocessor
Code Conversion in 8085 MicroprocessorCode Conversion in 8085 Microprocessor
Code Conversion in 8085 Microprocessor
 
8085 instruction set and Programming
8085 instruction set and Programming 8085 instruction set and Programming
8085 instruction set and Programming
 
Real Time Embedded System
Real Time Embedded SystemReal Time Embedded System
Real Time Embedded System
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
 
Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02
 
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSINTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085
 
EE2356 Microprocessor and Microcontroller Lab Manuel
EE2356 Microprocessor and Microcontroller Lab ManuelEE2356 Microprocessor and Microcontroller Lab Manuel
EE2356 Microprocessor and Microcontroller Lab Manuel
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction set
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction set
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

8085 program to find max and min using lookup table

  • 2. 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
  • 3. Algorithm • Maximum number is stored in B register and minimum in C register • Load counter in D register • Load starting element in Accumulator, B and C register • Compare Accumulator and B register • If carry flag is not set then transfer contents of Accumulator to B. Else, compare Accumulator with C register, if carry flag is set transfer contents of Accumulator to C • Decrement D register • If D>0 take next element in Accumulator and go to point 4 • If D=0, store B and C register in memory • End of program 9/8/2022 7:34 AM 3
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. Explanation • One by one all elements are compared with B and C register. • Element is compared with maximum, if it greater than maximum then it is stored in B register. Else, it is compared with minimum and if it is less than minimum then it stored in C regiter. • Loop executes 10 number of times. • At the end of 10 iterations, maximum and minimum are stored at 2060H and 2061H respectively. 9/8/2022 7:34 AM 7
  • 8. SMALLEST NUMBER IN A DATA ARRAY Algorithm 1) Load the address of the first element of the array in HL pair 2) Move the count to B – reg. 3) Increment the pointer 4) Get the first data in A – reg. 5) Decrement the count. 6) Increment the pointer 7) Compare the content of memory addressed by HL pair with that of A - reg. 8) If carry = 1, go to step 10 or if Carry = 0 go to step 9 9) Move the content of memory addressed by HL to A – reg. 10) Decrement the count 11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step. 12) Store the smallest data in memory. 13) Terminate the program. 9/8/2022 7:34 AM 8
  • 9. 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 Decremented the 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
  • 10. Largest number in an array 9/8/2022 7:34 AM 10
  • 13. Sort an array in ascending order 9/8/2022 7:34 AM 13
  • 17. 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
  • 18. Program LXI H,5000 ;Set pointer for array MOV C,M ;Load the Count DCR C ;Decrement Count REPEAT: MOV D,C LXI H,5001 LOOP: MOV A,M ;copy content of memory location to Accumulator INX H CMP M JC SKIP ;jump to skip if carry generated MOV B,M ;copy content of memory location to B - Register MOV M,A ;copy content of Accumulator to memory location DCX H ;Decrement content of HL pair of registers MOV M,B ;copy content of B - Register to memory location INX H ;Increment content of HL pair of registers SKIP: DCR D ;Decrement content of Register - D JNZ LOOP ;jump to loop if not equal to zero DCR C ;Decrement count JNZ REPEAT ;jump to repeat if not equal to zero HLT ;Terminate Program 9/8/2022 7:34 AM 18
  • 19. 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
  • 20. Sort an array in descending order START:MVI B, 00 ; Flag = 0 LXI H, 4150 ; Count = length of array MOV C, M DCR C ; No. of pair = count -1 INX H ; Point to start of array LOOP:MOV A, M ; Get kth element INX H CMP M ; Compare to (K+1) th element JNC LOOP 1 ; No interchange if kth >= (k+1) th MOV D, M ; Interchange if out of order MOV M, A ; DCR H MOV M, D INX H MVI B, 01H ; Flag=1 LOOP 1:DCR C ; count down JNZ LOOP ; DCR B ; is flag = 1? JZ START ; do another sort, if yes HLT ; If flag = 0, step execution 9/8/2022 7:34 AM 20
  • 21. To add numbers in an array Problem – Write an assembly language program to add hexadecimal numbers stored in continuous memory or in an array. Assumption – Suppose the size of the array is stored at memory location 2050 and the base address of the array is 2051. The sum will be stored at memory location 3050 and carry will be stored at location 3051. 9/8/2022 7:34 AM 21
  • 22. Algorithm • Load the base address of the array in HL register pair. • Use the size of the array as a counter. • Initialise accumulator to 00. • Add content of accumulator with the content stored at memory location given in HL pair. • Decrease counter on each addition. 9/8/2022 7:34 AM 22
  • 23. Program 2000 LDA 2050 A <- [2050] 2003 MOV B, A B <- A 2004 LXI H, 2051 H <- 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
  • 24. 2018 MOV A, C A <- C 2019 STA 3051 3051 <- A 201C HLT Terminates the program 9/8/2022 7:34 AM 24
  • 25. Explanation – LDA 2050: load accumulator with content of location 2050 MOV B, A: copy contents of accumulator to register B LXI H, 2051: store 20 to H register and 51 to L register MVI A, 00: store 00 to accumulator MVI C, 00: store 00 to register C ADD M: add accumulator with the contents of memory location given in HL register pair INR M: increase M by 1 JNC 2011: if not carry, jump to location 2011 otherwise to the location given in PC INR C: increase content of register C by 1 DCR B: decrease content of register B by 1 JNZ 200B: if not zero, jump to location 200B otherwise to the location given in PC STA 3050: store contents of accumulator to memory location 3050 MOV A, C: copy contents of register C to accumulator STA 3051: store contents of accumulator to memory location 3051 HLT: terminates the program 9/8/2022 7:34 AM 25
  • 26. Square of a Number Using Look Up Table Algorithm 1. Initialize HL pair to point Look up table. 2. Get the data . 3. Check whether the given input is less than 9. 4. If yes go to next step else halt the program. 5. Add the desired address with the accumulator content. 6. Store the result 9/8/2022 7:34 AM 26
  • 27. Program and Result LXI H,5000 ;Initialsie Look up table address LDA 5050 ;Get the data CPI 0A ;Check input > 9 JC AFTER ;if yes error VI A,FF ;Error Indication STA 5051 HLT AFTER: MOV C,A ;Add the desired Address MVI B,00 DAD B MOV A,M STA 5051 ;Store the result HLT ;Terminate the program 9/8/2022 7:34 AM 27
  • 28. LOOKUP TABLE 5000 01 5001 04 5002 09 5003 16 5004 25 5005 36 5006 49 5007 64 5008 81 9/8/2022 7:34 AM 28
  • 29. Result Input: Data: 05H in memory location 5050 Output: Data: 25H (Square of 5) in memory location 5051 Input: Data: 11H in memory location 5050 Output: Data: FFH (Error Indication) in memory location 5051 9/8/2022 7:34 AM 29