Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!caip!princeton!allegra!alice!ark From: ark@alice.UucP (Andrew Koenig) Newsgroups: net.unix,net.micro.att,net.lang.c Subject: Re: query: argument passing on UNIX PC, VAX, et al Message-ID: <5471@alice.uUCp> Date: Sat, 17-May-86 00:25:45 EDT Article-I.D.: alice.5471 Posted: Sat May 17 00:25:45 1986 Date-Received: Mon, 19-May-86 01:58:50 EDT References: <168@mtsbb.UUCP> Organization: Bell Labs, Murray Hill Lines: 31 Xref: linus net.unix:7213 net.micro.att:1213 net.lang.c:8287 > I am interested in the precision used by various C compilers when > passing arguments on the stack to a called routine. For example: > > some_routine_or_main() > { > char a,b; > > foo(a,b) > } > > foo (a,b) > long a,b; > > { > printf("%#lx\t%#lx\n", a, b); > } > > I tried a program similar to the above on a vax and a UNIX PC > and in both cases the values of 'a' and 'b' were correctly > passed. Given that a long on both machines is 32 bits and a char > is 8 bits, from this I assumed that both compilers are expanding > 'a' and 'b' to 32 bits before putting them on the stack. I might > have expected this for the vax, but not for the UNIX PC (68000 > based). The definition of C is that char or short arguments are expanded to ints. Both the VAX and UNIX PC (and the 3B machines, for that matter) support 32-bit ints. Since subscripts are ints rather than longs, a machine that implements only 16-bit ints has a rather hard time dealing with arrays with more than 32767 elements. This is, of course, often the case on little machines like PDP-11 or 8086.