-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab2.asm
256 lines (156 loc) · 3.97 KB
/
lab2.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
; Press (control + /) in vscode to uncomment codes.
; LAB 02
; **************************************** Start of Q1 ****************************************************
;1. Write a program to write your name e.g. "AHMED" using 2h interrupt. (hint: use character by character).
.model small
.stack 100h
; .data
; .code
; main proc
; mov dl , 'A'
; mov ah,02h
; int 21h
; mov dl , 'h'
; mov ah,02h
; int 21h
; mov dl , 'm'
; mov ah,02h
; int 21h
; mov dl , 'a'
; mov ah,02h
; int 21h
; mov dl , 'd'
; mov ah,02h
; int 21h
; mov ah,4ch
; int 21h
; main endp
; end main
; end of part 1
; **************************************** End of Q1 ****************************************************
; ************************************************Start of Q2 *********************************************************
;2. Write a assembly language program to print hello world using mov ah,02 service routine.
; .data
; .code
; main proc
; mov dl , 'H'
; mov ah,02h
; int 21h
; mov dl , 'e'
; mov ah,02h
; int 21h
; mov dl , 'l'
; mov ah,02h
; int 21h
; mov dl , 'l'
; mov ah,02h
; int 21h
; mov dl , 'o'
; mov ah,02h
; int 21h
; mov dl , ' '
; mov ah,02h
; int 21h
; mov dl , 'W'
; mov ah,02h
; int 21h
; mov dl , 'o'
; mov ah,02h
; int 21h
; mov dl , 'r'
; mov ah,02h
; int 21h
; mov dl , 'l'
; mov ah,02h
; int 21h
; mov dl , 'd'
; mov ah,02h
; int 21h
; mov ah,4ch
; int 21h
; main endp
; end main
; ************************************************End of Q2 *********************************************************
; ************************************************Start of Q3 *********************************************************
;3. Write Assembly program to Input Character from user and display it.
; .data
; .code
; main proc
; mov ah , 01h
; int 21h
; mov dl , al
; ; add dl , 48
; mov ah, 02h
; int 21h
; mov ah,4ch
; int 21h
; main endp
; end main
; ************************************************End of Q3 *********************************************************
; ************************************************Start of Q4 *********************************************************
;4. Write a program that take number and print the next number.
; .data
; .code
; main proc
; mov ah , 01h
; int 21h
; mov dl , al
; ; sub dl, 'a'
; add dl , 1
; mov ah,02h
; ; mov dl , 0Ah
; ; mov dl , 0Dh
; int 21h
; mov ah,4ch
; int 21h
; main endp
; end main
; ************************************************End of Q4 *********************************************************
; ************************************************Start of Q5 *********************************************************
;5. Write a program that take a number and print the previous number.
; .data
; .code
; main proc
; mov ah,01h
; int 21h
; mov dl , al
; sub dl , 1
; mov ah,02h
; int 21h
; mov ah,4ch
; int 21h
; main endp
; end main
; ************************************************End of Q5 *********************************************************
; ************************************************START of Q6 *********************************************************
;6. Write Assembly program to Input Lower Case letter from user and display it's upper case. (Subtract 32 in ASCII).
; .data
; .code
; main proc
; mov ah,01h
; int 21h
; mov dl , al
; sub dl , 32 ; subtract to convert lowercase to upper and add 32 to convert uppercase to lowercase
; mov ah,02h
; int 21h
; mov ah ,4ch
; int 21h
; main endp
; end main
; ************************************************End of Q6 *********************************************************
; ************************************************Start of Q7 *********************************************************
;8. Write Assembly program to input letter from the user and display the next character.
.data
.code
main proc
mov ah,01h
int 21h
mov dl , al
add dl ,1
mov ah,02h
int 21h
mov ah,4ch
int 21h
main endp
end main
; ************************************************End of Q7 *********************************************************