[fpc-pascal]DXE demo uploaded

Marco van de Voort marcov at stack.nl
Fri Jul 20 14:22:48 CEST 2001


> Great job, it works!!
> Anyway I found that Stack checking must be turned off, otherwise DXEGEN
> cannot process STACKCHECK symbol in .o file...

It is the same problem as mentioned in the prev. msg. Internal procedures
fail. A workaround could be:

What do you want to use DXE for? What kind of code do you want to put in the
DXE?

----------------------------------------------------------
Untested:

Use this in your DXE code:

type ThandleerrorProc = procedure (Errno:longint);

var remotestkbottom : ^longint;  
    remotehandleerror : THandleErrorProc;

procedure int_stackcheck(stack_size:longint);[public,alias:'FPC_STACKCHECK'];
{
  called when trying to get local stack if the compiler directive $S
  is set this function must preserve esi !!!! because esi is set by
  the calling proc for methods it must preserve all registers !!

  With a 2048 byte safe area used to write to StdIo without crossing
  the stack boundary
}
begin
  asm
        pushl   %eax
        pushl   %ebx
        movl    stack_size,%ebx
        addl    $2048,%ebx
        movl    %esp,%eax
        subl    %ebx,%eax
        movl    remotestkbottom,%ebx
	movl    (%ebx),%ebx
        cmpl    %eax,%ebx
        jae     .L__short_on_stack
        popl    %ebx
        popl    %eax
        leave
        ret     $4
.L__short_on_stack:
        { can be usefull for error recovery !! }
        popl    %ebx
        popl    %eax
   RemoteHandleError(202)
  end['EAX','EBX'];
  
end;

-----------------------
And then your main program should 

have 

var
   stkbottom : longint;external name '__stkbottom';

and via DXE calls you should set 

remotestkbottom to @stkbottom;
remotehandleerro to @handleerror;






More information about the fpc-pascal mailing list