Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!columbia!cheshire.columbia.edu!francus
From: francus@cheshire.columbia.edu (Yoseff Francus)
Newsgroups: comp.lang.c
Subject: Re: Inline assembler; a quiz  (long; sorry)
Message-ID: <4793@columbia.UUCP>
Date: Tue, 7-Jul-87 16:29:04 EDT
Article-I.D.: columbia.4793
Posted: Tue Jul  7 16:29:04 1987
Date-Received: Fri, 10-Jul-87 05:37:32 EDT
References: <608@zen.UUCP> <2299@hoptoad.uucp> <21211@sun.uucp>
Sender: nobody@columbia.UUCP
Reply-To: francus@cheshire.columbia.edu.UUCP (Yoseff Francus)
Organization: Columbia University CS Department
Lines: 51


In article <1084@bloom-beacon.MIT.EDU> wesommer@priam.UUCP (William Sommerfeld) writes:
>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
The point I'm trying to make is that on Unix the programmer doesn't
have to worry about the assembler "glue" thats being used.  Not only
can a programmer use a system call in the same manner as a function
call, but can even get an understanding of what the system call is
doing (what tables is it modifying etc.) because the guts of it
are also written in 'C'.

No argument from me that even UNIX needs things like machine.s,
trap.s etc.

Yoseff





******************************************************************
yf
In Xanadu did Kubla Khan a stately pleasure dome decree
But only if the NFL to a franchise would agree.

ARPA: francus@cs.columbia.edu
UUCP: seismo!columbia!f/V.p:
>