-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSubtraction_Of_Two_16-bit_Numbers.asm
More file actions
37 lines (33 loc) · 1.48 KB
/
Subtraction_Of_Two_16-bit_Numbers.asm
File metadata and controls
37 lines (33 loc) · 1.48 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
; =================================================================================================
; AUTHOR : Amey Thakur
; REPOSITORY : https://github.com/Amey-Thakur/MICROPROCESSOR-AND-MICROPROCESSOR-LAB
; DESCRIPTION : 8086 Assembly program to perform 16-bit subtraction of two hexadecimal numbers.
; -------------------------------------------------------------------------------------------------
; HOW IT WORKS:
; 1. Define two 16-bit numbers in the data section.
; 2. Load the numbers into CPU registers (AX and BX).
; 3. Execute 'SUB' to find the difference.
; 4. Save the result into a specific memory location.
; =================================================================================================
; --- DATA SEGMENT ---
DATA SEGMENT
A DW 9A88H ; Minuend: The number to be subtracted from (16-bit)
B DW 8765H ; Subtrahend: The number being subtracted (16-bit)
C DW ? ; Reserve 16 bits for the resulting difference
DATA ENDS
; --- CODE SEGMENT ---
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
; -- Initialization --
MOV AX, DATA
MOV DS, AX
; -- Core Logic: Performing Subtraction --
MOV AX, A ; Move value from 'A' into AX register
MOV BX, B ; Move value from 'B' into BX register
SUB AX, BX ; Subtract value in BX from AX (AX = AX - BX)
MOV C, AX ; Save the calculated difference into variable 'C'
; -- Cleanup --
INT 3 ; Halt for status check
CODE ENDS
END START