From: Story, L. <Lenny.Story@Alcatel.com> - 2003-05-28 22:11:14
|
Actually, It seems that the error is not what i had thought, but something else...rindex, which is the variable in question, is a BYTE not an int. So the issue is not the storage, but rather the fact that the compiler generated the instructions to grab two bytes from the structure member. It seems to only do this if you are attempting to take the address of and element of an array.... There are code fragments below which produce, and do NOT produce the error... This Code PRODUCES the error: byte *bufferPtr(TBuffer *pBuf) { return &(pBuf->buffer[pBuf->rindex]); } ; genPlus mov a,#0x05 ;GET RINDEX MEMBER OFFSET add a,ar2 ;ADD TO BASE PTR mov r2,a ;STORE RESULT IN R2 mov a,#0x00 ;ADD HIGH TO ZERO ? addc a,ar3 ; mov r3,a ; ; INDEX POINTER R3:R2:R4 ; 01:73:01 ; genPointerGet ; genGenPointerGet mov dpl,r2 ;FIRST READ mov dph,r3 mov b,r4 lcall __gptrget ;GET RINDEX HIGH BYTE mov r2,a ;STORE IN R2 inc dptr ;SECOND READ <---***ERROR*** lcall __gptrget ;GET RINDEX LOW BYTE mov r3,a ;STORE IN R3 ; RINDEX IS R2:R3 ; 00:07 The CDB Record shows that rindex is a BYTE and at offset 5 T:Fcmdas$TTinyBuffer [ ({0}S:S$pNext$0$0({3}DG,STTTinyBuffer:S),Z,0,0) ({3}S:S$length$0$0({1}SC:U),Z,0,0) ({4}S:S$maxLength$0$0({1}SC:U),Z,0,0) ({5}S:S$rindex$0$0({1}SC:U),Z,0,0) <<------------- ({6}S:S$windex$0$0({1}SC:U),Z,0,0) ({7}S:S$buffer$0$0({100}DA100,SC:U),Z,0,0) ] This code fragment Does NOT produce the error : byte *bufferPtr(TBuffer *pBuf) { return pBuf->buffer + pBuf->rindex; } ; genPlus mov a,#0x05 add a,ar2 mov r2,a mov a,#0x00 addc a,ar3 mov r3,a ; genPointerGet ; genGenPointerGet mov dpl,r2 ;SINGLE READ HERE... mov dph,r3 mov b,r4 lcall __gptrget mov r2,a Thanks, --Lenny > -----Original Message----- > From: Bernhard Held [mailto:ber...@be...] > Sent: Wednesday, May 28, 2003 4:09 PM > To: sdc...@li... > Subject: Re: [sdcc-devel] FW: Endian Problem with Code Generation. > (FORGOT THE FILE) > > > > It seems the the compiler is storing integers with the > > incorrect endian order. This results in problems when you > > add an int to a Pointer value. 0x0175 + 0x0007 = 0x875 ! > sdcc uses little endian for all data types. > > > Integers are stored as 0x0007, and Pointers are 0x7501. One > > of them is wrong i would guess its the integer one. > Ack. However analyzing the read access isn't helpfull here. > You should examine > why there's 0x0700 (this is a value, not the representation > in memory) in > your index. > > Bernhard > > > > ------------------------------------------------------- > This SF.net email is sponsored by: eBay > Get office equipment for less on eBay! > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > _______________________________________________ > sdcc-devel mailing list > sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-devel > |