Thread: C codes problem

  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,336
    * 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
    Chappell Hill, Texas
    Posts
    2,332
    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)
    Mainframe assembler programmer by trade. C coder when I can.

  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
    Chappell Hill, Texas
    Posts
    2,332
    When the term "caller" is used in software, it refers to the routine that called a function or a program.
    Mainframe assembler programmer by trade. C coder when I can.

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, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06: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