From: SourceForge.net <no...@so...> - 2005-08-12 11:28:57
|
Bugs item #1256215, was opened at 2005-08-10 22:01 Message generated for change (Comment added) made by tecodev You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1256215&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: pic16 target >Group: fixed >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Peter Onion (p_onion) >Assigned to: Raphael Neider (tecodev) Summary: PIC16: char * const names[]; Initial Comment: The following declaration puts both the strings and the array of pointers to them in the code memory. char * const months[12] = { "January","February","March","April","May","June", "July","August","September","October","November","December" }; The problem is that the code that access the array assumes there are 3 bytes per array element, but in reality due to word alignment there are 4 bytes per array element. MOVF _month, W, B MULLW 0x03 <<<< 3 bytes per entry in the array ! MOVFF PRODL, r0x01 MOVFF PRODH, r0x02 MOVLW LOW(_months) ADDWF r0x01, F MOVLW HIGH(_months) ADDWFC r0x02, F MOVLW UPPER(_months) CLRF r0x03 ADDWFC r0x03, F MOVFF r0x01, TBLPTRL MOVFF r0x02, TBLPTRH MOVFF r0x03, TBLPTRU The .asm file has this in it... _months: DB LOW(_str_16), HIGH(_str_16), UPPER(_str_16) DB LOW(_str_17), HIGH(_str_17), UPPER(_str_17) DB LOW(_str_18), HIGH(_str_18), UPPER(_str_18) DB LOW(_str_19), HIGH(_str_19), UPPER(_str_19) DB LOW(_str_20), HIGH(_str_20), UPPER(_str_20) DB LOW(_str_21), HIGH(_str_21), UPPER(_str_21) DB LOW(_str_22), HIGH(_str_22), UPPER(_str_22) DB LOW(_str_23), HIGH(_str_23), UPPER(_str_23) DB LOW(_str_24), HIGH(_str_24), UPPER(_str_24) DB LOW(_str_25), HIGH(_str_25), UPPER(_str_25) DB LOW(_str_26), HIGH(_str_26), UPPER(_str_26) DB LOW(_str_27), HIGH(_str_27), UPPER(_str_27) but the .lst file has this 0000 03222 _months: 0000 0000 0000 03223 DE LOW(_str_16), HIGH(_str_16), UPPER(_str_16) 0004 0000 0000 03224 DE LOW(_str_17), HIGH(_str_17), UPPER(_str_17) 0008 0000 0000 03225 DE LOW(_str_18), HIGH(_str_18), UPPER(_str_18) 000C 0000 0000 03226 DB LOW(_str_19), HIGH(_str_19), UPPER(_str_19) 0010 0000 0000 03227 DB LOW(_str_20), HIGH(_str_20), UPPER(_str_20) 0014 0000 0000 03228 DB LOW(_str_21), HIGH(_str_21), UPPER(_str_21) 0018 0000 0000 03229 DB LOW(_str_22), HIGH(_str_22), UPPER(_str_22) 001C 0000 0000 03230 DB LOW(_str_23), HIGH(_str_23), UPPER(_str_23) 0020 0000 0000 03231 DB LOW(_str_24), HIGH(_str_24), UPPER(_str_24) 0024 0000 0000 03232 DB LOW(_str_25), HIGH(_str_25), UPPER(_str_25) 0028 0000 0000 03233 DB LOW(_str_26), HIGH(_str_26), UPPER(_str_26) 002C 0000 0000 03234 DB LOW(_str_27), HIGH(_str_27), UPPER(_str_27) where an extra "0x00" byte is added to each entry ---------------------------------------------------------------------- >Comment By: Raphael Neider (tecodev) Date: 2005-08-12 11:28 Message: Logged In: YES user_id=1115835 This is definitely not a gpasm bug as it is well documented... So I guess this must be considered an SDCC bug. Fortunately I just fixed it in SDCC 2.5.2 #1086 ;-) ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2005-08-11 09:02 Message: Logged In: NO WIthout the const in the declaration, the strings still go in code space, but the array goes in initialised data space, and the byte padding doesn't happn and the array access code works. So I'm not sure if this is an sdcc or gpasm problem. Peter ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1256215&group_id=599 |