Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!bellcore!faline!scherzo!allegra!alice!bs From: bs@alice.UUCP Newsgroups: comp.lang.c++ Subject: Re: Problem with asm()s in inlines Message-ID: <6604@alice.uUCp> Date: Sun, 1-Feb-87 22:27:05 EST Article-I.D.: alice.6604 Posted: Sun Feb 1 22:27:05 1987 Date-Received: Tue, 3-Feb-87 02:02:09 EST References: <165700003@uiucdcsb> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 84 Summary: quick and dirty fix I think I've discovered a bug in the way cfront handles asm's in inlines. ***> You did. Thanks. Quick and dirty fix follows. I first noticed it using version 1.1 which I had ported to our Encore Multimax (UMAX 4.2). I first assumed that I had subtly botched the build in some way, but the older version 1.0 compilers on our VAX 11/780 (4.3bsd) and 3B2s do the same thing. Here's some code to illustrate the problem: C++ source code: */ inline void Barney() { asm(" op src,dst"); } void Fred() { Barney(); } /* C code for Fred() generated by cfront: int Fred () { { asm("rney"); } } Any ideas? Notice that "rney" is part of "Barney", the name of the inline function. I'd like to be able to generate inline assembly language in some very low-level routines which need to be fast (i.e., I don't want the subroutine call overhead and I *need* access to specific processor instructions (like setting bits in the PSR to enable/disable interrupts, etc.). Thanks. - Gary Johnston Department of Computer Science University of Illinois at Urbana-Champaign 1304 West Springfield Avenue Urbana, IL 61801 Phone: (217) 333-2518 USENET: {pur-ee,convex,inhp4}!uiucdcs!johnston b.cs.uiuc.edu csnet-relay ***> Here is a fix. in dcl2.c: grep for "ASM:" and change the case to: case ASM: /* save string */ { char* s = (char*)ss->e; int ll = strlen(s); char* s2 = new char[ll+1]; strcpy(s2,s); ss->e = Pexpr(s2); break; } The ``save string'' comment was always there. I forgot to obey it. in dcl.c: grep for "ASM:" and change the case to: case ASM: { Pbase b = (Pbase)tp; Pname n = tbl->insert(this,0); n->assign(); n->use(); char* s = (char*) b->b_name; // save asm string. Shoddy int ll = strlen(s); char* s2 = new char[ll+1]; strcpy(s2,s); b->b_name = Pname(s2); return this; } in expand.c add ASM cases to the two switches in stmt::expand: case ASM: if (s_list) { ee = new expr(CM, ee, (Pexpr)s_list->expand()); PERM(ee); } return (Pstmt)ee; and case ASM: break; */