delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/06/21:54:44

Date: Mon, 6 Oct 1997 18:50:30 -0700 (PDT)
Message-Id: <199710070150.SAA24301@adit.ap.net>
Mime-Version: 1.0
To: martsobm AT uv DOT es (Marsel), djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Assembler question

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. Note that this is not tested.:

-- file getip.asm --
[GLOBAL _getip]
[SECTION .text]
_getip:
        mov eax,[esp] ; get the address that was pushed by the parent's CALL
        ret

-- file getip.h --
unsigned getip(void);


Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019