Shop OBEX P1 Docs P2 Docs Learn Events
Propeller start up procedure ? — Parallax Forums

Propeller start up procedure ?

Chris MicroChris Micro Posts: 160
edited 2009-06-26 13:30 in Propeller 1
Hello together,

how is the start up procedure of the propeller?

If we have the following code:
pub xx
  cognew(@start,0)
dat
  org 0
start
  mov r0,#2
  add r0,#1
...



Where in the Hub memory the assembler code is starting?
If I take a look at the hex dump in the propeller tool, the

mov r0,#2 instruction seems to begin at address 0x18.

Is the first dat section always begining at this address?

Help appreciated,
chris

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-23 18:47
    There is no fixed location for the assembler code. The location depends on what else makes up your program. All you can tell is that, in the small sample program you posted, the assembly code started at location $0018. There is no way to control where it goes with the Propeller Tool. Some of the other 3rd party Spin compilers have some control of where the code goes, but it's normally not important.

    The Propeller's bootloader always starts up an initial Spin interpreter in a single cog and that interpreter finds its program based on the information stored in the 1st 16 bytes of the hub memory. That program starts with the first method in the outermost object, in your case "xx" and that method does whatever is needed by the overall program. In your case, it starts up a new cog with the assembly routine at the label "start".
  • Chris MicroChris Micro Posts: 160
    edited 2009-06-23 18:59
    Uhh, that sound complicated.



    I would need it for my little emulator project.
    Because the memory is so small, I can run only propeller assembler routines.
    The only idea I have at the moment is to begin the assembler routines with a dummy fixed starting sequence like

      mov PAR,#1
      mov PAR,#$55
      mov PAR,#$AA
    ...
    
    



    I can search for this sequence to get the start of the routine.

    Mike, thank you for the quick answer,
    chris
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-23 19:16
    It's always helpful at the outset to say what you're trying to accomplish ...

    How about:
    DAT
    marker   long    $55AA1133
                 org     0
    start       .....
    



    Your emulator would just search for marker and begin emulation immediately after that word. Something like:
    pri findStart | i
       for i := $0010 to $7FFC
          if long[noparse][[/noparse] i] == marker
             return i + 4
    
  • Chris MicroChris Micro Posts: 160
    edited 2009-06-23 20:27
    ok, that's better. I will take your solution smile.gif

    thank you,
    chris
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-06-23 20:34
    Do you have a propeller running? Maybe with an SD-card?

    I guess what you want is to extract some PASM-code to let it run on your emulator, right? With a propeller setup it's easy. Just write the dat section to an SD-Card. A while ago I posted some code which is doing that. PASMStore was the name ... if I'm right with my guess I can search for it or post it again.


    Edit: Currently it's the last post of this thread http://forums.parallax.com/showthread.php?p=794696·. Of course you could also replace the save to SD-Card with a send to PC via serial port. HyperTerminal allows to save data it receives via serial port.

    Post Edited (MagIO2) : 6/23/2009 8:54:00 PM GMT
  • BradCBradC Posts: 2,601
    edited 2009-06-24 00:21
    Chris Micro said...
    Hello together,

    how is the start up procedure of the propeller?

    If we have the following code:
    pub xx
      cognew(@start,0)
    dat
      org 0
    start
      mov r0,#2
      add r0,#1
    ...
    
    


    Where in the Hub memory the assembler code is starting?
    If I take a look at the hex dump in the propeller tool, the

    mov r0,#2 instruction seems to begin at address 0x18.

    Is the first dat section always begining at this address?

    If you only ever have one spin method then yes, it always starts at 0x18. For each object and spin method you add, you add 4 bytes to that offset.

    PBASE is always 0x10 for the top object, so you will _always_ find the method table at 0x10. Each entry in the method table takes 4 bytes, plus 4 bytes for the table header. The DAT segment is always located directly after the method table.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Missed it by ->" "<- that much!
  • RossHRossH Posts: 5,512
    edited 2009-06-24 00:33
    Hi Brad,

    It took me ages to figure this out for myself - and it seems that as we continue to push the limits of the Prop, more and more people need to know this kind of thing. Is this actually documented anywhere that you know of? Searching these forums to try and find little gems such as this is very frustrating.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • jazzedjazzed Posts: 11,803
    edited 2009-06-24 01:06
    @RossH,

    Try this: http://forums.parallax.com/showthread.php?p=736449

    Guess we could make better use of the Wiki ....

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


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • RossHRossH Posts: 5,512
    edited 2009-06-24 01:39
    @jazzed,

    Boomarked. Thanks.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • heaterheater Posts: 3,370
    edited 2009-06-24 05:55
    Chris: If you want just the assembled pasm bytes you might find the propasm assembler useful.

    www.cliff.biffle.org/software/propeller/propasm/

    Usage: java <vm options> -jar propasm.jar <flags> <input files>
    Any number of input files may be specified, though specifying zero
    will get you this message.
    Flags:
    -raw Generate raw machine code without a bootloader.
    The Propeller won't load the output directly; this is useful for making
    a "coglet" to include in larger assembly programs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2009-06-24 09:50
    RossH said...
    Hi Brad,

    It took me ages to figure this out for myself - and it seems that as we continue to push the limits of the Prop, more and more people need to know this kind of thing. Is this actually documented anywhere that you know of? Searching these forums to try and find little gems such as this is very frustrating.

    Ross.

    Hippy, Bill and Aextrix(spelling?) were the first to document it apart from chip. You probably know all this know but heres a couple of files that Hippy did up ages ago (before he had the spin source). I think that purpose of one of the other numbers in the object header was figured out but I can't remember. Most of it should be able to figure out from the spin code now but that isn't necessarily the easiest thing to do.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2009-06-24 10:03
    There's some info from Chip about half way down this page that's already repeated in the threads linked to above but just for interests sake http://forums.parallax.com/showthread.php?p=589824
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-06-24 10:12
    Homespun and/or bst support the @@@start directive to locate the actual hub address of the cog start routine.
    There are other ways as well. So it really depends on what you are trying to achieve.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, RamBlade, TwinBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index) ZiCog (Z80), MoCog (6809)
    · Search the Propeller forums (via Google)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Chris MicroChris Micro Posts: 160
    edited 2009-06-26 13:30
    Thank you for all the information. smile.gif
    For the first version of the cog-emulator I used the magic number principle.
    It is compiled for a LINUX command line ( because for some strange reasons my installed visual c++ express studio couldn't find stdio.h ).

    So, if you have linux, you can try the cog-emulator with my little example program ( see attached file ).
    I would be very glad, if someone could try the program. yeah.gif

    chris
Sign In or Register to comment.