what does the '@' do?

This is a discussion on what does the '@' do? within the C Programming forums, part of the General Programming Boards category; I'm going through some code and found this line: volatile char LCD_DATA @ 0x200; I know it's naming a char ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    52

    what does the '@' do?

    I'm going through some code and found this line:

    volatile char LCD_DATA @ 0x200;

    I know it's naming a char LCD_DATA but I'm not familiar with the @ symbol.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Me neither. Does it compile?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    Registered User
    Join Date
    Mar 2010
    Location
    pkr
    Posts
    32
    @ is used in various programming languages although there is not a consistent theme to its usage. For example:
    In C#, it denotes "verbatim strings", where no characters are escaped and two double-quote characters represent a single double-quote. As a prefix it also allows keywords to be used as identifiers.
    In Java, it is used to denote annotations, a kind of metadata, since version 5.0
    In modal logic, specifically when representing possible worlds, @ is sometimes used as a logical symbol to denote the actual world (the world we are 'at').
    In Pascal, @ is the "address of" operator (it tells the location at which a variable is found).
    In Perl, @ prefixes variables which contain arrays.
    In PHP, it is used just before an expression to make the interpreter suppress errors that would be generated from that expression.
    In Python 2.4 and up, it is used to decorate a function (wrap the function in another one at creation time).
    In Ruby, @ prefixes instance variables, and @@ prefixes class variables.
    In Scala, it is used to denote annotations (as in Java), and also to bind names to subpatterns in pattern-matching expressions.
    In ML, it denotes list concatenation.
    In Clipper, it is used to denote position on the screen. For example: @1,1 SAY "HELLO" to show the word "HELLO" in line 1, row 1.


    I could not find its any relation with C Programming Language.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,663
    Some embedded compilers use that notation to locate a variable at a specific address.

    In this case, your LCD_DATA variable will be located at address 0X200

    So when you do
    LCD_DATA = 'A';
    say, you may see an 'A' on your LCD.

    Read the docs for your LCD to find out more.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by Salem View Post
    Some embedded compilers use that notation to locate a variable at a specific address.

    In this case, your LCD_DATA variable will be located at address 0X200

    So when you do
    LCD_DATA = 'A';
    say, you may see an 'A' on your LCD.

    Read the docs for your LCD to find out more.
    That kind of makes sense, but in that case, what's wrong with:
    Code:
    char *LCD_DATA = (char*)0x200;
    It seems kind of an overkill to add a new operator for that.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    52
    I'll post up some more code of how it's used"

    Code:
    //Module LM6733
    // Epson 1330/1335 LCD Display Controller Port Addresses
    volatile char LCD_DATA @ 0x200; /*lcd data address*/
    volatile char LCD_CMD  @ 0x201;	/*lcd CMD address*/
    
    	while(LCD_DATA & 0x40) ; \
    	LCD_CMD=(unsigned char)cmd; \
    	_asm("bclr	_PORTE,128"); }
    
    	while(LCD_DATA & 0x40) ; \
    	LCD_DATA=(unsigned char)data; \
    	_asm("bclr	_PORTE,128"); }
    This is being used with MC68HC812A4 CPU.

Popular pages Recent additions subscribe to a feed

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