delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/04/13:08:55

From: DavMac AT iname DOT com (Davin McCall)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem with interrupts
Date: Mon, 04 Oct 1999 13:28:22 GMT
Organization: Monash Uni
Lines: 95
Distribution: world
Message-ID: <37f8ab24.16939224@newsserver.cc.monash.edu.au>
References: <37F871DE DOT C5C687E5 AT virtualis DOT com>
NNTP-Posting-Host: damcc5.halls.monash.edu.au
X-Trace: towncrier.cc.monash.edu.au 939043700 5570 130.194.198.138 (4 Oct 1999 13:28:20 GMT)
X-Complaints-To: abuse AT monash DOT edu DOT au
NNTP-Posting-Date: 4 Oct 1999 13:28:20 GMT
X-Newsreader: Forte Free Agent 1.1/32.230
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I wouldn't be surprised if gcc is generating a stack frame for your
"keyboard_handler" function, and the "iret" instruction is stuffing up
because of that.

You should really write that function in a seperate file (assembly)
and assemble it with "as", then link it with your C code.

Davin.



On Mon, 04 Oct 1999 19:22:39 +1000, Alex Mendes da Costa
<alexmdc AT virtualis DOT com> wrote:

>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(&region);
>
>  /* 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(&region);
>
>  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()
>{
>}

__________________________________________________________
       *** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/

- Raw text -


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