Thread: Definite Address locations

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    35

    Definite Address locations

    I do most of the time micro controller programming and i find source codes or the header file given by the manufacturer in this manner for example

    Code:
    #define Mod (*(volatile struct Mod_tag *) 0x35600000UL)
    There are definite addresses given here, but i write a C program for pc using Mingw to understand the behavior, i crash the pc as the addresses are not defined. How to overcome this problem? What are the address ranges i can use for PC?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    On the host, you would do
    Code:
    static struct Mod_tag ModDummy;
    #define Mod &ModDummy
    If your manufacturer data is all in one header file, then you could do something like this in your code.
    Code:
    #ifndef WIN32
    #include <hw_addresses.h>
    #else
    // This contains all the static structs and #defined pointers
    #include <pc_addresses.h>
    #endif
    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
    May 2019
    Posts
    214
    Salem has the answer but....


    Quote Originally Posted by Clearner123 View Post
    What are the address ranges i can use for PC?
    Just to be clear, unless one creates a fixed position mapped region of memory, there are none in modern operating systems. A fixed region of memory is related to the interprocess library for memory mapped files.

    There can be hardware on the machine which does have fixed memory regions for I/O, but it is rare and for modern systems like Linux or Windows that must be controlled by the operating system (not in a fixed location like you see in the embedded system).

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    This is a good lesson on why writting portible code matters
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tictactoe x and o locations.
    By xTonyLeo in forum C Programming
    Replies: 10
    Last Post: 01-27-2013, 06:12 PM
  2. New pointer locations
    By mica in forum C Programming
    Replies: 2
    Last Post: 03-23-2011, 08:31 AM
  3. writing to certain locations.
    By epidemic in forum C++ Programming
    Replies: 2
    Last Post: 12-19-2006, 12:12 PM
  4. file i/o locations
    By algi in forum C++ Programming
    Replies: 4
    Last Post: 01-16-2005, 11:21 AM
  5. Definite Answer Needed
    By CAP in forum C Programming
    Replies: 39
    Last Post: 06-18-2002, 03:41 AM

Tags for this Thread