Home » Embedded Systems

Print the table of a given number | 8086 Microprocessor

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

Problem statement:

Write an assembly language program in 8086 to print the table of a given integer.

Assumptions: Suppose the inputted number is at memory location 500 and the table will be printed from starting location 600 till 609 in hexadecimal.

Algorithm:

  1. Load input number address in SI and also load the address where we want output in DI .
  2. Store 00 in CH register.
  3. Increment value of CH by 1 and move the content of [SI] into AH register.
  4. Multiply content of AL and CH and store it in AX and then move content of AL into [DI], then increment value of DI by 1.
  5. Compare the value of CH and 0A, if not equal then go to step number 3 otherwise halt the program.

Program:

ADDRESSMNEMONICSCOMMENTS
400MOV SI, 500SI<-500
403MOV DI, 600DI<-600
406MOV CH, 00CH<-00
408INC CHCH<-CH+1
409MOV AL, [SI]AL<-[SI]
40BMUL CHAX<-AL*CH
40DMOV [DI], AL[DI]<-AL
40FINC DIDI<-DI+1
410CMP CH, 0ACH-0A
413JNZ 408jump to address 408 if zero flag is 0
415HLTTerminates the program

Explanation:

  1. MOV SI, 500: load 500 in SI.
  2. MOV DI, 600: load 600 in DI.
  3. MOV CH, 00: load 00 data in CH register.
  4. INC CH: increment the value inside CH register by 1.
  5. MOV AL, SI: move the content of SI into AL register.
  6. MUL CH: multiply the contents of AL and CH register and store in AX register.
  7. MOV [DI], AL: move the contents of AL register into [DI].
  8. INC DI: increment the value of DI by 1.
  9. CMP CH, 0A: subtract data inside CH register and 0A.
  10. JNZ 408: jump to address 408 if zero flag is 0.
  11. HLT: terminate the program.





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




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


© https://www.includehelp.com some rights reserved.