Re: dos_interrupt

new topic     » goto parent     » topic index » view thread      » older message » newer message

This is a multi-part message in MIME format.

------=_NextPart_000_0009_01C2DE7F.879818A0
	charset="iso-8859-1"


-- The following calls an interrupt thru the DPMI 0300h function
-- it uses 32 bit registers.
-- This works with ex.exe, it may work with exw.exe and win95/98.
-- It will not work with exw.exe and win ME=20
--
-- See Ralf Brown's Interrupt List for more information on DPMI =
functions.
-- Another good source for info on protected mode programming is Dieter =
Pawelczak's
-- Pass32/Pro32 assembler/extender and documentation, it's free.


constant=20
REG_EDI =3D   #00,
REG_ESI =3D   #04,
REG_EBP =3D   #08,
                      -- reserved  =3D #0C should be (00h)
REG_EBX =3D   #10,
REG_EDX =3D   #14,
REG_ECX =3D   #18,
REG_EAX =3D   #1C,
REG_flags =3D #20,
REG_ES =3D    #22,
REG_DS =3D    #24,
REG_FS =3D    #26,
REG_GS =3D    #28,
REG_IP =3D    #2A,      -- used by 0301h & 0302h only
REG_CS =3D    #2C,      --            "
REG_SP =3D    #2E,      -- (00h) use default stack
REG_SS =3D    #30       -- (00h)        "
                      -- dummy =3D #32  word for alignment (00h)

