Multiplication of 16-bit Nos (Assembly Language)

; Program to compute 16 bit multiplication of the data.

DATA SEGMENT                ;INITIALIZE DATA SEGMENT
NUM1 DW 4537H               ;INITIALIZE NUM1 ANY DATA
NUM2 DW 2222H               ;INITIALIZE NUM2 ANY DATA
RESULT DW 2 DUP(0)     ;INITIALIZE RESULT AS DATA WORD WITH OFFSET=2.
;IF RESULT IS AT LOCATION 0000H – IT WILL STORE THE LOWER ORDER 16 BIT OF DAT
;THE UPPER 16 BIT OF DATA WILL BE STORED AT RESULT +2 => 0000H +2H => 0002H
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
MUL BX                                    ;MULTIPLY BX REGISTER
;BY DEFAULT MUL OPCODE MULTIPLES REGISTER * ACCUMULATOR
;SYNTAX IS MUL XX (BY WHICH REGISTER TO MULTIPLY)
MOV RESULT,AX               ;MOVE THE LOWER 16 BIT RESULT FROM AX TO DEFAULT RESULT LOCATION AS EXPLAINED ABOVE
MOV RESULT+2,DX         ;MOVE THE UPPER 16 BIT RESULT FROM DX TO SECOND RESULT LOCATION AS EXPLAINED ABOVE
MOV AH,4CH                       ;END OF THE CODE
INT 21H                                  ;END OF THE CODE
CODE ENDS                          ;END OF CODE SEGMENT
END START                         ;END OF START
; INPUT :
; NUM1 – 4537H
; NUM2 – 2222H

; OUTPUT :
; RESULT (AX) – 7F4E
; RESULT+2 (DX) – 093A
; FINAL RESULT = 093A7F4EH

Advertisements

2 thoughts on “Multiplication of 16-bit Nos (Assembly Language)

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