struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / device / lib / mos6502-stack-auto / _srulonglong.c
blob2f5d151b97bfe967c1d58e324c6933e5f42b9a50
1 #include <stdint.h>
3 #ifdef __SDCC_LONGLONG
5 unsigned long long _srulonglong(unsigned long long l, char s)
7 uint8_t *const b = (uint8_t *)(&l);
8 unsigned char shift,t1,t2;
9 signed char zb,i;
11 zb=s>>3;
12 if(zb) {
13 for(i=0;i<(8-zb);i++) {
14 b[i]=b[zb+i];
17 for(;i<8;i++)
18 b[i]=0;
21 shift=s&0x7;
22 while(shift--) {
23 t2=0;
24 for(i=7-zb;i>=0;i--) {
25 t1=b[i]&1;
26 b[i]=(b[i]>>1)|t2;
27 t2=t1?0x80:0;
31 return(l);
34 #endif