-
Notifications
You must be signed in to change notification settings - Fork 0
/
Multiplication2Different32BitsNumbers.asm
108 lines (81 loc) · 1.69 KB
/
Multiplication2Different32BitsNumbers.asm
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
;In this project our goal is multiply two 32 bits numbers with each other (11223344h and 55667788h )
;Firstly I divide numbers to 2 16 bits numbers then I multiply them part by part.
;After that I sum the getting results. (BE CAREFUL ABOUT DIGIT VALUES OF EACH PART)
;Then store the final result in the memory
;Final result in the [20B0h] location.
org 100h
mov ax,a
mov bx,d ; a*d
mul bx
mov [2050h],0000h ; 16bit shift to left
mov [2050h+2],ax
mov [2050h+4],dx
mov ax,b
mov bx,d
mul bx ;b*d
mov [2050h+6],ax
mov [2050h+8],dx
mov bx,[2050h] ;
mov ax,[2050h+6] ;
add ax,bx
mov [2060h],ax
mov dx,[2052h]
mov ax,[2050h+8]
adc ax,dx
mov [2060h+2],ax
mov bx,[2054h]
mov ax,0000h
adc ax,bx
mov [2064h],ax ; result = 11223344 * 7788
mov ax,c
mov bx,b ; c*b
mul bx
mov [2080h],0000h ; 16bit shift to left
mov [2080h+2],ax
mov [2080h+4],dx
mov ax,c
mov bx,a
mul bx ;c*a
mov [2090h+4],ax
mov [2090h+6],dx
mov [2090h+2],0000h
mov [2090h],0000h
mov bx,[2080h] ;
mov ax,[2090h] ;
add ax,bx
mov [20A0h],ax
mov dx,[2082h]
mov ax,[2092h]
adc ax,dx
mov [20A0h+2],ax
mov bx,[2084h]
mov ax,[2094h]
adc ax,bx
mov [20A0h+4],ax
mov bx,[2086h]
mov ax,[2096h]
adc ax,bx
mov [20A0h+6],ax
;;;;;;;;;;;;;;;;
final :
mov bx,[2060h] ;
mov ax,[20A0h] ;
add ax,bx
mov [20B0h],ax
mov dx,[2062h]
mov ax,[20A0h+2]
adc ax,dx
mov [20B0h+2],ax
mov bx,[2064h]
mov ax,[20A0h+4]
adc ax,bx
mov [20B0h+4],ax
mov bx,[2066h]
mov ax,[20A0h+6]
adc ax,bx
mov [20B0h+6],ax
ret
a dw 1122h ;1122h
b dw 3344h ;2233h
c dw 5566h ;5566h
d dw 7788h ;7788h