Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: comp.lang.c Subject: Re: Arguments in included assembler instructions Message-ID: <3877@utcsri.UUCP> Date: Mon, 5-Jan-87 21:48:35 EST Article-I.D.: utcsri.3877 Posted: Mon Jan 5 21:48:35 1987 Date-Received: Tue, 6-Jan-87 00:35:21 EST References: <488@l.cc.purdue.edu> Reply-To: greg@utcsri.UUCP (Gregory Smith) Distribution: world Organization: CSRI, University of Toronto Lines: 29 Summary: In article <488@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: > >Many times I have found it necessary to include asm instructions >in a C program. It should be possible to do this in such a way >that the compiler will substitute the locations of variables for >the variable names in the asm instructions. I know of ways to do >the job; one person to whom I showed this pointed out that if the >compiler were changed this could break. This would not be the case >if the suggested enhancement were made. Yes. Someone suggested a 'printf-like' capability for asm() a while back. EG on a 68000 machine, to get the user stack pointer in supervisor code: ... char *user_sp; ... asm(" move usp,%a", user_sp ); '%a' would change either to (1) the appropriate extern name (eg "_user_sp"), if user_sp were external, (2) the appropriate local symbol if user_sp were local static, or (3) the appropriate stack-indexed or frame-indexed address if user_sp were auto. The above code would then be immune to a large class of compiler changes. In particular, changes to (1) name translation conventions, (2) local symbol allocation method, (3) stack allocation and addressing conventions. Other bells and whistles could be added, but this would be the most useful feature. Of course, different features would be useful with different machines.