Shop OBEX P1 Docs P2 Docs Learn Events
program in prop assembly — Parallax Forums

program in prop assembly

richaj45richaj45 Posts: 179
edited 2008-03-03 02:36 in Propeller 1
Question:

If i wanted to only program in prop assembly then i would be limited to one 512 instruction per cog and no more? That is, to use the 32k bytes of hub ram for a program it can not be COG asm code but must be some interpreted code that a cog asm program is interpreting?

rich

Post Edited By Moderator (Joshua Donelson (Parallax)) : 10/23/2009 4:48:36 AM GMT

Comments

  • hippyhippy Posts: 1,981
    edited 2008-03-01 03:16
    Yes, each cog is 512 x 32-bit, of which 496 can be used for code and/or data, the other 16 are Special Function registers.

    You can either interpret arbitrary bytecode, p-code etc from the Hub RAM, run PASM an instruction at a time loaded from Hub RAM using Large Memory Model (LMM) coding, or page in code overlays which can then run full-speed.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-01 03:17
    You can actually only use the first 496 longs in a cog since the last 16 are used for other things (timers, input output etc). If you want to make programs longer than this can you can use LMM code (see propeller.wikispaces.com/Large+Memory+Model or you can store some of your program in the hub and swap bits from/to the hub as needed. Its complicated but have a look at what I am doing in this thread http://forums.parallax.com/showthread.php?p=711713
  • Chuck McManisChuck McManis Posts: 65
    edited 2008-03-01 05:28
    Not to be pedantic, but if you were really careful you could store assembly code in RAM and page it in. You'd probably end up with about 128 words (or thereabouts) but given the self modifying nature of cog assembly you could "page in" with an assembly loop and then jump into the page you just loaded. Of course keeping it there would be problematic as you don't have an MMU to throw a pagefault so you'd have to fix up references going in and coming out of any of your assembly.

    Generally its safer to just think of it as a flat 496 words of space I think.

    --Chuck
  • deSilvadeSilva Posts: 2,967
    edited 2008-03-01 08:34
    If someone is interested in the technique Chuck refers to, I could post some examples. It is just a matter of "organization". Most PASM support routines are only 100 instructions or even less.

    Loding them takes 100 µs (which can even be reduced stopping at the logical end of the overlay) which corresponds to 5 to 10 SPIN instructions. E.g. incrementing a vector of 16 elements will take:
    :loop
       RDLONG  x,    haddr
       ADD        x,   #1
       WRLONG X,   haddr
       ADD       haddr,  #4
       DJNZ      _16, :loop
    


    negligeable 32x16*12.5 ns = 6,25 µs

    Doing this loop in SPIN will be
    REPEAT x FROM 0 to 15
      HADDR[noparse][[/noparse]x] ++
    


    and take more than 500 µs

    So this is something of an "break even point" smile.gif

    Post Edited (deSilva) : 3/1/2008 9:10:04 AM GMT
Sign In or Register to comment.