A complex macro definition
-
define blHeadTable ((V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3 *)(BL_HEAD_ADDRESS))
define GetblDID1() (blHeadTable->DID[1])
I am a little confused in the first macro declaration. Appreciate any explanation.
Basically it casts the fixed address
BL_HEAD_ADDRESS
as a pointer to some type:# define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))
In your case the type is
V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3
. Assuming thatV_ROM1_FAR
andV_ROM2_FAR
are something likefar *
, the type is a pointer inV_ROM3
that points to atblHead
pointer. Effectively it will assign a pointer to atblHead
structure at a fixed address. -
Basically it casts the fixed address
BL_HEAD_ADDRESS
as a pointer to some type:# define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))
In your case the type is
V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3
. Assuming thatV_ROM1_FAR
andV_ROM2_FAR
are something likefar *
, the type is a pointer inV_ROM3
that points to atblHead
pointer. Effectively it will assign a pointer to atblHead
structure at a fixed address. -
I understand it's like:
# define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))
But the type:
V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3
I am still a little confused with it.
int a Char short, is that similar?
Thanks
You have to lookup first how
V_ROM1_FAR
andV_ROM2_FAR
are defined. Then it will be something likefar * tblHead far * V_ROM3
far
is a compiler and platform specific keyword. See Far pointer - Wikipedia[^]. See also Cx51 User's Guide: Abstract Pointers[^] (I did not found a better link that explains such castings). -
Basically it casts the fixed address
BL_HEAD_ADDRESS
as a pointer to some type:# define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))
In your case the type is
V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3
. Assuming thatV_ROM1_FAR
andV_ROM2_FAR
are something likefar *
, the type is a pointer inV_ROM3
that points to atblHead
pointer. Effectively it will assign a pointer to atblHead
structure at a fixed address.