0% found this document useful (0 votes)
218 views

System Programming - CS609 Power Point Slides Lecture 04

The document discusses interrupt interception and memory mapped I/O. It provides examples of intercepting the BIOS timer interrupt and using memory mapped I/O to write text directly to the video memory to display on the monitor screen. Memory mapped I/O allows directly reading and writing values to hardware I/O ports by accessing memory locations.

Uploaded by

Arslan
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views

System Programming - CS609 Power Point Slides Lecture 04

The document discusses interrupt interception and memory mapped I/O. It provides examples of intercepting the BIOS timer interrupt and using memory mapped I/O to write text directly to the video memory to display on the monitor screen. Memory mapped I/O allows directly reading and writing values to hardware I/O ports by accessing memory locations.

Uploaded by

Arslan
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

Another Example:

#include<BIOS.H>
#include<DOS.H>
char st[80] ={"Hello World$"};
char st1[80] ={"Hello Students!$"};
void interrupt (*oldint65)( );
void interrupt newint65( );
void main()
{
oldint65 = getvect(0x65);
setvect(0x65, newint65);
keep(0, 1000);
}
Continued:
void interrupt newint65( )
{
if (( _AH ) = = 0)
{
_AH = 0x09;
_DX = (unsigned int) st;
geninterrupt (0x21);
}
else
{
if (( _AH ) = = 1)
{
_AH = 0x09;
_DX = (unsigned int) st1;
geninterrupt (0x21);
}
}
}
2nd Program:
#include<BIOS.H>
#include<DOS.H>
void main()
{
_AH = 1;
geninterrupt (0x65);
_AH = 0;
geninterrupt (0x65);
}
Interrupt Interception
Hooks/Stealing
Execution Interrupted

ISR Perform I/O

Normal Execution of Interrupt


New Routine

Original Routine

Interrupt Interception
Original Routine

New Routine

Other form of Interrupt Interception


void Interrupt newint();
void Interrupt (*old)();
void main()
{
old=getvect(0x08);
Setvect(0x08,newint);
Keep(0,1000);
}
void interrupt newint ()
{
(*old)();
}
Timer Interrupt
Hardware Interrupts
Invoked by Means of
Hardware
Approximately occurs 18.2
times per second
BIOS Data Area
0040:0000
40:17H 7 6 5 4 3 2 1 0

Insert key
Right Shift key
Caps Lock Key Left Shift Key
Num Lock key Ctrl Key
Scroll lock key Alt Key
Keyboard Status Word
#include <dos.h>
void Interrupt (*old)();
void Interrupt new();
Char far *scr=(char far* ) 0x00400017;
Void main()
{
old=getvect(0x08);
Setvect(0x08,new);
Keep(0,1000);
}
Void interrupt new (){
*scr=64;
(*old)();
}
New Routine

Original Routine

Interrupt Interception
Memory Mapped
Isolated I/O
Isolated I/O
IN

M I/O
P

OUT
Memory Mapped I/O
MOV

M I/O
P

MOV
Memory Mapped I/O ON Monitor
B8OO:0002
B8OO:0003
B8OO:0000
B8OO:0001

Low Byte = ASCII CODE


High Byte =Attribute Byte
Memory Mapped I/O ON Monitor
fore color
Blink X X X X X X X X

Back Color Color


Bold
Low Byte = Ascii Code 000 Black
High Byte = Attribute Byte 100 Red
010 Green
001 Blue
111 White
unsigned int far *scr=0xb8000000;

void main()
{

(*scr)=0x0756;
(*(scr+1))=0x7055;

You might also like