Mplab 8086

You might also like

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 7

Tribhuvan University

Institute of Engineering
Thapathali Campus, Thapathali

Subject: Microprocessor
LAB 6
8086 Programming

Submitted by:
Name: Shishir Gaire
Roll No.: THA078BEI044

Submitted to:
Department of Electronics and Computer Engineering
Date: 21st Falgun 2079
In the microprocessor 8086, the interrupt vector table is a reserved block of memory locations in
the range of memory addresses from 0000h to 03FFh. The interrupt vector table contains 256
entries, each 4 bytes long, which correspond to the various software and hardware interrupts
that the processor can recognize.
The entries in the interrupt vector table for interrupts INT 01h through INT 10h are as follows:
● INT 01h: This interrupt is reserved for debugging purposes and is not used by most
software programs. The entry in the interrupt vector table for INT 01h points to the
address of the interrupt service routine (ISR) for this interrupt.

● INT 02h: This interrupt is used by the BIOS to control the system's floppy disk drives.
The entry in the interrupt vector table for INT 02h points to the address of the ISR for this
interrupt.

● INT 03h: This interrupt is used by the DOS operating system to allow software programs
to invoke a debugger. The entry in the interrupt vector table for INT 03h points to the
address of the ISR for this interrupt.

● INT 04h: This interrupt is used by the BIOS to control the system's serial ports. The entry
in the interrupt vector table for INT 04h points to the address of the ISR for this interrupt.

● INT 05h: This interrupt is used by the BIOS to control the system's parallel ports. The
entry in the interrupt vector table for INT 05h points to the address of the ISR for this
interrupt.
● INT 06h: This interrupt is used by the BIOS to control the system's floppy disk drives.
The entry in the interrupt vector table for INT 06h points to the address of the ISR for this
interrupt.

● INT 07h: This interrupt is used by the DOS operating system to perform print spooling.
The entry in the interrupt vector table for INT 07h points to the address of the ISR for this
interrupt.

● INT 08h: This interrupt is used by the BIOS to read the system's real-time clock. The
entry in the interrupt vector table for INT 08h points to the address of the ISR for this
interrupt.

● INT 09h: This interrupt is used by the DOS operating system to handle keyboard input.
The entry in the interrupt vector table for INT 09h points to the address of the ISR for this
interrupt.

● INT 0Ah: This interrupt is used by the DOS operating system to handle printer output.
The entry in the interrupt vector table for INT 0Ah points to the address of the ISR for
this interrupt.
Each ISR is a piece of code that handles a specific interrupt request. When an interrupt occurs,
the processor looks up the appropriate ISR in the interrupt vector table and jumps to its address
to handle the interrupt.

Problem 1
Write a program to print Programming is Fun with carriage return.

Programming
Is
Fun

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

; output "Programming" on a new line


mov ah, 09h
lea dx, programming
int 21h

mov dl, 0Ah


mov ah, 02h
int 21h

; output "is" on a new line


mov ah, 09h
lea dx, is
int 21h

mov dl, 0Ah


mov ah, 02h
int 21h

; output "fun" on a new line


mov ah, 09h
lea dx, fun
int 21h

mov ah, 4Ch


int 21h
main endp

.data
programming db 'Programming$'
is db 'is$'
fun db 'fun$'
end main

Problem 2
Write a program to print Programming is Fun without carriage return.

Programming
Is
Fun

Program

.model small
.stack 100h
.data
msg1 db 'Programming','$'
msg2 db 'Is','$'
msg3 db 'Fun','$'
.code
main proc
mov ax, @data
mov ds,ax

mov dx,OFFSET msg1


mov ah,9h
int 21h

mov dx,10
mov ah,2
int 21h

mov dx, offset msg2


mov ah,09h
int 21h

mov dx,10
mov ah,2
int 21h

mov dx, offset msg3


mov ah,09h
int 21h
mov ah,4ch

int 21h
main endp
end main

Program 3:
Write Assembly level program to print Hello World with different color text in different
background.

.model small
.stack 100h
.data
hello_message db "Hello World","$"
.code

main proc
mov ax,@data
mov ds,ax
mov ah,09h
mov b1,9
moc cx,12
int 10h

mov dx, offset hello_message


int 21h

mov ah,09h
mov b1,0e4h
mov cx,12
int 10
mov dx, offset hello_message
int 21h

mov ah,09h
mov b1,0a4h
mov cx,12
int 10h

mov dx, offset hello_message


int 21h

mov ax,4c00h
int 21h
main endp
end main

Discussion for problem 3:


This 8086 program is meant to print "Hello World" on the screen using various BIOS and DOS interrupts.
Here is what the program does.
The program starts by defining its memory model as "small" and the size of the stack as 100h. The
"hello_message" variable is defined in the data section and is initialized with the string "Hello World"
terminated by a "$" character. The main procedure starts by setting the data segment register (DS) to
point to the data segment.
The program then uses the BIOS interrupt 10h, function 09h to print a rectangle made of characters to the
screen. The "b1" variable is set to 9, which represents the ASCII value of the character used to draw the
rectangle. The "cx" variable is set to 12, which represents the number of times the character should be
printed horizontally.
The program then uses the DOS interrupt 21h, function 09h to print the "hello_message" string to the
screen. The program repeats step 4 and 5, but with a different character for the rectangle and a different
color for the text. Finally, the program uses the DOS interrupt 21h, function 4Ch to terminate itself.
Note: There seems to be a typo in the program where "moc" should be "mov" when initializing the CX
register.

Discussion:
In this lab report, we have studied software interrupts in the context of the 8086 microprocessor.
Software interrupts are a way for the program to communicate with the operating system or
other software components by invoking a specific interrupt vector. The interrupt vector is a
predefined memory address that contains the starting address of the interrupt service routine
(ISR) that handles the interrupt request.
In the lab, we have written a simple program that demonstrates the use of software interrupts in
the 8086 microprocessor. Specifically, we have used the INT instruction to invoke software
interrupt 21h, which is used to call the DOS function for displaying a character on the screen.
We have also used the AH and AL registers to specify the function and the character code,
respectively.
We have observed that the use of software interrupts can simplify the programming of complex
tasks, as the programmer can rely on the operating system or other software components to
provide specific services. Moreover, software interrupts can be used to implement a form of
multitasking, where the program can switch between different tasks by invoking different
interrupt vectors.

Conclusion:
In conclusion, software interrupts are an essential feature of the 8086 microprocessor and other
similar architectures. They provide a way for the program to communicate with the operating
system or other software components, which can simplify the programming of complex tasks.
Moreover, software interrupts can be used to implement a form of multitasking, which is useful
in many applications.
The lab has demonstrated the use of software interrupts in a simple program, but their
applications are much broader. In practice, software interrupts are used extensively in operating
systems, device drivers, and other software components that require interaction with hardware
or other software components. Therefore, understanding the concept of software interrupts is
crucial for any programmer working with the 8086 microprocessor or similar architectures.

You might also like