0% found this document useful (0 votes)
46 views3 pages

Programa

This document contains 3 examples of C code that handle keyboard interrupts in DOS. The code in each example installs and uninstalls interrupt handlers for keyboard interrupts. When a keyboard interrupt occurs, the interrupt handler saves the pressed key and displays it on the screen. The first example only handles key presses, while the second and third examples also track the number of key presses and display the count when a key is pressed.

Uploaded by

Clei Shin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views3 pages

Programa

This document contains 3 examples of C code that handle keyboard interrupts in DOS. The code in each example installs and uninstalls interrupt handlers for keyboard interrupts. When a keyboard interrupt occurs, the interrupt handler saves the pressed key and displays it on the screen. The first example only handles key presses, while the second and third examples also track the number of key presses and display the count when a key is pressed.

Uploaded by

Clei Shin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Ejemplo 2

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <dos.h>

void InstalaRSI(void);
void DesinstalaRSI(void);
void interrupt RSITeclado(void);
void Mostrararacter(int c! int "! int #);

void interrupt ($pRSI)(void);
int IMR;
int ontInt % &;

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
int 'ain(void)
(
int Tecla;

InstalaRSI();

)hile(*)
(
Tecla % +etch();
i,(-&-<%Tecla .. Tecla<%-/-) ;
else
(
i,(Tecla %% 01)
2rea3;
putch(Tecla);
4
4

DesinstalaRSI();
return &;
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void InstalaRSI(void)
(
disa2le();

pRSI % +etvect(/);
setvect(/!RSITeclado);

IMR % inport2(&"0*);
outport2(&"0*!IMR . &"5D);

ena2le();
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void DesinstalaRSI(void)
(
disa2le();

setvect(/!pRSI);

outport2(&"0*!IMR);

ena2le();
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void interrupt RSITeclado(void)
(
($pRSI)();

ontInt66;
i,(ontInt %% *&)
ontInt % &;

Mostrararacter(ontInt6-&-!1/!&);

outport2(&"0&!&"0&);//78I
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void Mostrararacter(int c! int "! int #)
(
unsi+ned char ,ar $p % (unsi+ned char ,ar $)&"29&&&&&&;
p % p 6 0$(9&$# 6 ");
$p % c;
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Ejemplo 3
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <dos.h>

void InstalaRSI(void);
void DesinstalaRSI(void);
void interrupt RSITi'er&(void);
void Mostrararacter(int c! int "! int #);

void interrupt ($pRSI)(void);
int IMR;
int ontInt % &;
int ont:ant % &;

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
int 'ain(void)
(
int Tecla;

InstalaRSI();

)hile(*)
(
Tecla % +etch();
i,(-&-<%Tecla .. Tecla<%-/-) ;
else
(
i,(Tecla %% 01)
2rea3;
putch(Tecla);
4
4
DesinstalaRSI();
return &;
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void InstalaRSI(void)
(
disa2le();

pRSI % +etvect(9);
setvect(9!RSITi'er&);
IMR % inport2(&"0*);
outport2(&"0*!IMR . &"57);
ena2le();
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void DesinstalaRSI(void)
(
disa2le();
setvect(9!pRSI);
outport2(&"0*!IMR);
ena2le();
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void interrupt RSITi'er&(void)
(
($pRSI)();

ontInt66;
i,(ontInt %% *9)
(
ontInt % &;

ont:ant66;
i,(ont:ant %% *&)
ont:ant % &;
Mostrararacter(ont:ant6-&-!1/!&);
4
outport2(&"0&!&"0&);//78I
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void Mostrararacter(int c! int "! int #)
(
unsi+ned char ,ar $p % (unsi+ned char ,ar $)&"29&&&&&&;
p % p 6 0$(9&$# 6 ");
$p % c;
4
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Ejemplo 1
#include <stdio.h>
int 'ain(void)
(
int Tecla;

)hile(*)
(
Tecla % +etch();
i,(-&-<%Tecla .. Tecla<%-/-) ;
else
(
i,(Tecla %% 01)
2rea3;
putch(Tecla);
4
4
return &;
4

You might also like