C codes problem

This is a discussion on C codes problem within the C Programming forums, part of the General Programming Boards category; Code: static inline void outw( unsigned long address, unsigned long value ) { *((volatile unsigned long *const)address)=value; } static inline ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    5

    C codes problem

    Code:
    static inline void  outw( unsigned long address, unsigned long value )
    {
    	*((volatile unsigned long *const)address)=value;
    }
    
    static inline unsigned int inw( unsigned long address )
    {
    	return *((volatile unsigned long *const)address);
    }
    can somebody explain me the codes above in detail?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    * means to dereference a pointer, and a type in parentheses means to cast to that type (so "(volatile unsigned long *const)address" means to cast address to the type volatile unsigned long *const. And of course = means assignment.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    The first function moves the data from variable "value" to the location pointed to by "address".

    The second function retrieves the value at "address" and returns it to the caller.

    By being designated as "volatile", that means a process outside of this program can update it as well.

    (tabstop gave you what you asked for, the detail, and I gave you the high level summary)
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    5
    What did you mean by 'caller'?

  5. #5
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    When the term "caller" is used in software, it refers to the routine that called a function or a program.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  4. Problem in simple code.
    By richdb in forum C Programming
    Replies: 6
    Last Post: 03-20-2006, 02:45 AM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21