Thread: Can you get memory addresses from compile time

  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    1

    Can you get memory addresses from compile time

    I've been a programmer for many years now, but I've come across a new situation which I have never had to deal with before. My question is this: Is it possible to determine where functions are stored at compile time, so that at run time you can pass the memory address as a pointer to the interrupt handler so that it can directly call the function at memory location 'X'? The newest project I'm working on would require to either somehow capture these addresses or to find a work-around so that instead of passing the pointer to the interrupt handler, the software would then need to be able to be non-interruptable. If anyone has any ideas please let me know. I've never had to write this level of complexity into my software before. Most software I've worked on has been user-end and this isn't user-end, but rather processor-end software to drive the system.

    Thanks in advance.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    You've been a programmer for "many years" and you've never heard of function pointers?

    Have you ever used qsort() in stdlib.h - it uses a function pointer.

    > the software would then need to be able to be non-interruptable.
    Aside from it being the responsibility of the interrupt handler to manage whether further interrupts are allowed or not, the only other restrictions you should be aware of are
    - code called in ISR context should be as fast as possible (do the minimal amount of work necessary, then return).
    - if you're running any kind of OS as well, there will be restrictions on which OS interfaces you can call from ISR context.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    1,658
    Is this a program that will run under windows, linux, posix, unix, ... ? If so, and you want to create an interrupt handler, you may need to create and install a device driver. Device drivers and their interrupt handlers normally need to run in the same memory space as the kernel.

    If this is code for an embedded system or msdos, where no virtual memory is involved, then your program can probably hook into the interrupt vector directly.
    Last edited by rcgldr; 09-01-2013 at 09:39 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 04-11-2010, 07:14 AM
  2. Working with memory addresses
    By Fujy in forum C++ Programming
    Replies: 7
    Last Post: 01-18-2010, 09:31 AM
  3. Editting Memory Addresses?
    By Dae in forum C++ Programming
    Replies: 7
    Last Post: 07-03-2005, 07:07 PM
  4. Memory Addresses
    By Breetai in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2002, 08:10 AM
  5. pointer-memory addresses
    By TerryK in forum C Programming
    Replies: 2
    Last Post: 05-16-2002, 01:31 PM