8086 Lab Questions with solution

1. Write a program for 16 bit microprocessor to find factorial of a given number.

MOV AL, 05H
MOV CL, AL
DEC CL
Back: MUL CL
LOOP Back
; Results stored in AX
; To store the result at D000H
MOV [1000], AX
HLT

2. Write a program to character entered from the keyboard.

.org 100h
.code
start:
mov ah, 1h ; keyboard input subprogram
int 21h ; read character into al
mov dl, al
mov ah, 2h ; display subprogram
int 21h ; display character in dl
mov ax, 4c00h ; return to ms-dos
int 21h
end start

3. Write a program to display string “Computer Science”.

Title display the string
.model small
org 100h
.data
String1 db "Computer Science$"
.code
main Disp proc
mov ax,@data
mov ds,ax
mov ah,09h
mov dx,offset String1
int 21h
mov ah,4ch
mov al,00h
int 21h
endp
end main

4. Write a program to display reverse of a given string “Computer Science”.

.model small
org 100h
.data
String1 db 'Computer Science $'
Length dw $-String1-1
.code
Main proc
MOV AX, @data
MOV DS, AX
MOV SI, offset String1
MOV CX, Length
ADD SI, CX
Back: MOV DL, [SI]
MOV AH, 02H
INT 21H
DEC SI
LOOP Back
MOV AH, 4CH
INT 21H
Main endp
End Main

5. Write a program to convert a given string “Computer Science” to uppercase.

model small
.stack 100h
.data
String1 db 'Computer Science$'
Length EQU $-String1-1
.code
Main proc
MOV AX, @data
MOV DS, AX
MOV SI, offset String1
MOV CX, Length
Back:MOV DL,[SI]
CMP DL,'a'
JC Conv
SUB DL,20h;
CONV:MOV AH, 02H
INT 21H
INC SI
LOOP Back
MOV AH, 4CH
INT 21H
Main endp
End Main

6. Write a program to convert a given string “Computer Science” to lowercase.

model small
.stack 100h
.data
String1 db 'Computer Science$'
Length EQU $-String1-1
.code
Main proc
MOV AX, @data
MOV DS, AX
MOV SI, offset String1
MOV CX, Length
Back:MOV DL,[SI]
CMP DL,'a'
JNC Conv
ADD DL,20h;
CONV:MOV AH, 02H
INT 21H
INC SI
LOOP Back
MOV AH, 4CH
INT 21H
Main endp
End Main

7. Write a program to count and display occurrence of character ‘e’ in the given string “Computer Science”.

Title string operation Dosseg
.model small
.stack 100h
.data
String db ‘exercise$’
Ans db ?
Length db $-String
.code Main proc
MOV AX, @data MOV DS, AX MOV AL,00H
MOV SI, offset String MOV CX, Length
Back: MOV BH, [SI]
CMP BH, ‘e’
JNZ Label INC AL
Label: INC SI
LOOP Back MOV Ans, AL MOV AH, 4CH INT 21H
Main endp End Main
end main

0 Comments