-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab03.asm
183 lines (122 loc) · 2.89 KB
/
lab03.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
; Press (control + /) in vscode to uncomment codes.
; LAB 03
.model small
.stack 100h
; **************************************** Start of Q1 ****************************************************
; Write Assembly program to add two numbers using variables.
; .data
; var1 db 5
; var2 db 2
; .code
; main proc
; mov ax , @data
; mov ds , ax
; mov al, var1
; add al , var2
; mov dl,al
; add dl , 30h ; convert to ascii
; mov ah,02h
; int 21h
; mov ah ,4ch
; int 21h
; main endp
; end main
; **************************************** End of Q1 ****************************************************
; **************************************** Start of Q2 ****************************************************
; Write Assembly program to subtract two numbers using variables.
; .data
; var1 db 5
; var2 db 2
; .code
; main proc
; mov ax , @data
; mov ds , ax
; mov al, var1
; sub al , var2
; mov dl,al
; add dl , 30h ; convert to ascii
; mov ah,02h
; int 21h
; mov ah ,4ch
; int 21h
; main endp
; end main
; **************************************** End of Q2 ****************************************************
; **************************************** Start of Q3 ****************************************************
; mutiply two numbers
; .data
; var1 db 3
; var2 db 3
; result dw 0
; .code
; main proc
; mov ax, @data
; mov ds, ax
; mov ax, var1
; mul var2
; mov result, ax
; mov dx, result
; add dx, 30h ; convert to ascii
; mov ah, 02h
; int 21h
; mov ah, 4ch
; int 21h
; main endp
; end main
; **************************************** End of Q3 ****************************************************
; **************************************** Start of Q4 ****************************************************
; Write Assembly program to get two single digit numbers from user using variables and add them.
; .data
; var1 db ?
; var2 db ?
; .code
; main proc
; mov ax, @data
; mov ds, ax
; mov ah,01h
; int 21h
; sub al ,'0' ; converting input to numerical value
; mov var1 , al
; mov ah,01h
; int 21h
; sub al ,'0' ; converting input to numerical value
; mov var2 , al
; mov al ,var1
; add al , var2
; mov dl , al
; add dl , 30h
; mov ah , 02h
; int 21h
; mov ah, 4ch
; int 21h
; main endp
; end main
; **************************************** End of Q4 ****************************************************
; **************************************** Start of Q5 ****************************************************
; var4 = (var1 + var2) * var3
.data
var1 db ?
var2 db ?
.code
main proc
mov ax, @data
mov ds, ax
mov ah,01h
int 21h
sub al ,'0' ; converting input to numerical value
mov var1 , al
mov ah,01h
int 21h
sub al ,'0' ; converting input to numerical value
mov var2 , al
mov al ,var1
add al , var2
mov dl , al
add dl , 30h
mov ah , 02h
int 21h
mov ah, 4ch
int 21h
main endp
end main
; **************************************** End of Q5 ****************************************************