Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!linus!decvax!ucbvax!ucdavis!lll-crg!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: asm Message-ID: <105@hadron.UUCP> Date: Fri, 29-Nov-85 19:29:07 EST Article-I.D.: hadron.105 Posted: Fri Nov 29 19:29:07 1985 Date-Received: Sat, 7-Dec-85 11:43:19 EST References: <382@celerity.UUCP> <86900003@haddock.UUCP> <607@ttrdc.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 27 Summary: Where's the variable? Well, here ... First off: the best way to find out for a given C compiler on a given machine (which is all you want, anyway, since asm's are inherently non-portable) is to ask the compiler. Do a cc -S (cc -S -O if you like) to get an assembler output. Most C compilers I have run into seem to (note all the hedging) put register variables into the highest free register first. E.g., on the VAX skip PC, SP, FP, AP, and start with R11. Most C compilers then allow you down to R6 or R5. On the PDP-11, one skipped PC, SP, and FP, and had R4-R2. The 80X86 is (characteristically) a total mess: SI and DI are often used, as the closest to real GP registers; although some will use DX, CX, and BX and skip the optimisations that using them in-line sometimes bring. The M680X0 uses the VAX model, with the interesting twist of address + data registers. ... Static and extern data typically has the same name as in the C program, but with an underscore pre-pended: but not a few have chosen to change even this simple rule. Auto's tend to be put on the stack, with the first-declared closest to the head of the stack and later vars further down. In the back of my head there's something nagging at me that there are machines that do it with the last-declared near the top of the stack. Either way, array elements are always in the correct order. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}