Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!hplabs!hpda!hpisoa2!hpitg!cbmvax!grr@cbmvax From: grr@cbmvax Newsgroups: net.lang.c Subject: Re: varargs Message-ID: <155@cbmvax> Date: Sun, 27-Apr-86 06:21:00 EDT Article-I.D.: cbmvax.155 Posted: Sun Apr 27 06:21:00 1986 Date-Received: Tue, 13-May-86 01:13:26 EDT References: <293@usc-obero> Lines: 43 In article <792@ccird2.UUCP> rb@ccird2.UUCP (Rex Ballard) writes: >In article <5302@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes: >>> I have always heard that varargs is not very portable... ... >I have heard that there are a few "peculiar" >compilers available for the Atari ST, Mac, and Amiga, which, although >not "kosher", CAN support most varargs situations. The problems that >can occur are "intelligent" compilers which put arguments directly >into registers rather than on the stack. Appearantly, this can be >a real problem if you wish to "intercept" a system call at the >application side. Why do so many of the micro operating systems >insist on putting arguments in registers!!!. Even MS-DOS expects >arguments in registers rather than on the stack. Mainly cause it makes calling subroutines very fast! (and breaks a lot of code) imagine: routine(arg); register char *arg; {...} If the compiler knows that arg just happens to be in a suitable register when the routine is called; the only overhead is an optional register to register move, and a call instruction. This can really speed things up when you have a lot of little inner routines. However, spare us compiler writers! It just isn't worth it when you're trying to use somebody else's 'portable' code. It would be fine if C had nested procedures or inlines or something, but a disaster otherwise. > >The C frame is a more sensible archetecture... > Most micro operating systems, includeing MSDOS include some degree of conceptual compatibility with CP/M, and the CP/M system system calls were intended to be used from assembly language programs, thus getting the arguments in registers was easier than not. Kind of like the influence the PDP-9 assembler had on the selection of * and & for the C address operators, when @ and # make a lot more sense to anybody brought up on a PDP-11. -- George Robbins - now working with, uucp: {ihnp4|seismo|caip}!cbmvax!grr but no way officially representing arpa: cbmvax!grr@seismo.css.GOV Commodore, Engineering Department fone: 215-431-9255 (only by moonlite)