Write a program for 8085 microprocessor to arrange first 10 numbers from memory address 3000H in an ascending order.
Answer:
MVI B, 09 :"Initialize counter"
START :"LXI H, 3000H: Initialize memory pointer"
MVI C, 09H :"Initialize counter 2"
BACK: MOV A, M :"Get the number"
INX H :"Increment memory pointer"
CMP M :"Compare number with next number"
JC SKIP :"If less, don’t interchange"
JZ SKIP :"If equal, don’t interchange"
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H :"Interchange two numbers"
SKIP:DCR C :"Decrement counter 2"
JNZ BACK :"If not zero, repeat"
DCR B :"Decrement counter 1"
JNZ START
HLT :"Terminate program execution"
Answer:
MVI B, 09 :"Initialize counter"
START :"LXI H, 3000H: Initialize memory pointer"
MVI C, 09H :"Initialize counter 2"
BACK: MOV A, M :"Get the number"
INX H :"Increment memory pointer"
CMP M :"Compare number with next number"
JC SKIP :"If less, don’t interchange"
JZ SKIP :"If equal, don’t interchange"
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H :"Interchange two numbers"
SKIP:DCR C :"Decrement counter 2"
JNZ BACK :"If not zero, repeat"
DCR B :"Decrement counter 1"
JNZ START
HLT :"Terminate program execution"
Discover the captivating tapestry of nations and their vibrant epicenters with our comprehensive guide on Countries of the World and Their Capitals. Unearth a treasure trove of invaluable information as we navigate through the rich cultural diversity, historical landmarks, and fascinating anecdotes that make each country and its capital a distinctive masterpiece. From the bustling streets of Paris to the ancient wonders of Beijing, embark on an SEO-friendly expedition that will leave you awe-inspired and well-informed about the global tapestry that connects us all.
ReplyDelete