This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Deciphering ISO C (Chap 6.3.2.3 - Pointers)


Hi,

I'm having weird difficulties with the flash_am29xxxxx.inl file, whereas I
have created this cut-down version of what appears to be my problem:

-------------

The code-example further down was created from analyzing line 216-217 in
file flash_am29xxxxx.inl:
	ROM = (flash_data_t*) CYGNUM_FLASH_BASE;
	f_s1 = FLASH_P2V(ROM+FLASH_Setup_Addr1);

Resulting output after preprocessing is:
    ROM = (flash_data_t*) (0x00000000u);
    f_s1 = ((volatile flash_data_t *) \
		((CYG_ADDRWORD)((CYG_ADDRESS)ROM+(0x555))));

The value in f_s1 must be 0x555 for the AMD chip to work in word mode (as
far as I have read) ... but "diag_printf("%x", f_s1)" yields 0xAAA :(

-------------

I can't seem to find the logic in why this example doesn?t work:

	cyg_uint16* res_16;
	cyg_uint16* p_16;
	cyg_uint16 u_16;

	p_16 = 0x0u;
	u_16 = 0x0u;
	res_16 = (p_16 + 0x555u);

The above code yields res_16 == 0xaaa
I was sort of hoping for 0x555 instead...

Altering the addition line to this:
	res_16 = (cyg_uint16*)(u_16 + 0x555);
corrects the problem... 

why?

The platform is a 32bit.
Trying to decipher the first addition, I get:
	32bit_u = (32bit_u + 32bit_u)
assuming that the pointer ?cyg_uint16 *? is 32bit...

-------------

I hope one of you can shed some light to this problem of mine :)

Regards,
-=[ Philip Soeberg ]=-



--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]