gnupic: byte data in code space on 16 bit devices


Previous by date: 10 Aug 2005 22:26:45 +0100 gpasm: Assertion `state.obj.debug_file != ((void *)0)' failed, David Saxton
Next by date: 10 Aug 2005 22:26:45 +0100 Re: [gnupic] RE: fsusb-0.1.11 problem, Chen Xiao Fan
Previous in thread:
Next in thread:

Subject: byte data in code space on 16 bit devices
From: Peter Onion ####@####.####
Date: 10 Aug 2005 22:26:45 +0100
Message-Id: <1123709176.6260.51.camel@HP.RoomLan>

I'm sure I've seen somewhere a gpasm directive that doesn't zero pad
byte data to 16 bits.

I've just fond a problem in sdcc where an array of pointers is assumed
to take 3 bytes per element, but the padding takes it up to 4 bytes so
array access calculations go wrong...   I'de like to know how to fix
this before I post the bug report on the sdcc site.


c code :
char * const  months[12]  =  {
    "January","February","March","April","May","June",
    "July","August","September","October","November","December" 
};


Code generated to access the array...  Note the "MULLW 0x03" assumes 3
bytes per pointer:

000432   51f9     movf  0xf9, 0, 0x1            MOVF    _month, W, B
000434   0d03     mullw 0x3                     MULLW   0x03
000436   cff3     movff 0xff3, 0x1              MOVFF   PRODL, r0x01
000438   f001
00043a   cff4     movff 0xff4, 0x2              MOVFF   PRODH, r0x02
00043c   f002
00043e   0e04     movlw 0x4                     MOVLW   LOW(_months)
000440   2601     addwf 0x1, 0x1, 0             ADDWF   r0x01, F
000442   0e16     movlw 0x16                    MOVLW   HIGH(_months)
000444   2202     addwfc        0x2, 0x1, 0             ADDWFC  r0x02, F
000446   0e00     movlw 0                       MOVLW   UPPER(_months)
000448   6a03     clrf  0x3, 0                  CLRF    r0x03
00044a   2203     addwfc        0x3, 0x1, 0             ADDWFC  r0x03, F
00044c   c001     movff 0x1, 0xff6              MOVFF   r0x01, TBLPTRL
00044e   fff6
000450   c002     movff 0x2, 0xff7              MOVFF   r0x02, TBLPTRH
000452   fff7
000454   c003     movff 0x3, 0xff8              MOVFF   r0x03, TBLPTRU
000456   fff8

array data in the code space....  Note 4 bytes per pointer:

                                            _months:
001604   16ea     andwf 0xea, 0x1, 0            DB      LOW(_str_16), HIGH(_str_16), UPPER(_str_16)
001606   0000     nop
001608   16f2     andwf 0xf2, 0x1, 0            DB      LOW(_str_17), HIGH(_str_17), UPPER(_str_17)
00160a   0000     nop
00160c   16fc     andwf 0xfc, 0x1, 0            DB      LOW(_str_18), HIGH(_str_18), UPPER(_str_18)
00160e   0000     nop
001610   1702     andwf 0x2, 0x1, 0x1           DB      LOW(_str_19), HIGH(_str_19), UPPER(_str_19)
001612   0000     nop
001614   1708     andwf 0x8, 0x1, 0x1           DB      LOW(_str_20), HIGH(_str_20), UPPER(_str_20)
001616   0000     nop
001618   170c     andwf 0xc, 0x1, 0x1           DB      LOW(_str_21), HIGH(_str_21), UPPER(_str_21)
00161a   0000     nop
00161c   1712     andwf 0x12, 0x1, 0x1          DB      LOW(_str_22), HIGH(_str_22), UPPER(_str_22)
00161e   0000     nop
001620   1718     andwf 0x18, 0x1, 0x1          DB      LOW(_str_23), HIGH(_str_23), UPPER(_str_23)
001622   0000     nop
001624   1720     andwf 0x20, 0x1, 0x1          DB      LOW(_str_24), HIGH(_str_24), UPPER(_str_24)
001626   0000     nop
001628   172a     andwf 0x2a, 0x1, 0x1          DB      LOW(_str_25), HIGH(_str_25), UPPER(_str_25)
00162a   0000     nop
00162c   1732     andwf 0x32, 0x1, 0x1          DB      LOW(_str_26), HIGH(_str_26), UPPER(_str_26)
00162e   0000     nop
001630   173c     andwf 0x3c, 0x1, 0x1          DB      LOW(_str_27), HIGH(_str_27), UPPER(_str_27)
001632   0000     nop



Previous by date: 10 Aug 2005 22:26:45 +0100 gpasm: Assertion `state.obj.debug_file != ((void *)0)' failed, David Saxton
Next by date: 10 Aug 2005 22:26:45 +0100 Re: [gnupic] RE: fsusb-0.1.11 problem, Chen Xiao Fan
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.