Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!necntc!husc6!bloom-beacon!wesommer From: wesommer@bloom-beacon.UUCP Newsgroups: comp.lang.c Subject: Re: Inline assembler; a quiz (long; sorry) Message-ID: <1084@bloom-beacon.MIT.EDU> Date: Tue, 7-Jul-87 14:05:05 EDT Article-I.D.: bloom-be.1084 Posted: Tue Jul 7 14:05:05 1987 Date-Received: Thu, 9-Jul-87 06:14:33 EDT References: <608@zen.UUCP> <2299@hoptoad.uucp> <21211@sun.uucp> <830@omepd> <239@sugar.UUCP> <8253@utzoo.UUCP> <4788@columbia.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: wesommer@priam.UUCP (William Sommerfeld) Organization: Massachusetts Institute of Technology Lines: 26 In article <4788@columbia.UUCP> francus@cheshire.columbia.edu.UUCP (Yoseff Francus) writes: >In article <8253@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >>I have news for you: Unix systems generally require assembly-language glue >>around system calls too, since virtually no Unix system does system calls >>exactly the same way it does function calls. (If nothing else, the actual >>call instruction almost invariably differs.) The standard solution, used >>by the original Unix and still used by most Unixes, is that the "system >>call" in C is just an ordinary function call, and the function that's called >>is written in assembler and does the actual system call. > >Well, if you look at the source code, if you have source, you'll notice >that most - if not all - of the system call found in Section 2 of the >manual are written in 'C'. Yes, but to get to them, you have to use some form of assembler "glue" to warp between user mode and kernel mode.. for example, on the VAX, you use a "chmk" instruction (CHange Mode to Kernel); this causes the processer to jump through a trap vector through some kernel assembler code in locore.s, and into the "syscall" routine. This winds up copying the system call arguments from user space into a known area of kernel space (pointed at by u.u_ap), and then calls one of the top-level system call functions. These functions thus get their REAL arguments by looking at u.u_ap. Bill Sommerfeld wesommer@athena.mit.edu