Hello,
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.

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.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.