# Print the table of a given number | 8085 Microprocessor

Here, we are going to learn how to print the table of a given number using assembly language in 8085 microprocessor?
Submitted by Ayush Sharma, on October 30, 2018

Problem statement:

Write an assembly language program in 8085 to print the table of input integer.

Assumptions: Suppose the inputted number is at memory location 2050 and the table will be printed from starting location 3050.

Algorithm:

1. Load the value of input in accumulator from memory location 2050 and then copy it to another register say D. Also store 0A in register B.
2. Store memory location 3050 in M using LXI instruction and take another register say C with its value 00.
3. Now copy the content of D register to A and add the contents of A and C and store it in A then copy it to M.
4. Increment value of M by 1.
5. Copy content of A to C and decrements the content of B by 1 and if its value is 0 then halt otherwise again go to step number 3.

Program:

2000LDA 2050A<-[2050]
2004MVI B 0AB<-0A
2006LXI H 3050H<-30 & L<-50
2009MVI C 00C<-00
200BMOV A, DA<-[D]
200DMOV M, AM<-[A]
200EINX HHL<-HL+1
200FMOV C, AC<-[A]
2010DCR BB<-[B]-1
2014HLTTerminates the program

Explanation:

1. LDA 2050: load the contents from 2050 memory location to accumulator (register A).
2. MOV D, A: move the contents of accumulator to register D.
3. MVI B 0A: store 0A data into register B.
4. LXI H 3050: store 30 in H register and 50 in L register; hence M will contain 3050 inside it.
5. MVI C 00: store 00 data in register C.
6. MOV A, D: move the contents of D register into A.
7. ADD C: add the contents of A and C register and store in A.
8. MOV M, A: move the contents of A register into M.
9. INX H: increments content of M by 1.
10. MOV C, A: move the contents of A register into C.
11. DCR B: decrements the content of B register by 1.
13. HLT: terminate the program.

What's New

Top Interview Coding Problems/Challenges!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates