## [sdcc-devel] Variable left shifts

 [sdcc-devel] Variable left shifts From: Scott Dattalo - 2002-03-14 14:24:47 ```I'm in the process of committing my latest pic port changes. But before I do this, I want to pass all of my regression tests (which are different than the main regression tests). I came across a failure for left shifts. I have a function: unsigned char achar0; unsigned char achar1; ... void shift_left_var(void) { achar0 <<= achar1; } I discovered that achar0 is getting case to 16 bits. This is clearly unnecessary. So I poked around and found this comment in SDCCast.c (around line 2674): /* a left shift must be done with at least 16bits */ --- ?!? My question is: why must a left shift be done with at least 16 bits? I could understand if the destination was 16 or more bits. However, it is clear that the size of all operands is 8 bits. Scott ```

 [sdcc-devel] Variable left shifts From: Scott Dattalo - 2002-03-14 14:24:47 ```I'm in the process of committing my latest pic port changes. But before I do this, I want to pass all of my regression tests (which are different than the main regression tests). I came across a failure for left shifts. I have a function: unsigned char achar0; unsigned char achar1; ... void shift_left_var(void) { achar0 <<= achar1; } I discovered that achar0 is getting case to 16 bits. This is clearly unnecessary. So I poked around and found this comment in SDCCast.c (around line 2674): /* a left shift must be done with at least 16bits */ --- ?!? My question is: why must a left shift be done with at least 16 bits? I could understand if the destination was 16 or more bits. However, it is clear that the size of all operands is 8 bits. Scott ```
 RE: [sdcc-devel] Variable left shifts From: Sandeep Dutta - 2002-03-14 14:41:28 ```Hi Scott, This is the bug that Johan has been bugging me to fix for a while. Will fix this over the weekend. Sandeep > -----Original Message----- > From: sdcc-devel-admin@... > [mailto:sdcc-devel-admin@...]On Behalf Of Scott > Dattalo > Sent: Thursday, March 14, 2002 6:25 AM > To: sdcc-devel@... > Subject: [sdcc-devel] Variable left shifts > > > > I'm in the process of committing my latest pic port changes. > But before I > do this, I want to pass all of my regression tests (which are > different > than the main regression tests). I came across a failure for > left shifts. > > I have a function: > > unsigned char achar0; > unsigned char achar1; > > > ... > > > void shift_left_var(void) > { > > achar0 <<= achar1; > } > > > I discovered that achar0 is getting case to 16 bits. This is clearly > unnecessary. So I poked around and found this comment in > SDCCast.c (around > line 2674): > > /* a left shift must be done with at least 16bits */ > > --- > > ?!? > > My question is: why must a left shift be done with at least 16 bits? I > could understand if the destination was 16 or more bits. > However, it is > clear that the size of all operands is 8 bits. > > Scott > > > _______________________________________________ > sdcc-devel mailing list > sdcc-devel@... > https://lists.sourceforge.net/lists/listinfo/sdcc-devel > ```
 RE: [sdcc-devel] Variable left shifts From: Sandeep Dutta - 2002-03-16 18:13:09 ```This is fixed. Now a cast will be added if a) the shifting more than sizeof object b) if assigned to size > left of shift operation. Sandeep > -----Original Message----- > From: sdcc-devel-admin@... > [mailto:sdcc-devel-admin@...]On Behalf Of Scott > Dattalo > Sent: Thursday, March 14, 2002 6:25 AM > To: sdcc-devel@... > Subject: [sdcc-devel] Variable left shifts > > > > I'm in the process of committing my latest pic port changes. > But before I > do this, I want to pass all of my regression tests (which are > different > than the main regression tests). I came across a failure for > left shifts. > > I have a function: > > unsigned char achar0; > unsigned char achar1; > > > ... > > > void shift_left_var(void) > { > > achar0 <<= achar1; > } > > > I discovered that achar0 is getting case to 16 bits. This is clearly > unnecessary. So I poked around and found this comment in > SDCCast.c (around > line 2674): > > /* a left shift must be done with at least 16bits */ > > --- > > ?!? > > My question is: why must a left shift be done with at least 16 bits? I > could understand if the destination was 16 or more bits. > However, it is > clear that the size of all operands is 8 bits. > > Scott > > > _______________________________________________ > sdcc-devel mailing list > sdcc-devel@... > https://lists.sourceforge.net/lists/listinfo/sdcc-devel > ```