struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / device / lib / mos6502 / _srslonglong.c
blob01d38ca169a24f86755645bb82342075b4808c44
1 #include <stdint.h>
3 #ifdef __SDCC_LONGLONG
5 long long _srslonglong(long long l, char s)
8 uint8_t *const b = (uint8_t *)(&l);
9 unsigned char shift,t1,t2, sign;
10 signed char zb,i;
12 sign=b[7]&0x80;
14 zb=s>>3;
15 if(zb) {
16 i=0;
17 for(;i<(8-zb);i++) {
18 b[i]=b[zb+i];
20 for(;i<8;i++)
21 b[i]=sign?0xff:0x00;
24 shift=s&0x7;
25 while(shift--) {
26 t2=sign;
27 for(i=7-zb;i>=0;i--) {
28 t1=b[i]&1;
29 b[i]=(b[i]>>1)|t2;
30 t2=t1?0x80:0;
34 return(l);
37 #endif