delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/11/04/06:03:54

Message-ID: <001901c1651f$df3887a0$4bd24dd5@piec>
From: "Piotr Fusik" <P DOT Fusik AT elka DOT pw DOT edu DOT pl>
To: <djgpp AT delorie DOT com>
Subject: Keyboard interrupt
Date: Sun, 4 Nov 2001 11:55:06 +0100
MIME-Version: 1.0
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);
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019