[fpc-pascal]Minimum size of parameters

Aitor Santamaria Merino aitor.sm at wanadoo.es
Thu Dec 6 16:59:29 CET 2001


Hi,

I explain the problem, then my solution, then my questions:
(Platform: GO32V2, although I think it could be independent)

Problem: if I have a record like this:
RECORD
      Pt: PointerToCertainProcedure;
      Sz: SizeInBytesOfProcedureArgs;
      Arg: PointerToARecordContainingArgs;
END;
then I would like to make a Call procedure to interpretate this all. The 
parameters of the procedures and the record containing args specify both 
in the same order.

My solution (briefly):
(a) typecast the RecordContainingArgs to an ARRAY OF WORD (using 
pointers, etc.)(why?  because it seems that I can only PUSH words!)
(b) push that array REVERSING the order
(c) ASM_CALL the procedure
It worked.

Notes:
I noted that I typecasted to words because inline ASM did only allow me 
to push WORDs.
I also tried with types bigger than WORD (CARDINAL, ARRAYs, RECORDs), 
and reversing DID work.
I have also discovered the following "funny" behaviour of calls when I 
have to use BYTES:

{This works!!}
{$ASMMODE Intel}
VAR
    Par1, Par2: word;

BEGIN
      Par1 := 1;
      Par2 := 2;
      ASM
         PUSH Par2
         PUSH Par1
         CALL P
      END
END.

Where P is a PROCEDURE (a,b: BYTE);
ATTENTION: I push WORDS and P "pops" BYTES!

Questions:
For which kind of basic bytes should I expect such behaviour?
(boolean?,sortint?) I would say for those types whose size is not a 
multiple of 2 bytes, am I right?


Aitor





More information about the fpc-pascal mailing list