0% found this document useful (0 votes)
80 views11 pages

Lab 1

The document contains code snippets for 12 programs that demonstrate reading input from the keyboard, displaying output, manipulating character data, and other basic operations. The programs include: reading and displaying a character; printing a hardcoded string; converting between uppercase and lowercase letters; reading and displaying digits and their sum; reading and displaying initials; converting between hexadecimal and decimal; displaying an asterisk box; and reading input and displaying it within an asterisk box.

Uploaded by

Saimun Mahumd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views11 pages

Lab 1

The document contains code snippets for 12 programs that demonstrate reading input from the keyboard, displaying output, manipulating character data, and other basic operations. The programs include: reading and displaying a character; printing a hardcoded string; converting between uppercase and lowercase letters; reading and displaying digits and their sum; reading and displaying initials; converting between hexadecimal and decimal; displaying an asterisk box; and reading input and displaying it within an asterisk box.

Uploaded by

Saimun Mahumd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

4.

1 Write a program that will


read a character from the
keyboard and display it at the
beginning of the next line.

.model small mov ah,2


.stack 100h mov dl,bl
.code int 21h
main proc
mov ah,4ch
mov ah,1
int 21h
int 21h
main endp
mov bl,al
end main
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
4.2 write a program that print
the "HELLO!".

mov ah,4ch
.model small
int 21h
.stack 100h
main endp
.data
end main
msg DB 'Hello!$'
.code
main proc
mov ax,@data
mov ds,ax
lea dx,msg
mov ah,9
int 21h
4.3 WRITE A PROGRAM THAT int 21h
CONVERT LOWER CASE LETTER mov dl,0ah
INTO UPPERCASE LETTER
int 21h

.model small
mov ah,9
.stack 100h
lea dx, msg1
.data
int 21h
msg db 'Enter a lowercase letter :$'
msg1 db 'In uppercase form it is : $'
mov ah,2
.code
sub bl,32
main proc
mov ax,@data mov dl,bl

mov ds,ax int 21h

mov ah,9 mov ah,4ch


lea dx,msg int 21h
int 21h main endp
end main
mov ah,1
int 21h
mov bl,al

mov ah,2
mov dl,0dh
7.1 Read a character, and
display it at the T'.ext position
on the
same line.

.model small
mov ah,4ch
.stack 100h
int 21h
.code
main endp
main proc
end main
mov ah,1
int 21h
mov bl,al

mov ah,2
mov dl,bl
int 21h

7.2 WRITE A PROGRAM THAT


CONVERT UPPER CASE LETTER
INTO LOWERCASE LETTER IN
THE SAME LINE

mov ah,4ch
.model small int 21h
.stack 100h main endp
.code end main
main proc
mov ah,1
int 21h
mov bl,aL

mov ah,2
add bl,32
mov dl,bl
int 21h

8. Write a program to (a) display


a "?", (b) read two decimal
digits
who.se sum "is less than 10, (c)
display them and their sum on
the
next line, with an appropriate
message
mov ah,1
.model small int 21h
.stack 100h mov c1,al
.data int 21h
msg db 0ah,0dh, 'The sum of ' mov c2,al
c1 db ?, ' and ' add al,c1
c2 db ?, ' is ' sub al,48
c3 db ?, '$' mov c3,al
.code
main proc mov ah,9

mov ax,@data lea dx,msg

mov ds,ax int 21h


mov ah,4ch
mov ah,2 int 21h
mov dl, '?' main endp
int 21h end main

9. Write a program to (a)


prompt the user, (b) read first,
middle, and
last initials of a person's name,
and (c) display them duwn the mov c2,al
left margin. int 21h
mov c3,al

.model small
mov ah,2
.stack 100h
mov dl,0ah
.data
int 21h
msg db 'Enter three initials : $ '
mov dl,0dh
c1 db ?, 0ah,0dh
int 21h
c2 db ?, 0ah,0dh
c3 db ?, '$'
mov ah,9
.code
lea dx,c1
main proc
int 21h
mov ax,@data
mov ds,ax
mov ah,4ch
int 21h
mov ah,9
main endp
lea dx,msg
end main
int 21h

mov ah,1
int 21h
mov c1,al
int 21h

10. Write· a program to read


one of the hex digits A-I', and
<.lisplay it
on the next line in decimal.
sub al,11h
.model small mov c1,al
.stack 100h
.data mov ah,9

msg db 'Enter a hex digit : $ ' lea dx,msg1

msg1 db 0ah,0dh, 'In decimal it int 21h


is 1'
c1 db ?, '$' mov ah,4ch
.code int 21h
main proc main endp
mov ax,@data end main
mov ds,ax

mov ah,9
lea dx,msg
int 21h

mov ah,1
int 21h
11. Write a program to display a
t 0 x 10 solid box of asterisks.
Hint: declare a string in the data
segment that specifies the box,
and display it with INT 2lh,
function 9h.

int 21h
.model small
int 21h
.stack 100h
int 21h
.data
int 21h
msg db 0ah,0dh,'********** $'
int 21h
.code
main proc
mov ah,4ch
mov ax,@data
int 21h
mov ds,ax
main endp
end main
mov ah,9
lea dx,msg
int 21h
int 21h
int 21h
int 21h
int 21h
12. Write a program to (a)
display"?", (b) read three
initials,(<;) dis-
play them in the middle of an 11
x 11 box of astc:ri5ks, and (d) mov c3,al
beep the computer
mov ah,2
.model small mov dl,0ah
.stack 100h int 21h
.data mov dl,0dh
msg db '*********',0ah,0dh,'$' int 21h
msg1 db '***'
c1 db ?
mov ah,9
c2 db ?
lea dx,msg
c3 db ?, '***',0ah,0dh,'$'
int 21h
int 21h
.code
int 21h
main proc
int 21h
mov ax,@data
int 21h
mov ds,ax

mov ah,1
lea dx, msg1
int 21h
int 21h
mov c1,al
int 21h lea dx, msg
mov c2,al int 21h
int 21h
int 21h
int 21h
int 21h
int 21h

mov ah,4ch
int 21h
main endp
end main

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy