Shop OBEX P1 Docs P2 Docs Learn Events
LLVM Backend for Propeller 2 - Page 13 — Parallax Forums

LLVM Backend for Propeller 2

1789101113»

Comments

  • Is long long (64) bit supported?

    I have this code that generates two different answers and don't know if this is correct:

    int main(int argc, char** argv)
    {
        long long t;
        int d1;
        unsigned int c5;
        int x;
    
        printf("Starting\n");
    
        x = rand() % 10;
        printf("Rand: %d\n", x);
    
        d1 = 8052495 + x;
        c5 = 31559;
    
        t = d1 - (c5 << 8);
        x = d1 - (c5 << 8);
    
        printf("t: %lld, x: %d\n", t, x);
    
        printf("Done\n");
    
        while (1)
        {
            wait(500);
        }
    }
    

    The long value is 4294941851 were the int value is -25445 which is the answer I was looking for.

    Mike

  • 64 bit ints and doubles should work, but I haven't tested them thoroughly, so if you find bugs, let me know, but I've been using them and having found any issues yet. Many floating point operations aren't supported yet (the code is there, I just need to actually enable compiling it into the library. I've been doing it piece by piece to avoid adding a ton of code at once and then hunting down bugs later).

  • @iseries I just merged in a rewrite of stdio and your SD card code. I haven't tested the sd stuff, and the changes to stdio shouldn't be breaking anything, EXCEPT I removed simple_printf. After the rewrite of printf, it didn't really makes sense to keep simple_printf since it was only slightly smaller and faster, not enough to keep both implementations. Let me know if you run into any issues.

  • Yes, the SD card functions has a bug in it and I didn't know how to send an updated version to an alread submitted pull request.

    Apparently all I had to do was update it.

    Anyway I need to send you an update to the SD card functions. Also hopefully the memory functions that I updated and you merged in work for you.

    Mike

  • Submitted update SD driver code.

    Speed test program that was used:

    #include <stdio.h>
    #include <sys/time.h>
    #include <stdlib.h>
    #include <propeller.h>
    #include <sys/sdcard.h>
    
    uint32_t randfill(uint32_t *, size_t);
    int  compare(uint32_t *, uint32_t *, size_t);
    
    #define PIN_SS   23
    #define PIN_MISO 20
    #define PIN_CLK  21
    #define PIN_MOSI 22
    
    uint32_t  data1[25000];
    uint32_t  data2[25000];
    struct tm tv;
    
    
    int main(int argc, char** argv)
    {
        FILE  *fh;
        uint32_t  ticks;
        time_t t;
        struct timeval x;
    
        tv.tm_year = 2022 - 1900;
        tv.tm_mon = 3;
        tv.tm_mday = 7;
        tv.tm_hour = 6;
        tv.tm_min = 0;
        tv.tm_sec = 0;
        t = mktime(&tv);
        x.tv_sec = t;
        x.tv_usec = 0;
    
        settimeofday(&x, 0);
    
        printf( " clkfreq = %d   clkmode = 0x%x\n", _clkfreq, _clkmode);
        printf( " Randfill ticks = %d\n", randfill( data1, sizeof(data1) ) );
    
        printf( " Mounting: " );
        sd_mount(0, PIN_SS, PIN_CLK, PIN_MOSI, PIN_MISO);
    
        if( (fh = fopen( "SD0:/speed2.bin", "w" )) > 0 )
        {
            ticks = getms();
            fwrite( data1, 1, sizeof(data1), fh );
            fclose( fh );
            ticks = getms() - ticks;
            printf( " Writing %u bytes at %u kB/s\n", sizeof(data1), (sizeof(data1) * 1000 / ticks + 512) >> 10 );
        } else  printf( " SD card write error!\n" );
    
        if( (fh = fopen( "SD0:/speed2.bin", "r" )) > 0 )
        {
            ticks = getms();
            fread( data2, 1, sizeof(data2), fh );
            fclose( fh );
            ticks = getms() - ticks;
            printf( " Reading %u bytes at %u kB/s\n", sizeof(data2), (sizeof(data2) * 1000 / ticks + 512) >> 10 );
            if( compare( data1, data2, sizeof(data2) ) )  printf( " Matches!  :)\n" );
            else    printf( " Mis-matches!  :(\n" );
        } else  printf( " SD card read error!\n" );
    
        while (1)
        {
            waitms(500);
        }
    }
    
    uint32_t  randfill( uint32_t *addr, size_t size )
    {
        uint32_t  ticks;
    
        size >>= 2;
        ticks = _cnt();
        do {
            *(addr++) = rand();
        } while( --size );
    
        return( _cnt() - ticks );
    }
    
    
    int  compare( uint32_t *addr1, uint32_t *addr2, size_t size )
    {
        uint32_t  pass = 1;
    
        size >>= 2;
        do {
            if( *(addr1++) != *(addr2++) )  pass = 0;
        } while( --size );
    
        return( pass );
    }
    

    Mike

Sign In or Register to comment.