delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/09/25/22:04:03

From: NoEmailAds AT execpc DOT com (Chris Giese)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Handle software interrupts with DPMI
Date: Wed, 26 Sep 2001 01:53:52 GMT
Organization: PROPULSION GROUP
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1010924121539 DOT 25254L-100000 AT is> <3bafe2de$0$1528$272ea4a1 AT news DOT execpc DOT com>
X-Newsreader: Forte Free Agent 1.11/32.235
Lines: 41
Message-ID: <3bb1352d$0$1525$272ea4a1@news.execpc.com>
NNTP-Posting-Host: c1d339d8.news.execpc.com
X-Trace: DXC=c6\ocL]B4E]\Vgb3A6n1HU>Wd]eNKISHV0ICGTaT\Bl]=EV;d7?Dn`]_md?7I3`fAYd7jAeL2dO]PKKDEdGGlf[R>kD3P5o[1\U
X-Complaints-To: abuse AT execpc DOT com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I wrote:

>This code doesn't segfault, and the handler gets called
>(I can see the hex dump of the stack), but I don't see
>the register values I'm looking for...

Oops, got it now. The software interupt handler has a
__dpmi_regs * argument. Good ol' trial and error:


#include <stdio.h> /* printf() */
#include <dpmi.h> /* __dpmi_regs, _go32_... */
#include <go32.h> /* _my_cs() */

#define	VECT	0x32

static void syscall_int(__dpmi_regs *regs)
{	printf("%c%c%c%c%c%c", regs->h.al, regs->h.bl, regs->h.cl,
		regs->h.dl, regs->x.si, regs->x.di); }

int main(void)
{	_go32_dpmi_seginfo old, syscall;

	_go32_dpmi_get_protected_mode_interrupt_vector(VECT, &old);
	syscall.pm_selector = _my_cs();
	syscall.pm_offset = (unsigned long)syscall_int;
	_go32_dpmi_allocate_iret_wrapper(&syscall);
	_go32_dpmi_set_protected_mode_interrupt_vector(VECT, &syscall);
	__asm__ __volatile__(
		"int %0\n"
		:
		: "i"(VECT), "a"('h'), "b"('e'), "c"('l'),
			"d"('l'), "S"('o'), "D"('\n'));
	_go32_dpmi_set_protected_mode_interrupt_vector(VECT, &old);
	_go32_dpmi_free_iret_wrapper(&syscall);
	return 0; }

-- 
geezer@    | http://www.execpc.com/~geezer/osd
execpc.com | http://www.execpc.com/~geezer/os

- Raw text -


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