Mail Archives: djgpp/1999/03/02/16:23:29
Andrew Davidson wrote:
> Andrew Davidson <andrew AT lemure DOT freeserve DOT co DOT uk> wrote in message news:...
>
> Sorry, please ignore that question as it was totally the wrong one to be
> asking! :(
>
> What I'm really after is how to pass arguments to a function at machine code
> level. Assuming I have the address of the function (which I can keep in any
> register you like) what registers would I have to write to to provide
> arguments. I'm guessing it would be something like <number of args> in one
> register <address of start of args> in another, but how would I know what
> sort of arguments they were? I'm really after simply passing a short int to
> a function but while I'm here I might as well learn something!
They are all passed on the stack, in reverse order. And I believe they are
pushed as 32-bit values:
void a(char b, short c, int d)
To call this, you push 'd', then 'c' [as 32-bits, I don't know if the value
of the most significant word matters], then 'b' as 32-bits. There is know way
to know, from the machine's perspective, what has been passed, you have to rely
on the caller to push the correct type of information onto the stack.
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT GeoCities DOT com
Endlisnis AT BrunNet DOT Net
Endlisnis AT HotMail DOT com
- Raw text -