Message-ID: <001901c1651f$df3887a0$4bd24dd5@piec>
From: "Piotr Fusik"
To:
Subject: Keyboard interrupt
Date: Sun, 4 Nov 2001 11:55:06 +0100
MIME-Version: 1.0
Content-Type: text/plain;
charset="windows-1250"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
X-Virus-Scanned: by AMaViS perl-11 elektron
Reply-To: djgpp AT delorie DOT com
Hello,
I compile following code with gcc 2.95.3 with -O2.
The key_handler function has no stack variables, but gcc does some
optimizations, which result in using the stack. I noticed that this causes
Win 98 crashes. If the stack is not used, it works.
I tried removing asm's, but it didn't help. The code is not mine, so don't
ask why it's done that way.
What's wrong?
unsigned int raw_key_r;
_go32_dpmi_seginfo old_key_handler, new_key_handler;
void key_handler(void)
{
asm("cli; pusha");
raw_key_r = inportb(0x60);
// ...
outportb(0x20, 0x20);
asm("popa; sti");
}
void key_init(void)
{
new_key_handler.pm_offset = (int) key_handler;
new_key_handler.pm_selector = _go32_my_cs();
_go32_dpmi_get_protected_mode_interrupt_vector(0x9, &old_key_handler);
_go32_dpmi_allocate_iret_wrapper(&new_key_handler);
_go32_dpmi_set_protected_mode_interrupt_vector(0x9, &new_key_handler);
}
void key_delete(void)
{
_go32_dpmi_set_protected_mode_interrupt_vector(0x9, &old_key_handler);
}