You are on page 1of 10

Lab Report

Department of CSE
Course Title: Microprocessor & Assembly language lab
Course Code: CSE 232

SUBMITTED TO :
Tapasy Rabeya
Department of CSE

SUBMITTED BY :
Nashed Shah Roni
ID: 181-15-11170
Section: P ; Batch : 49

Submission Date:15 December 2019


(a) write an assembly code for case conversion.

.model small
.stack 100h
.data
cr equ 0dh
lf equ 0ah
msg1 db 'Enter a lower case letter:$'
msg2 db 0dh,0ah,'in upper case letter:'
char db ?,'$'

.code
main proc
mov ax,@data
mov ds,ax

lea dx,msg1
mov ah,9
int 21h

mov ah,1
int 21h
sub al,20h
mov char,al

lea dx,msg2
mov ah,9
int 21h

mov ah,4ch
int 21h

main endp

(b)write an assembly code to reverse a string.


.model small
.stack 100h
.data
msg db "DAFFODIL"
.code

main proc
mov ax,@data
mov ds,ax

mov si,offset msg


mov si,7
mov cx,8

top:
mov ax,[si]
add ax,20h
mov dx,ax
mov ah,2h
int 21h
dec si
loop top
exit:

(c)write an assembly code for printing a rectangle by star.


.model small
.stack 100h
.data
.code
main proc

mov ah,2

mov cx,5
mov bx,5

Top:

mov dl,'*'
mov ah,2
int 21h
dec bx

cmp bx,0
je Top2

jmp Top

Top2:
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h

mov bx,5
loop Top
Exit:
(d)write an assembly code for printing a triangle by star.

.model small
.stack 100h
.data
.code
main proc

mov ah,2

mov bx,5
mov cx,5

loop1:

mov ah,2
mov dl,'*'
int 21h
dec bx

cmp bx,0
je loop2

jmp loop1

loop2:
mov dl,0ah
int 21h
mov dl,0dh
int 21h

mov bx,cx
dec bx
loop loop1

exit:

(e)write an assembly code for printing a pyramid by star.

.model small
.stack 100h
.data
nl db 10,13,'$'
.code
main proc
mov ax,@data
mov ds,ax

mov cx,5
mov bx,1

f1:
push cx

mov dl,20h
mov ah,2

f2:
int 21h
loop f2

mov cx,bx
mov dl,'*'
mov ah,2

f3:
int 21h
loop f3

lea dx,nl
mov ah,9
int 21h

inc bx
inc bx
pop cx

loop f1

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

(f) Read a character, and if its an uppercase letter, display it.

.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'Enter the character : $'
MSG_1 DB 'The input letter is : $'
MSG_2 DB 'The input character is not an Upper Case Letter.$'

.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT


MOV AH, 9
INT 21H

MOV AH, 1
INT 21H

MOV BL, AL

MOV AH, 2
MOV DL, 0DH
INT 21H

MOV DL, 0AH


INT 21H

CMP BL, "A"

JB @DISPLAY

CMP BL, "Z"

JA @DISPLAY

LEA DX,MSG_1
MOV AH, 9
INT 21H

MOV AH, 2
MOV DL, BL
INT 21H

JMP @EXIT

@DISPLAY:
LEA DX,MSG_2
MOV AH, 9
INT 21H

@EXIT:
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN

(g)write an assembly code to read characters until a blank is read.

.model small
.stack 100h
.data
.code
main proc

input:
mov ah,1
int 21h

cmp al," "


jne input

exit:

(h)write an assembly code to count the number of character in an


input line
.model small
.stack 100h
.data
.code

main proc

mov bl,0
mov ah,1
int 21h

L1:
cmp al,0dh
je end
inc bl
int 21h
jmp L1

end:
mov ah,2
mov dl,10
int 21h
mov dl,13
int 21h

mov ah,2
add bl,48
mov dl,bl
int 21h
exit:
mov ah,4ch
int 21h

endp main

(i)write an assembly code to print star depend on input number.


.MODEL SMALL
.STACK 100H
.CODE
MAIN PROC

MOV AH,1
INT 21H
MOV BL,AL
SUB bl,30H
MOV CX,bx

MOV AH,2
MOV DL,'*'

TOP:
INT 21H
dec cx
jnz TOP

EXIT:

MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN

(j)write an assembly code for if AL contains 1 or 3 display "Odd"


if AL contains 2 or 4 display "Even".

.model small
.stack 100h
.data
a db 0dh,0ah,'Enter the number $'
b db 0dh,0ah,'The number is even $'
c db 0dh,0ah,'The number is odd $'
.code
main proc
mov ax,@data
mov ds,ax

lea dx,a
mov ah,9
int 21h

mov ah,1
int 21h

cmp al,'2'
je l

cmp al,'4'
je l

cmp al,'6'
je l

cmp al,'8'
je l

lea dx,c
mov ah,9
int 21h
jmp exit

l:
lea dx,b
mov ah,9
int 21h

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

You might also like