Subtraction of 16-bit Nos (Assembly Language)

; Program to compute 16 bit subtraction of the data.
DATA SEGMENT             ;INITIALIZE DATA SEGMENT
NUM1 DW 4537H            ;INITIALIZE NUM1 ANY DATA
NUM2 DW 2222H            ;INITIALIZE NUM2 ANY DATA
RESULT DW ?                    ;INITIALIZE RESULT
DATA ENDS                        ;END OF DATA SEGMENT
CODE SEGMENT             ;INITIALIZE CODE SEGMENT
START:                                 ;START THE CODE
ASSUME CS:CODE , DS:DATA                 ;ASSUMPTION OF CODE AND DATA
MOV AX,DATA                 ;MOV DATA INTO ACCUMULATOR AX
MOV DS,AX                        ;MOV DATA FROM ACCUMULATOR INTO DATA SEGMENT REGISTER
MOV AX,NUM1                ;MOV NUM1 INTO ACCUMULATOR AX REGISTER
MOV BX,NUM2                ;MOV NUM2 INTO BASE BX REGISTER
SUB AX,BX                         ;SUBTRACTING THE CONTENTS OF AX AND BX. RESULT IS STILL IN ACCUMULATOR
MOV RESULT,AX           ;MOVE THE RESULT FROM AX INTO RESULT VARIABLE
MOV AH,4CH                    ;END OF THE CODE
INT 21H                               ;END OF THE CODE
CODE ENDS                       ;END OF CODE SEGMENT
END START                      ;END OF START
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s