<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [fpc-pascal]DXE demo uploaded</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Okies, thanks for the usefull information!</FONT>
</P>
<P><FONT SIZE=2>I need DXEs for DOS version Pixel32 (<A HREF="http://pixel32.box.sk" TARGET="_blank">http://pixel32.box.sk</A>), this should be first DOS application supporting plugins :))</FONT></P>
<P><FONT SIZE=2>Regards, Pavel Kanzelsberger</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: marcov@stack.nl [<A HREF="mailto:marcov@stack.nl">mailto:marcov@stack.nl</A>] </FONT>
<BR><FONT SIZE=2>Sent: Friday, July 20, 2001 2:23 PM</FONT>
<BR><FONT SIZE=2>To: fpc-pascal@deadlock.et.tudelft.nl</FONT>
<BR><FONT SIZE=2>Subject: Re: [fpc-pascal]DXE demo uploaded</FONT>
</P>
<BR>
<P><FONT SIZE=2>> Great job, it works!!</FONT>
<BR><FONT SIZE=2>> Anyway I found that Stack checking must be turned off, otherwise </FONT>
<BR><FONT SIZE=2>> DXEGEN cannot process STACKCHECK symbol in .o file...</FONT>
</P>
<P><FONT SIZE=2>It is the same problem as mentioned in the prev. msg. Internal procedures fail. A workaround could be:</FONT>
</P>
<P><FONT SIZE=2>What do you want to use DXE for? What kind of code do you want to put in the DXE?</FONT>
</P>
<P><FONT SIZE=2>----------------------------------------------------------</FONT>
<BR><FONT SIZE=2>Untested:</FONT>
</P>
<P><FONT SIZE=2>Use this in your DXE code:</FONT>
</P>
<P><FONT SIZE=2>type ThandleerrorProc = procedure (Errno:longint);</FONT>
</P>
<P><FONT SIZE=2>var remotestkbottom : ^longint; </FONT>
<BR><FONT SIZE=2> remotehandleerror : THandleErrorProc;</FONT>
</P>
<P><FONT SIZE=2>procedure int_stackcheck(stack_size:longint);[public,alias:'FPC_STACKCHECK'];</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR><FONT SIZE=2> called when trying to get local stack if the compiler directive $S</FONT>
<BR><FONT SIZE=2> is set this function must preserve esi !!!! because esi is set by</FONT>
<BR><FONT SIZE=2> the calling proc for methods it must preserve all registers !!</FONT>
</P>
<P><FONT SIZE=2> With a 2048 byte safe area used to write to StdIo without crossing</FONT>
<BR><FONT SIZE=2> the stack boundary</FONT>
<BR><FONT SIZE=2>}</FONT>
<BR><FONT SIZE=2>begin</FONT>
<BR><FONT SIZE=2> asm</FONT>
<BR><FONT SIZE=2> pushl %eax</FONT>
<BR><FONT SIZE=2> pushl %ebx</FONT>
<BR><FONT SIZE=2> movl stack_size,%ebx</FONT>
<BR><FONT SIZE=2> addl $2048,%ebx</FONT>
<BR><FONT SIZE=2> movl %esp,%eax</FONT>
<BR><FONT SIZE=2> subl %ebx,%eax</FONT>
<BR><FONT SIZE=2> movl remotestkbottom,%ebx</FONT>
<BR> <FONT SIZE=2>movl (%ebx),%ebx</FONT>
<BR><FONT SIZE=2> cmpl %eax,%ebx</FONT>
<BR><FONT SIZE=2> jae .L__short_on_stack</FONT>
<BR><FONT SIZE=2> popl %ebx</FONT>
<BR><FONT SIZE=2> popl %eax</FONT>
<BR><FONT SIZE=2> leave</FONT>
<BR><FONT SIZE=2> ret $4</FONT>
<BR><FONT SIZE=2>.L__short_on_stack:</FONT>
<BR><FONT SIZE=2> { can be usefull for error recovery !! }</FONT>
<BR><FONT SIZE=2> popl %ebx</FONT>
<BR><FONT SIZE=2> popl %eax</FONT>
<BR><FONT SIZE=2> RemoteHandleError(202)</FONT>
<BR><FONT SIZE=2> end['EAX','EBX'];</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>end;</FONT>
</P>
<P><FONT SIZE=2>-----------------------</FONT>
<BR><FONT SIZE=2>And then your main program should </FONT>
</P>
<P><FONT SIZE=2>have </FONT>
</P>
<P><FONT SIZE=2>var</FONT>
<BR><FONT SIZE=2> stkbottom : longint;external name '__stkbottom';</FONT>
</P>
<P><FONT SIZE=2>and via DXE calls you should set </FONT>
</P>
<P><FONT SIZE=2>remotestkbottom to @stkbottom;</FONT>
<BR><FONT SIZE=2>remotehandleerro to @handleerror;</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>fpc-pascal maillist - fpc-pascal@lists.freepascal.org <A HREF="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" TARGET="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</A></FONT>
</P>
</BODY>
</HTML>