gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/asm/mos6502/_rrslonglong.c
1
2 #pragma std_c99
3
4 #include <stdint.h>
5
6 #ifdef __SDCC_LONGLONG
7
8 long long _rrslonglong(long long l, char s)
9 {
10
11 uint8_t *const b = (uint8_t *)(&l);
12 unsigned char shift,t1,t2, sign;
13 signed char zb,i;
14
15 sign=b[7]&0x80;
16
17 zb=s>>3;
18 if(zb) {
19 i=0;
20 for(;i<(8-zb);i++) {
21 b[i]=b[zb+i];
22 }
23 for(;i<8;i++)
24 b[i]=sign?0xff:0x00;
25 }
26
27 shift=s&0x7;
28 while(shift--) {
29 t2=sign;
30 for(i=7-zb;i>=0;i--) {
31 t1=b[i]&1;
32 b[i]=(b[i]>>1)|t2;
33 t2=t1?0x80:0;
34 }
35 }
36
37 return(l);
38 }
39
40 #endif
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.