-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDivision_Of_Two_8-bit_Numbers.asm
More file actions
39 lines (35 loc) · 1.59 KB
/
Division_Of_Two_8-bit_Numbers.asm
File metadata and controls
39 lines (35 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
; =================================================================================================
; AUTHOR : Amey Thakur
; REPOSITORY : https://github.com/Amey-Thakur/MICROPROCESSOR-AND-MICROPROCESSOR-LAB
; DESCRIPTION : 8086 Assembly program to perform 8-bit division of two hexadecimal numbers.
; -------------------------------------------------------------------------------------------------
; HOW IT WORKS:
; 1. Define an 8-bit dividend and an 8-bit divisor.
; 2. Load the dividend into the AL register (part of the larger AX register).
; 3. Load the divisor into a general register (BL).
; 4. Execute 'DIV'. The Quotient goes to AL and the Remainder goes to AH.
; =================================================================================================
; --- DATA SEGMENT ---
DATA SEGMENT
A DB 28H ; Dividend (8-bit)
B DB 02H ; Divisor (8-bit)
C DW ? ; Word (16-bit) to store both Quotient (AL) and Remainder (AH)
DATA ENDS
; --- CODE SEGMENT ---
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
; -- Initialization --
MOV AX, DATA
MOV DS, AX
; -- Core Logic: Performing the Division --
MOV AX, 0000H ; Clear the AX register to avoid garbage values
MOV BX, 0000H ; Clear BX register
MOV AL, A ; Load the 8-bit dividend into AL
MOV BL, B ; Load the 8-bit divisor into BL
DIV B ; Perform division (AX / B). Result: AL = Quotient, AH = Remainder.
MOV C, AX ; Save the combined result (AX) into memory location 'C'
; -- Cleanup --
INT 3 ; Halt for inspection
CODE ENDS
END START