Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!jarthur!nntp-server.caltech.edu!tybalt.caltech.edu!chi From: chi@tybalt.caltech.edu (Curt Hagenlocher) Newsgroups: comp.sys.mac.programmer Subject: Re: passing correct var size in MPW C/C++ Summary: MPW C always passes 32-bit stuff Message-ID: <1990Jul24.235007.20545@laguna.ccsf.caltech.edu> Date: 24 Jul 90 23:50:07 GMT References: <26ACA0CB.542F@wilbur.coyote.trw.com> <43315@apple.Apple.COM> Sender: chi@tybalt.caltech.edu Distribution: usa Organization: California Institute of Technology, Pasadena Lines: 27 In article <43315@apple.Apple.COM> marc@Apple.COM (Mark Dawson) writes: >I wrote a routine in assembly that I wanted to call from my C++ code, it >didn't end up working the way I expected--the C++ call kept passing a long, >when my assembly was expecting a short (2 bytes). I've of course modifed >my assembly to expect a long, but I'd like to know where my thinking went >wrong. > >(code deleted) > >When I did a debugger trap in myProc(), the stack always had an $FFFF FFFE, >not the $FFFE that I expected--it seemed to be passing 4 bytes instead of two. >Why? > MPW C always converts everything to 32 bits that's less than 32 bits in length. This includes characters and shorts. The information is put into the low (byte/word) and sign extended to make a long integer. I imagine this is done so that everything stays longword aligned. This information can be found in the chapter of the MPW C manual entitled ``Calling Conventions.'' I believe it is Appendix B. --- chi@tybalt.caltech.edu Curt Hagenlocher