Newsgroups: comp.os.msdos.djgpp From: Peter Berdeklis Subject: Re: Assembler question Message-ID: NNTP-Posting-Host: chinook.physics.utoronto.ca Sender: news AT info DOT physics DOT utoronto DOT ca (System Administrator) Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Organization: University of Toronto - Dept. of Physics In-Reply-To: <199710070150.SAA24301@adit.ap.net> Date: Wed, 8 Oct 1997 13:55:17 GMT References: <199710070150 DOT SAA24301 AT adit DOT ap DOT net> Lines: 20 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Tue, 7 Oct 1997, Nate Eldredge wrote: > At 03:03 10/6/1997 GMT, Marsel wrote: > >Hi, > > Can I get the address of the program counter in a C program ? > I don't think there's a good way to do it directly from C, but you can do it > with external assembler, I.E. NASM. Easy to do with inline assembler: int pc; asm( "movl %%eip, %0"; "=q" (pc) ); (Untested, but I don't think that it violates any protection.) --------------- Peter Berdeklis Dept. of Physics, Univ. of Toronto