I have problem to understand the code below:

#define LCD_DATA_REG (*(unsigned char*)( 0xC000 )) // Data Register
#define LCD_CTRL_REG (*(unsigned char*)( 0x8000 )) // CTRL Register

I know basics about pointers and I know how to understand pointers to functions, arrays, structures, int, ... However I don't understand these definitions at all. Would anybody of you be so kind to explain me what these lines of code means in detail? I would be very glad if you'll explain it step by step:

1. (unsigned char*)( 0xC000 ) - can number (0xC000) be a pointer? or what does this line mean?
2. (*(unsigned char*)( 0xC000 )) - what does the other symbol * mean?

Thank you and sorry for bothering you with this maybe easy problem.

8 Years
Discussion Span
Last Post by Dawee1

Its defining a pointer to a specific address. Works ok (probably) in MS-DOS version 6.X and earlier where that type of syntax was sometimes used, but it will fail in any modern 32-bit operating system such as MS-Windows and *nix. So if you are using a modern compiler then those defines because they won't compile.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.