atom xfrblk  xfrblk =3D allocate(#34)

integer intn  intn =3D 0

sequence int31_code                  -- DosProtectedModeInterface
int31_code =3D
   {#50,                             -- push    eax
    #53,                             -- push    ebx
    #51,                             -- push    ecx
    #57,                             -- push    edi
    #06,                             -- push    es
    #66,#B8,#00,#03} &               -- mov     ax,#0300    ; Call Real =
Mode Interrupt
   {#8B,#1D} & int_to_bytes(intn) &  -- mov     ebx,[intn]  ; interrupt =
to execute
   {#33,#C9} &                       -- xor     ecx,ecx
   {#BF} & int_to_bytes(xfrblk) &    -- mov     edi,offset xfrblk
   {#1E,                             -- push    ds
    #07,                             -- pop     es          ; es:edi =
pointer to xfrblk
    #CD,#31,                         -- int     31
    #07,                             -- pop     es
    #5F,                             -- pop     edi
    #59,                             -- pop     ecx
    #5B,                             -- pop     ebx
    #58,                             -- pop     eax
    #C3}                             -- ret

atom int31
int31 =3D allocate(length(int31_code))
poke(int31,int31_code)


procedure call_DPMI300(integer interrupt_number)
     poke(intn,interrupt_number)
     call(int31)                   -- on return xfrblk will hold results
end procedure


-- Example:

poke4(xfrblk+REG_EAX,#00003000)    -- Get MS-DOS Version Number

call_DPMI300(#21)

printf( 1, "DOS Version: %d.%d\n",
        {remainder(peek4u(xfrblk+REG_EAX),#100),
         floor(peek4u(xfrblk+REG_EAX)/#100)} )



------=_NextPart_000_0009_01C2DE7F.879818A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff><FONT size=3D2>
<DIV><BR><FONT face=3D"Courier New">-- The following calls an interrupt =
thru the=20
DPMI 0300h function<BR>-- it uses 32 bit registers.<BR>-- This works =
with=20
ex.exe, it may work with exw.exe and win95/98.<BR>-- It will not work =
with=20
exw.exe and win ME <BR>--<BR>-- See Ralf Brown's Interrupt List for more =

information on DPMI functions.<BR>-- Another good source for info on =
protected=20
mode programming is Dieter Pawelczak's<BR>-- Pass32/Pro32 =
assembler/extender and=20
documentation, it's free.</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3D"Courier New">constant <BR>REG_EDI =3D&nbsp;&nbsp; =

#00,<BR>REG_ESI =3D&nbsp;&nbsp; #04,<BR>REG_EBP =3D&nbsp;&nbsp;=20
#08,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- reserved&nbsp; =3D #0C should be (00h)<BR>REG_EBX =3D&nbsp;&nbsp; =
#10,<BR>REG_EDX=20
=3D&nbsp;&nbsp; #14,<BR>REG_ECX =3D&nbsp;&nbsp; #18,<BR>REG_EAX =
=3D&nbsp;&nbsp;=20
#1C,<BR>REG_flags =3D #20,<BR>REG_ES =3D&nbsp;&nbsp;&nbsp; =
#22,<BR>REG_DS=20
=3D&nbsp;&nbsp;&nbsp; #24,<BR>REG_FS =3D&nbsp;&nbsp;&nbsp; =
#26,<BR>REG_GS=20
=3D&nbsp;&nbsp;&nbsp; #28,<BR>REG_IP =3D&nbsp;&nbsp;&nbsp;=20
#2A,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- used by 0301h &amp; 0302h =
only<BR>REG_CS=20
=3D&nbsp;&nbsp;&nbsp; #2C,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
"<BR>REG_SP=20
=3D&nbsp;&nbsp;&nbsp; #2E,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- (00h) use =
default=20
stack<BR>REG_SS =3D&nbsp;&nbsp;&nbsp; =
#30&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --=20
(00h)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- dummy =3D #32&nbsp; word for alignment (00h)</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New">atom xfrblk&nbsp; xfrblk =3D=20
allocate(#34)</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New">integer intn&nbsp; intn =3D =
0</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New">sequence=20
int31_code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- DosProtectedModeInterface<BR>int31_code =3D<BR>&nbsp;&nbsp;=20
{#50,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- push&nbsp;&nbsp;&nbsp; eax<BR>&nbsp;&nbsp;&nbsp;=20
#53,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- push&nbsp;&nbsp;&nbsp; ebx<BR>&nbsp;&nbsp;&nbsp;=20
#51,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- push&nbsp;&nbsp;&nbsp; ecx<BR>&nbsp;&nbsp;&nbsp;=20
#57,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- push&nbsp;&nbsp;&nbsp; edi<BR>&nbsp;&nbsp;&nbsp;=20
#06,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- push&nbsp;&nbsp;&nbsp; es<BR>&nbsp;&nbsp;&nbsp; #66,#B8,#00,#03}=20
&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;=20
-- mov&nbsp;&nbsp;&nbsp;&nbsp; ax,#0300&nbsp;&nbsp;&nbsp; ; Call Real =
Mode=20
Interrupt<BR>&nbsp;&nbsp; {#8B,#1D} &amp; int_to_bytes(intn) &amp;&nbsp; =
--=20
mov&nbsp;&nbsp;&nbsp;&nbsp; ebx,[intn]&nbsp; ; interrupt to=20
execute<BR>&nbsp;&nbsp; {#33,#C9}=20
&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- xor&nbsp;&nbsp;&nbsp;&nbsp; ecx,ecx<BR>&nbsp;&nbsp; {#BF} &amp;=20
int_to_bytes(xfrblk) &amp;&nbsp;&nbsp;&nbsp; -- =
mov&nbsp;&nbsp;&nbsp;&nbsp;=20
edi,offset xfrblk<BR>&nbsp;&nbsp;=20
{#1E,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New">atom int31<BR>int31 =3D=20
allocate(length(int31_code))<BR>poke(int31,int31_code)</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3D"Courier New">procedure call_DPMI300(integer=20
interrupt_number)<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
poke(intn,interrupt_number)<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
call(int31)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- on return xfrblk will hold results<BR>end procedure</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3D"Courier New">-- Example:</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier =
New">poke4(xfrblk+REG_EAX,#00003000)&nbsp;&nbsp;&nbsp;=20
-- Get MS-DOS Version Number</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New">call_DPMI300(#21)</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New">printf( 1, "DOS Version:=20
%d.%d\n",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{remainder(peek4u(xfrblk+REG_EAX),#100),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
floor(peek4u(xfrblk+REG_EAX)/#100)} )</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>

------=_NextPart_000_0009_01C2DE7F.879818A0--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu