How can I recognise in the p-Code, that this is an integer function and has not 3 parameter values (6 bytes = 3 words data).
Has not? To be honest, I'm a bit confused about what you're asking. So here are my two (no, not cents) possible interpretations of this question.
If it's about how many parameters a function has:
In p-code functions always have (at least) two (16 bit) parameters even if there is none defined in source. Any defined ones come in addition. So RANDU
has one source level parameter, but three internal.
That's nicely visible with the call for the random
function within your RANDU
. CXP 16,6
calls entry 6 in external segment 16 (which should be random
). Before doing so two constant 0 words are pushed - even though random
doesn't have a parameter.
If you want to know how to determinate function parameters and return from objectcode:
There is no direct way for a program to evaluate during runtime how many parameters a function (or procedure) has. The parameter list is prepared when the activation record is setup by the calling instruction (C*P
). It uses the 'Parameter Size' value stored in the attribute section of the jump table - or procedure header - to reserve that space above the Mark Pointer and copies as much bytes from the stack into this space. There is no information (in object code) hom many parameter there are and how they are structured.
For further information you may want to read the Apple Pascal Operating System Reference Manual which contains all information. In addition Randall Hyde's p-Source - a Guide to the Apple Pascal System might be helpful, as it explains it (mostly the same parts) in greater detail.