Mail Archives: djgpp/1999/10/04/10:20:53
Message-ID: | <37F871DE.C5C687E5@virtualis.com>
|
Date: | Mon, 04 Oct 1999 19:22:39 +1000
|
From: | Alex Mendes da Costa <alexmdc AT virtualis DOT com>
|
X-Mailer: | Mozilla 4.51 [en] (Win98; I)
|
X-Accept-Language: | en
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Problem with interrupts
|
NNTP-Posting-Host: | a3-p16.syd.fl.net.au
|
X-Trace: | 4 Oct 1999 19:26:18 +1000, a3-p16.syd.fl.net.au
|
Organization: | Customer of First Link Internet Services, Sydney, Australia
|
Lines: | 77
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi all again.
I don't know if this is against the rules of the list, and I'm really
sorry if it is, but I can't get this code to work. I have read through
just about all of the Documentation and FAQ and sent a few posts to this
list, but I can't get my code to work!! So if anyone would be as kind to
browse this and see where I have slipped up, I would appreciate it
greatly.
This code stuffs up my computer completely every time I try to run it,
but it compiles alright.
NOTE: I changed the asm interrupt to contain the bare essentials cause I
wasn't sure if that was the problem.
My code:
#include <stdio.h>
#include <dpmi.h>
void main();
void keyboard_handler();
void keyboard_handler_end();
char keystatus[128];
int i;
unsigned long baseaddr;
__dpmi_paddr old_keyboard_handler, new_keyboard_handler;
__dpmi_meminfo region;
void main()
{
__dpmi_get_protected_mode_interrupt_vector(0x09,
&old_keyboard_handler);
/* Lock the interrupt code */
__dpmi_get_segment_base_address(_my_cs(), &baseaddr);
region.handle = 0;
region.size = (keyboard_handler_end - keyboard_handler);
region.address = baseaddr + keyboard_handler;
__dpmi_lock_linear_region(®ion);
/* Lock the keystatus array */
__dpmi_get_segment_base_address(_my_ds(), &baseaddr);
region.handle = 0;
region.size = 128;
region.address = baseaddr + keystatus;
__dpmi_lock_linear_region(®ion);
new_keyboard_handler.offset32 = (int)keyboard_handler;
new_keyboard_handler.selector = _my_cs();
__dpmi_set_protected_mode_interrupt_vector(0x09,
&new_keyboard_handler);
i = 0;
do {
printf("%d\n",(keyboard_handler_end - keyboard_handler));
/* Endless Loop? */
} while (i == 0);
__dpmi_set_protected_mode_interrupt_vector(0x09,
&old_keyboard_handler);
}
void keyboard_handler()
{
asm("pushw %ax
movb $0x20, %al
outb %al, $0x20
popw %ax
sti
iret");
}
void keyboard_handler_end()
{
}
- Raw text -