On Sun, 22 Feb 2004 19:15:32 +0100, roaher <go***@email.si> wrote:
hi
I have some trouble reading this macro:
#define SMC_inl(r) (*((volatile dword *)(SMC_BASE_ADDRESS+(r))))
also consider that SMC_BASE_ADDRESS is address base of I/O mapped
peripherial registers, r is register offset.
Does that read: return 32bits of data stored in memory location
SMC_BASE_ADDRESS+r.
with this "(volatile dword *)" we are casting pointer to point to 32bit
wide address and first * means get the value stored at that address.
Am i reading this right ?
regards, himba
It depends on the definition of SMC_BASE_ADDRESS.
If it is a numeric constant or variable, then the value of the
expression (r) added to the value of SMC_BASE_ADDRESS using normal
arithmetic, the resulting value is treated as the address of a dword
(which is not a standard type), and the value of the dword at that
address is the result of the expression. If the address is not
properly aligned for a dword, it invokes undefined behavior.
If it is a pointer expression, then the value of the expression
(r) is added to the value of SMC_BASE_ADDRESS using pointer arithmetic
(where +1 means the number of bytes in one object of the type the
pointer points to), the resulting value is treated the same as above.
For what it's worth, the second '(' and the next to last ')' are
superfluous.
<<Remove the del for email>>