From: Endlisnis Newsgroups: comp.os.msdos.djgpp Subject: Re: ANSI standard (machine code level) function returns Date: Tue, 02 Mar 1999 15:38:25 -0400 Organization: BrunNet Lines: 32 Message-ID: <36DC3E31.51C23E2@unb.ca> References: <7bgg9t$ur1$1 AT news6 DOT svr DOT pol DOT co DOT uk> NNTP-Posting-Host: ftnts4c86.brunnet.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Andrew Davidson wrote: > Andrew Davidson 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 in one > register
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