Shop OBEX P1 Docs P2 Docs Learn Events
C Objects in the Parallax Object Exchange — Parallax Forums

C Objects in the Parallax Object Exchange

ImageCraftImageCraft Posts: 348
edited 2008-09-01 00:39 in Propeller 1
Parallax informed me that you can now upload C object files in the Object Exchange. When you upload an object, you can specify whether it is Spin, asm, or C, and you can also sort the list as well based on the type field.

I hope ICC users will share their objects. Thank you for your support.

// richard
«1

Comments

  • jazzedjazzed Posts: 11,803
    edited 2008-08-09 18:31
    Is there some expectation of the package to be added? Working would be good I guess[noparse]:)[/noparse] What about makefiles, etc....

    ICC tends to create a lot of files, and the need for some of them are suspect. I wish ICC had a "clean" command so that generated files can be removed; putting generated files under source control is a no-no. The object exchange is a repository however lacking in normal source control tools it may be. I wouldn't want generated files there mainly because it's a waste of space and having them can cause big problems in some source control tools that professionals must use. I've used Eclipse for some C projects ... it has real and convenient source control; I would add makefiles for those projects to the object exchange I guess.

    It seems that the common denominator is really the C (*.c *.h *.s) source files. Adding just those files would be reasonable as there would be little clutter in the exchange and users can just pick them up and use them in projects.

    If one followed the example of what is created with the Propeller archive tool, the _README_.txt is similar to a Makefile, and the .spin files are like the C sources (*.[noparse][[/noparse]chs]).

    I'm not suggesting anyone must follow an example really. I just want a good idea of what the community thinks is appropriate so that I can start committing files to the exchange.

    This does open up a feature request for ICC ... Richard, it would be quite useful if ICC had an achive command similar to what the Propeller tool provides.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • ImageCraftImageCraft Posts: 348
    edited 2008-08-15 19:01
    Hm... good suggestion. What if I add a command like Project->"Archive Project" and it will save the relevant files, may be as a zip file (if I can get some public domain ZIP code). Would that be helpful and good enough? I guess I should have a companion command like Project->"Import Archived Project"
  • AleAle Posts: 2,363
    edited 2008-08-15 19:28
    The zlib has a nice license that I think allows binding to commercial software. It is available at www.zlib.net.

    Any chance of getting a standalone compiler and loader for linux and or mac osx ? I'm willing to pay for it! (Before I embark myself into adding a port to sdcc or gcc)
  • jazzedjazzed Posts: 11,803
    edited 2008-08-15 19:31
    That would be great Richard. Barring that, at minimum a "clean" would be nice to have to enable achieving a similar goal. Meanwhile, I'll start committing sources for drivers this weekend or Monday. I'm kind of busy now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BradCBradC Posts: 2,601
    edited 2008-08-16 14:13
    Ale said...
    (Before I embark myself into adding a port to sdcc or gcc)

    I've looked quite closely at both of those and I reckon SDCC is the way to go. GCC appears to be a target with a much higher bar..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • hippyhippy Posts: 1,981
    edited 2008-08-16 15:28
    When I looked at creating C for the Propeller, LCC was what I decided upon.

    That has a bytecode generator so it's a case of taking that bytecode and producing Propeller Code ( PASM, LMM or some other Propeller bytecode, even Spin bytecode ). A much simpler and easier proposition than writing the compiler itself. If one wants more than the compiler delivers out the box there's no choice but getting in up to one's elbow. It would be possible to rewrite the back-end code generator to target the Propeller to create a standalone compiler.

    That's possibly why ImageCraft have based their offering around LCC. While I was simply day-dreaming about it, they actually did it.

    Post Edited (hippy) : 8/16/2008 3:33:40 PM GMT
  • BradCBradC Posts: 2,601
    edited 2008-08-16 16:59
    hippy said...
    even Spin bytecode

    This is something I've been thinking about pretty seriously.. It's not suitable for everything, but the SPIN bytecode is reasonably flexible.. why not a compiler for BASIC.. or PASCAL.. or C to target the SPIN Interpreter..

    Maybe a spin compiler that understands a "BAS" block or A "CC" block..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • AleAle Posts: 2,363
    edited 2008-08-16 19:48
    Did they use LCC ?, the license does not allow that.... I think they did say something about using their current ARM offring as a base...

    Well I have added a new port to LCC, it is crude, it needs some serious help from a kernel but it works (sort of)... but I'll do my best to have something more working really soon. Stay tuned.

    Here a crude example

    int func1(int a, int b, int c)
    {
        for (; a < 16; a++)
            b += a *c;
        return b;
    }
    
    int func2(void)
    {
        return func1(1, 4, 5) - 8;
    }
    
    
    **
    .set reorder
    .globl func1
    .text
    .text
    .align 2
    .ent func1
    func1:
    .frame krnl_sp,0,$31
    .set noreorder
    .cpload $25
    .set reorder
                    call #krnl_j
                    long L.5
    L.2:
                    call #krnl_mul
                    long (krnl_r24<<26)+(krnl_r4<<9)+krnl_r6
                    add krnl_r5,$24
    L.3:
                    mov krnl_r4,1($4)
    L.5:
                    mov krnl_r24,16
                    blt $4,$24,L.2
                    move krnl_r2,krnl_r5
    L.1:
                    call_ret
    .end func1
    .globl func2
    .text
    .align 2
    .ent func2
    func2:
    .frame krnl_sp,32,$31
    .set noreorder
    .cpload $25
    .set reorder
                    sub krnl_sp,#32
    .mask 0x82000000,-12
    .cprestore 16
                    call #krnl_swsp
                    long (krnl_r31<<26)+20
                    mov krnl_r4,1
                    mov krnl_r5,4
                    mov krnl_r6,5
                    call #krnl_jal
                    long func1
                    move krnl_r24,krnl_r2
                    sub krnl_r24,8
    L.6:
                    call #krnl_lwsp
                    long (krnl_r25<<26)+16
                    call #krnl_lwsp
                    long (krnl_r31<<26)+20
                    add krnl_sp,#32
                    call_ret
    .end func2
    
    
  • hippyhippy Posts: 1,981
    edited 2008-08-16 21:05
    Ale said...
    Did they use LCC ?, the license does not allow that.... I think they did say something about using their current ARM offring as a base...

    I cannot comment on licensing and any agreements, or how extensively LCC may be used, but iccv7prop certainly acknowledges its use and indicates relevant permissions have been granted ...

    C:\iccv7prop\bin\imakew -f TEST.mak
        iccprop -c -e -D__ICC_VERSION="7.00 BETA2" -DP8X32A  -l -v -g -Wa-g  test.c
    Copyright (C) 1994 - 2005 ImageCraft
    ImageCraft, 706 Colorado Ave., Suite 10-88, Palo Alto, CA 94303
    info@imagecraft.com, phone (650) 493-9326 FAX (650) 493-9329
    http://www.imagecraft.com
    lcc source code (C) 1995, by David R. Hanson and AT&T. Reproduced by permission.
    
    



    Full LCC lcensing details here : drh.svnrepository.com/svn/lcc/trunk/CPYRIGHT

    Writing a standalone bytecode to Propeller back-end would probably be okay. IANAL.

    Post Edited (hippy) : 8/16/2008 9:10:27 PM GMT
  • ImageCraftImageCraft Posts: 348
    edited 2008-08-17 00:17
    Yes, we licensed the LCC front end back in 1994. Still have the contract Agreement smile.gif I am not entirely clear who owns the current copyright anymore. When we negotiated the contract, it was with Addison Wellesey, the book publisher and not the authors of LCC, as that was their arrangements. A-W got bought up by an other company, which got bought up by another, and... Since our COntract is a perpetual use, it doesn't matter to us.

    The backend lburg is great.... for 32 bits RISC machines. All our code generators generate some sort of pseudo-asm code internally so we can perform optimizations. Otherwise, the code will not be competitive for production use.
  • jazzedjazzed Posts: 11,803
    edited 2008-08-17 00:38
    BradC said...
    hippy said...
    even Spin bytecode

    This is something I've been thinking about pretty seriously.. It's not suitable for everything, but the SPIN bytecode is reasonably flexible.. ....
    This is attractive for memory size especially if the built-in interpreter commands can be exposed. Performance would not be as expected for a typical C environment, but·that's ok.·Now if there was a way to choose the optimization for given pieces of code, that would be nice.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • AleAle Posts: 2,363
    edited 2008-08-17 05:22
    Well, that shows that I haven't used ImageCraft's ICC wink.gif.

    Spin byte code could be generated. But that would mean converting a register based compiler into a stack based one... maybe with a modified kernel that could be done more efficiently, it should be possible.
  • hippyhippy Posts: 1,981
    edited 2008-08-17 09:39
    Generating Spin bytecode isn't really any advantage other than in saving time in coding up a dedicated interpreter.

    My approach would be to design a virtual instruction set which does the job required, knock up a a simple assembler for that and then optimise from there.
  • RaymanRayman Posts: 14,243
    edited 2008-08-18 00:59
    I don't think I like the way Parallax added C objects to the Object Exchange. I think they should be (when they exist) on a seperate page. Spin and ASM can be mixed and matched, but I think it's difficult to add Spin to a C object.
  • hippyhippy Posts: 1,981
    edited 2008-08-18 13:59
    If looking for C objects one probably wouldn't want to see reams of non-C objects.
  • jazzedjazzed Posts: 11,803
    edited 2008-08-18 14:50
    Well, at least you can sort on the "language" attributes. Maybe Parallax can add a "C" group icon and an "ASM" group icon?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • RaymanRayman Posts: 14,243
    edited 2008-08-18 18:00
    I didn't think of sorting by the "language"... I guess that will work. At least, until there are a lot of them...

    Jazzed: Are you going to post your C VGA driver?
  • jazzedjazzed Posts: 11,803
    edited 2008-08-18 19:01
    I've posted "C TV_Text" driver to the object exchange today.
    I will post more as time permits (one a day if possible).

    I have several drivers to add:
    • FdSerial - bin-array version of FullDuplexSerial.spin
    • FSRW - bin-array version of Tom's fsrw.spin
    • Mouse - bin-array version of Mouse.spin
    • VGA_Text - bin-array version of VGA_Text.spin
    • Timer - lets user add linked list of functions to run in a COG

    --Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • jazzedjazzed Posts: 11,803
    edited 2008-08-19 17:27
    Rayman,

    The VGA_Text code ships with ICC software. I'll commit it to OBEX last.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
  • RaymanRayman Posts: 14,243
    edited 2008-08-19 19:57
    Jazzed: I'm glad you're going to post FdSerial. I think I'll need that in the near future...
  • jazzedjazzed Posts: 11,803
    edited 2008-08-26 18:01
    Hello again.

    I got behind on my OBEX commits. Today I took time to post all the OBEX quality C source I have. This includes Tom's fswr code ... Tom, if you want me to pass control back to you please speak up.

    Just wanted to point out that anyone can take a PASM driver and convert it to a C module by creating an ASCII-byte array. This is what I did for most of the work committed to OBEX. I hope I'm not the only C programmer that will have a desire to contribute to the community.

    Thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve

    Post Edited (jazzed) : 8/26/2008 6:11:21 PM GMT
  • RaymanRayman Posts: 14,243
    edited 2008-08-26 18:05
    jazzed,

    Thanks for posting your serial driver!

    Is the procedure to "take a PASM driver and convert it to a C module by creating an ASCII-byte array" documented anywhere?
  • jazzedjazzed Posts: 11,803
    edited 2008-08-26 18:19
    @Rayman. Not formally.·I use a script that relies on linux tools or cygwin. Here is the batch file I use. The number of bytes to skip to get the DAT section is usually the number of PUB methods*4+16 assuming no included objects.

    @echo /**
    @echo  * @file %1.h - defines %1 array include file
    @echo  * automatically generated with: "px %1 %2 %3 > %1.h"
    @echo  * @param %1 is array[noparse][[/noparse]] name
    @echo  * @param %2 is input file name
    @echo  * @param %3 is beginning of file number of bytes to skip
    @echo  */
    @echo off
    @echo long %1[noparse][[/noparse]] = {
    @od -v -t x4z %2 -j %3 | sed "s/ /, 0x/g" | cut -d" " --fields 2,3,4,5,6 | sed "s/ 0x,//g"
    @echo };
    @echo off
    
    

    I'll put this on the wiki later.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
  • jazzedjazzed Posts: 11,803
    edited 2008-08-26 19:01
    I have been asked to provide a copyright notice on all the files I've contributed to the OBEX in addition to the MIT license blocks I included. While I find it absurd to require a copyright claim on works for which I do not care to claim copyrights, I will abide by the "current rules" and add this information as time permits.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-08-26 22:21
    The point is to provide a homogenous set of libraries in terms of licensing so that people who want to use them understand precisely what can and can't be done with the libraries. It puts the legal department of a company as ease when they see this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-26 22:40
    jazzed,
    I'm not a lawyer, but I understand the need for copyright is that you can't have licensing rules if you don't claim a copyright. You can say "This is mine, but I give it away", but you can't make any claim or set any requirements if you don't "own" it to begin with.
  • jazzedjazzed Posts: 11,803
    edited 2008-08-26 23:12
    Whatever. I'll put copyright john doe next time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
  • ImageCraftImageCraft Posts: 348
    edited 2008-08-26 23:21
    jazzed said...
    @Rayman. Not formally. I use a script that relies on linux tools or cygwin. Here is the batch file I use. The number of bytes to skip to get the DAT section is usually the number of PUB methods*4+16 assuming no included objects.



    [noparse][[/noparse]code]

    @echo /**
    @echo * @file %1.h - defines %1 array include file
    @echo * automatically generated with: "px %1 %2 %3 > %1.h"
    @echo * @param %1 is array[noparse]/noparse name
    @echo * @param %2 is input file name
    @echo * @param %3 is beginning of file number of bytes to skip
    @echo */
    @echo off
    @echo long %1[noparse]/noparse = {
    @od -v -t x4z %2 -j %3 | sed "s/ /, 0x/g" | cut -d" " --fields 2,3,4,5,6 | sed "s/ 0x,//g"
    @echo };
    @echo off



    I'll put this on the wiki later.

    Hey Steve, that shouldn't be difficult to add as a function in our IDE. I mean converting what od/cur/sed is doing to C/C++ smile.gif
  • jazzedjazzed Posts: 11,803
    edited 2008-08-31 17:06
    ImageCraft said...
    ...
    Hey Steve, that shouldn't be difficult to add as a function in our IDE. I mean converting what od/cur/sed is doing to C/C++ smile.gif

    Please help me test the included Windows console application.

    It is·a C based·application that extracts the DAT section from a spin binary and creates an ASCII-byte (long actually) array for use in a driver. The "entry org 0" should be the first code in the DAT section for this to work. The app decodes the spin bytes so you don't have to do it.

    I've tried this on a few projects and am quite happy with it so far. I'll send the source to Richard after more test results. Here are some output examples.

    C:\>spinc
    Convert Spin DAT PASM to a C ASCII-HEX array.
    spinc <filename>
    

    C:\ICC Projects\interrupts>spinc IntSpin.binary
    /**
     * @file IntSpin_array.h
     * Created with spin.binary PASM to C Array Converter.
     * Copyright (c) 2008, John Doe
     */
    long IntSpin_array[noparse][[/noparse]] =
    {
        0xa0bc27f0, 0xa0bc29f0, 0x80fc2804, 0xa0bc2bf0,
        0x80fc2a08, 0xa0bc2df0, 0x80fc2c0c, 0x08bc2215,
        0x64bfec11, 0x08bc2416, 0x08bc2014, 0xa0bc23f2,
        0x6cbc2212, 0x62bc2210, 0x08142213, 0x5c7c000a,  0
    };
    


    TIA

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve
  • simonlsimonl Posts: 866
    edited 2008-08-31 18:02
    Hey Steve - you're just teasing aren't you! I spy the 'I' word wink.gif Want to spill the beans?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again wink.gif
    BTW: I type as I'm thinking, so please don't take any offence at my writing style smile.gif
Sign In or Register to comment.