git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/asm/mos6502/_rrulonglong.c

      1 
      2 #pragma std_c99
      3 
      4 #include <stdint.h>
      5 
      6 #ifdef __SDCC_LONGLONG
      7 
      8 unsigned long long _rrulonglong(unsigned long long l, char s)
      9 {
     10 
     11   uint8_t *const b = (uint8_t *)(&l);
     12   unsigned char shift,t1,t2;
     13   signed char zb,i;
     14   
     15   zb=s>>3;
     16   if(zb) {
     17     for(i=0;i<(8-zb);i++) {
     18       b[i]=b[zb+i];
     19     }
     20   
     21     for(;i<8;i++)
     22       b[i]=0;
     23   }
     24   
     25   shift=s&0x7;
     26   while(shift--) {
     27     t2=0;
     28     for(i=7-zb;i>=0;i--) {
     29       t1=b[i]&1;
     30       b[i]=(b[i]>>1)|t2;
     31       t2=t1?0x80:0;
     32     } 
     33   }
     34   
     35   return(l);
     36 }
     37 
     38 #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.