The Wayback Machine - https://web.archive.org/web/20240717024422/https://www.geeksforgeeks.org/assembly-language-program-8086-microprocessor-divide-16-bit-number-8-bit-number/
Open In App

8086 program to divide a 16 bit number by an 8 bit number

Last Updated : 23 May, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

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

Example –
division of 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. Halt the program.

Assumption – Initial value of each segment register is 00000.

Calculation of physical memory address –
Memory Address = Segment Register * 10(H) + offset,
where Segment Register and Offset is decided on the basis of following table.

OPERATIONS SEGMENT REGISTER OFFSET
Instruction fetching Code Segment Instruction Pointer
Data operation Data Segment Base Register [BX], Displacement [DISP]
Stack operation Stack Segment Stack Pointer (SP), Base Pointer (BP)
String as a source Data Segment Source Indexed (SI)
String as a destination Extra Segment Destination Indexed (DI)

Program –

MEMORY ADDRESS MNEMONICS COMMENT
0400 MOV SI, 500 SI <- 500
0403 MOV DI, 600 DI <- 600
0406 MOV BL, [SI] BL <- [SI]
0408 INC SI SI <- SI + 1
0409 MOV AX, [SI] AX <- [SI]
040B DIV BL AX <- AX / BL
040D MOV [DI], AX [DI] <- AX
040F HLT End 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


Similar Reads

8086 program to reverse 8 bit number using 8 bit operation
Problem – Write an assembly language program in 8086 microprocessor to reverse 8 bit number using 8 bit operation. Example – Assume 8 bit number is stored at memory location 2050 Algorithm – Load contents of memory location 2050 in register AL Assign 0004 to CX Register Pair Rotate the contents of AL by executing ROL instruction using CX Store the
1 min read
8086 program to reverse 16 bit number using 8 bit operation
Problem - Write an assembly language program in 8086 microprocessor to reverse 16 bit number using 8 bit operation. Example - Assume 16 bit number is stored at memory location 2050 and 2051. Algorithm – Load contents of memory location 2050 in register AL Load contents of memory location 2051 in register AH Assign 0004 to CX Register Pair Rotate th
2 min read
8086 program to convert an 8 bit BCD number into hexadecimal number
Problem - Write an assembly language program in 8086 microprocessor to convert an 8 bit BCD number into hexadecimal number. Example - Assumption - Initial value of segment register is 00000. Calculation of physical memory address: Memory Address = Segment Register * 10(H) + Offset where Segment Register is 00000 (Assumption) and Offset is given in
2 min read
8086 program to find sum of digits of 8 bit number
Problem - Write an assembly language program in 8086 microprocessor to find sum of digit of an 8 bit number using 8 bit operation. Example - Assume 8 bit number is stored at memory location 2050. Assumptions - Addresses of input data and output data are 2050 and 2051 respectively. Algorithm - Load contents of memory location 2050 in register AL Cop
2 min read
8086 program to Print a 16 bit Decimal number
Problem: Write a 8086 program to Print a 16 bit Decimal number. Examples: Input: d1 = 655 Output: 655 Input: d1 = 234 Output:234 Explanation: load the value stored into registerdivide the value by 10push the remainder into the stackincrease the countrepeat the steps until the value of the register is greater than 0until the count is greater than ze
2 min read
8086 program to convert a 16 bit decimal number to binary
Problem: We are given a 16 bit decimal number we have to print the number in binary format Examples: Input: d1 = 16 Output: 10000 Input: d1 = 7 Output: 111 Explanation: Load the value stored into registerDivide the value by 2 to convert it to binaryPush the remainder into the stackIncrease the countRepeat the steps until the value of the register i
2 min read
8086 program to convert a 16 bit Decimal number to Octal
Problem: We are given a 16 bit decimal number we have to print the number in octal format. Examples: Input: d1 = 16 Output:20 Input: d1 = 123 Output: 173 Explanation: Load the value stored into register Divide the value by 8 to convert it to octal Push the remainder into the stack Increase the count Repeat the steps until the value of the register
2 min read
8086 program to convert a 16 bit decimal number to Hexadecimal
Problem: We are given a 16 bit decimal number we have to print the number in Hexadecimal format. Examples: Input: d1 = 999 Output: 3E7 Input: d1 = 123 Output: 7B Explanation: Load the value stored into register Divide the value by 16 to convert it to Hexadecimal Push the remainder into the stack Increase the count Repeat the steps until the value o
2 min read
8086 program to convert 8 bit BCD number into ASCII Code
Problem – Write an assembly language program in 8086 microprocessor to convert 8-bit BCD number to its respective ASCII Code. Assumption – Starting address of the program: 400 Input memory location: 2000 Output memory location: 3000 Example : Input: DATA: 98H in memory location 2000Output:DATA: 38H in memory location 3000 and 39H in memory location
2 min read
8086 program to convert 8 bit ASCII to BCD number
Problem - Write a program to convert ASCII to BCD 8-bit number where the starting address is 2000 and the number is stored at 2050 memory address and store result in 3050 memory address. Example-Input : location: 2050 Data : 37Output : location: 3050 Data : 07 Algorithm – Move value at [2050] into AL Perform AND operation on AL with 0F Move the con
1 min read