Problem – Write an assembly language program in 8086 microprocessor to divide a 16 bit number by an 8 bit number.
- Assign value 500 in SI and 600 in DI
- Move the contents of [SI] in BL and increment SI by 1
- Move the contents of [SI] and [SI + 1] in AX
- Use DIV instruction to divide AX by BL
- Move the contents of AX in [DI].
- 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.
|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)|
|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
- MOV SI, 500 assigns 500 to SI
- MOV DI, 600 assigns 600 to DI
- MOV BL, [SI] moves the content of [SI] to BL register i.e. value of divisor will be stored in BL
- INC SI increment the content of SI by 1
- MOV AX, [SI] moves the content of [SI] and [SI + 1] to AX register i.e. value of dividend will be stored in AX
- DIV BL divide the content of AX by BL, after execution of this instruction the quotient get stored in AL and remainder in AH
- MOV [DI], AX moves the content of AX to [DI]
- HLT stops executing the program and halts any further execution
- 8086 program to convert an 8 bit BCD number into hexadecimal number
- 8086 program to reverse 8 bit number using 8 bit operation
- 8086 program to find the factorial of a number
- 8086 program to convert 8 bit ASCII to BCD number
- 8086 program to Print a 16 bit Decimal number
- 8086 program to reverse 16 bit number using 8 bit operation
- 8086 program to search a number in a string
- 8086 program to find sum of digits of 8 bit number
- 8086 program to convert 8 bit BCD number into ASCII Code
- 8086 program to find Square Root of a number
- 8086 program to convert a 16 bit decimal number to Hexadecimal
- 8086 program to convert a 16 bit Decimal number to Octal
- 8086 program to convert a 16 bit decimal number to binary
- 8086 program to determine largest number in an array of n numbers
- 8086 program to find the square root of a perfect square root number | Set-2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.