Open In App

8085 program to print the table of input integer

Last Updated : 11 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Problem – Write an assembly language program in 8085 to print the table of input integer. Assumption – Suppose the inputted number is at memory location 2050 and the table will be printed from starting location 3050. Example – 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 –

ADDRESS MNEMONICS COMMENTS
2000 LDA 2050 A<-[2050]
2003 MOV D, A D<-[A]
2004 MVI B 0A B<-0A
2006 LXI H 3050 H<-30 & L<-50
2009 MVI C 00 C<-00
200B MOV A, D A<-[D]
200C ADD C A<-[A]+[C]
200D MOV M, A M<-[A]
200E INX H HL<-HL+1
200F MOV C, A C<-[A]
2010 DCR B B<-[B]-1
2011 JNZ 200B Jump to address 200B if ZF=0
2014 HLT Terminates 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.
  12. JNZ 200B: jump to address 200B if Carry flag is not zero.
  13. HLT: terminate the program.

Advantages:

  • This program is capable of printing the table of any input integer up to 255 in decimal or FF in hexadecimal.
     
  • The program uses subroutines to print numbers and characters, making it more modular and reusable.
     
  • The program uses the multiplication operation to generate the table, which is an efficient method.
     
  • The program can be easily modified to output the table in different formats, such as a CSV or HTML table.
     

Disadvantages:

  • The program is relatively complex and may be difficult to understand for novice programmers.
     
  • The program assumes that the input integer is in the A register and does not provide error checking for invalid input.
     
  • The program does not allow for dynamic memory allocation, which may limit its usefulness in more complex applications.
     
  • The program outputs the table to the console, which may not be suitable for all use cases.

Similar Reads

8086 program to print the table of input integer
Problem - Write an assembly language program in 8086 to print the table of input integer. Assumption - Suppose the inputted number is at memory location 500 and the table will be printed from starting location 600 till 609 in hexadecimal. Example - Algorithm - Load input number address in SI and also load the address where we want output in DI . St
2 min read
8085 program for Linear search | Set 2
Problem - Write an assembly language program in 8085 microprocessor to find a given number in the list of 10 numbers, if found store 1 in output else store 0 in output. Example - Assumption - Data to be found at 2040H, list of numbers from 2050H to 2059H and output at 2060H. Algorithm - Load data byte to be searched in B register and counter in D r
2 min read
8085 program to find the element that appears once
Prerequisite - Find the element that appears once in an array where every other element appears twice Problem – Given 11 numbers, write an assembly language program to find the element that appears once where 5 numbers appear twice and one element appears once. Examples: Input : [01H, 02H, 09H, 01H, 01H, 02H, 0AH, 01H, 09H, 03H, 03H] Output : 0AH E
2 min read
8085 program to find maximum and minimum of 10 numbers
Problem - Write an assembly language program in 8085 microprocessor to find maximum and minimum of 10 numbers. Example - Minimum: 01H, Maximum: FFH In CMP instruction: If Accumulator &gt; Register then carry and zero flags are reset If Accumulator = Register then zero flag is set If Accumulator &lt; Register then carry flag is set Assumption - List
3 min read
8085 program to search a number in an array of n numbers
Problem - Write an assembly language program in 8085 to search a given number in an array of n numbers. If number is found, then store F0 in memory location 3051 otherwise store 0F in 3051. Assumptions - Count of elements in an array is stored at memory location 2050. Array is stored from starting memory address 2051 and number which user want to s
4 min read
8085 program to find maximum of two 8 bit numbers
Problem - Write a assembly language program to find maximum of two 8 bit numbers in 8085 microprocessor. Assumptions - Starting memory locations and output memory locations are 2050, 2051 and 3050 respectively. Example - Algorithm - Load value in the accumulator Then, copy the value to any of the register Load next value in the accumulator Compare
1 min read
8085 program to add two 8 bit numbers
Problem - Write an assembly language program to add two 8 bit numbers stored at address 2050 and address 2051 in 8085 microprocessor. The starting address of the program is taken as 2000. Example - Algorithm - Load the first number from memory location 2050 to accumulator.Move the content of accumulator to register H.Load the second number from mem
2 min read
8085 program to multiply two 8 bit numbers
Problem - Multiply two 8 bit numbers stored at address 2050 and 2051. Result is stored at address 3050 and 3051. Starting address of program is taken as 2000. Example - Algorithm - We are taking adding the number 43 seven(7) times in this example.As the multiplication of two 8 bit numbers can be maximum of 16 bits so we need register pair to store
3 min read
8085 program to convert an 8 bit number into Grey number
Prerequisite - Binary to/from Gray Code Problem - Write an assembly language program in 8085 which convert an 8 bit number into grey number Example - Assumption - 8 bit number (input) is stored at memory location 2050 and output to be stored at memory location 3050. Algorithm - Load the content of memory location 2050 in AccumulatorReset carry flag
2 min read
8085 program to find the factorial of a number
Problem - Write an assembly language program for calculating the factorial of a number using 8085 microprocessor. Example - Input : 04H Output : 18H as 04*03*02*01 = 24 in decimal =&gt; 18H In 8085 microprocessor, no direct instruction exists to multiply two numbers, so multiplication is done by repeated addition as 4x3 is equivalent to 4+4+4 (i.e.
2 min read