Home » Embedded Systems

Divide a 16 bits number by an 8 bits number | 8086 Microprocessor

Here, we are going to learn how to divide a 16 bits number by an 8 bits number using assembly program in 8086 Microprocessor?
Submitted by Ayush Sharma, on October 31, 2018

Problem statement:

Write an assembly language program in 8086 microprocessor to divide a 16 bit number by an 8 bit number.

Algorithm:

  1. Assign value 500 in SI and 600 in DI
  2. Move the contents of [SI] in BL and increment SI by 1
  3. Move the contents of [SI] and [SI + 1] in AX
  4. Use DIV instruction to divide AX by BL
  5. Move the contents of AX in [DI].
  6. Stop the program.

Assumption: Initial value of each segment register is 00000.

Calculation of physical memory address: Memory Address = Segment Register * 10(H) + offset,

Program:

ADDRESSMNEMONICSCOMMENTS
0400MOV SI, 500SI <- 500
0403MOV DI, 600DI <- 600
0406MOV BL, [SI]BL <- [SI]
0408INC SISI <- SI + 1
0409MOV AX, [SI]AX <- [SI]
040BDIV BLAX <- AX / BL
040DMOV [DI], AX[DI] <- AX
040FHLTEnd of program

Explanation: Registers used AX, BL, SI, DI

  1. MOV SI, 500 assigns 500 to SI
  2. MOV DI, 600 assigns 600 to DI
  3. MOV BL, [SI] moves the content of [SI] to BL register i.e. value of divisor will be stored in BL
  4. INC SI increment the content of SI by 1
  5. MOV AX, [SI] moves the content of [SI] and [SI + 1] to AX register i.e. value of dividend will be stored in AX
  6. DIV BL divide the content of AX by BL, after execution of this instruction the quotient get stored in AL and remainder in AH
  7. MOV [DI], AX moves the content of AX to [DI]
  8. HLT stops executing the program and halts any further execution





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.