You are on page 1of 5

Computer Organization and Assembly Language

Question # 1:
Write ReadChar and WriteChar procedures

Code:
WriteChar proc ReadChar proc

Mov ah,02 Mov ah,01

Int 21h Int 21h

Ret Ret

WriteChar endp ReadChar endp

Question # 2:
Write a program in which first you display a prompt message “Please enter your name:”
on screen using writechar procedure that you write. Then you get the name in a buffer in your
program by using readchar procedure that you write. After that you display a greeting
“welcome to assembly language lab” followed by the name entered, using writechar.

Code:
Dosseg .code

.model small main proc

.stack 100h mov ax,@data

.data mov ds,ax

string1 db 'Please enter your name: ',0 mov cx,25

string2 db 'Welcome to Assembly Language Lab lea si,string1


',0
l1: mov dl,[si]
string3 db 10 dup(?)
call WRITECHAR
inc si mov cx,40

dec cx lea si,string2

jnz l1 l3: mov dl,[si]

lea si,string3 call WRITECHAR

l2: call READCHAR inc si

cmp al,13 dec cx

je stringend jnz l3

mov [si],al mov ah,4ch

inc si int 21h

jnz l2 main endp

stringend: end main

Question # 3:
Write a program in which first you display a prompt message “Please enter your name:” on
screen using Writechar procedure that you write. Then you get the name in buffer in your
program by using Readchar procedure that you write. After that you display a greeting
“Welcome to assembly language lab” followed by the name entered.

Code:
Dosseg .code

.model small main proc

.stack 100h mov ax,@data

.data mov ds,ax

string1 db 'Please enter your name: ',0 mov cx,25

string2 db 'Welcome to Assembly Language Lab lea si,string1


',0
l1: mov dl,[si]
string3 db 10 dup(?)
call WRITESTRING
inc si lea si,string2

dec cx l3: mov dl,[si]

jnz l1 call WRITECHAR

lea si,string3 inc si

l2: call READSTRING dec cx

cmp al,13 jnz l3

je stringend mov ah,4ch

mov [si],al int 21h

inc si main endp

jnz l2 end main

stringend: mov cx,42

Question # 4:
Write two procedures isCapital and isSmall which return true / false by setting / clearing carry
flag.

Both of these procedures receive ASCII character is AL on calling, which is tested by the
procedures and true / false is returned accordingly.

Code:
isSmall proc int 21h

mov ah,01 cmp al,122

int 21h jle convert

cmp al,97

jge convert convert:

sub al,32

isCapital proc mov dl,al

mov ah,01 mov ah,02


int 21h
Question # 5:
Write a procedure that tests ASCII value in AL for being a digit in the range “0 – 9” and return
true/false be setting/clearing Z flag.

Code:
.model small

.stack 100h

.data

.code

main proc

mov cx,10

mov dx,48

l1:

mov ah,2

int 21h

inc dx

dec cx

jnz l1

mov ah,4ch

int 21h

main endp

end main

You might also like