Mail Archives: djgpp/1999/10/04/13:08:55
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(®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()
>{
>}
__________________________________________________________
*** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/
- Raw text -