[fpc-pascal]Minimum size of parameters
Aitor Santamaria Merino
aitor.sm at wanadoo.es
Thu Dec 6 16:47:14 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 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?,)
How are STRINGS popped? will this trick of reversing parameter data work?
If the answer to the previous was NO, then do you have another idea to
solve my initial problem, execute this:
RECORD
Pt: PointerToCertainProcedure;
Sz: SizeInBytesOfProcedureArgs;
Arg: PointerToARecordContainingArgs;
END;
Aitor
More information about the fpc-pascal
mailing list