Shop OBEX P1 Docs P2 Docs Learn Events
What's in the 'Initialization' section? — Parallax Forums

What's in the 'Initialization' section?

RossHRossH Posts: 5,422
edited 2008-07-22 01:43 in Propeller 1
The first $10 bytes of Propeller code are labelled 'Initialization' when you look at them in the Propeller IDE. I know a couple of longs are used for the CLK and FREQ values, but what are the others used for? All I can find in the manual are that these are the "initial interpreter pointers"

I have written a high resolution VGA driver which uses whatever free RAM is available to implement a virtual screen bitmap. But currently I have to manually tell the program where the free RAM starts. I am sure that one of the values in the Initialization section has this value - there are a couple of values in there that look to be likely candidates, but I'm not sure which one to use.

Does anyone have a definition for what these other Initialization values are?

Thanks,

Ross.

Comments

  • RossHRossH Posts: 5,422
    edited 2008-07-21 06:56
    After a few more searches I think I found what I needed in this thread:

    http://forums.parallax.com/forums/default.aspx?f=25&m=221434

    But it still be good to get some "official" confirmation from Parallax.

    Ross.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-21 12:50
    Here's the information:
    $0000: XX XX XX XX - internal clock frequency in Hz (long)
    $0004: XX                - value to be written to clock register (byte)
    $0005: XX                - checksum so that all RAM bytes will sum to 0 (modulus 256)
    $0006: XX XX           - 'pbase' (word) must be $0010
    $0008: XX XX           - 'vbase' (word) number of longs loaded times 4
    $000A: XX XX           - 'dbase' (word) where two $FFF9FFFF's get placed
    $000C: XX XX           - 'pcurr' (word) points to Spin code
    $000E: XX XX           - 'dcurr' (word) points to local stack (above $FFF9FFFF)
    
  • hippyhippy Posts: 1,981
    edited 2008-07-21 13:04
    And in graphical form ...

                               .----------.
                               |__________|         Long : Frequency (Hz)
                               |__|                 Byte : XTAL mode
                               |__|__               Byte : Checksum
                    .----------|_____|              Word : Base of program
                .---|----------|_____|              Word : Base of variables
              .-|---|----------|_____|              Word : Base of stack
              | | .-|----------|_____|              Word : Initial program counter
            .-|-|-|-|----------|     |              Word : Initial stack pointer
            | | | | |          `-----'
            | | | | |
            | | | | |          .----------.
            | | | | `-> .------|__________|    +0   Pointer to next object
            | | | |     |   .--|__________|    +1   Pointer to first method
            | | | |     |   |  |__________|
            | | | |     | .-|--|          |    +N   Pointer to last method
            | | | |     | | |  |----------|
            | | | |     | | |  | DAT      |         Data Area
            | | | |     | | |  |----------|
            | | | `---> | | `->| PUB      |
            | | |       | |    :          :         Methods
            | | |       | `--->| PRI      |
            | | |       |      `----------'
            | | |       |      .----------.
            | | `-----> `----->| vars     |        Main Program Variables
            | |                |          |
            | |                `----------'
            | |                .----------.
            | `--------------->| stack    |         Stack Space
            `----------------->|          |
                               `----------'
    
    
    



    There's no easy way to tell where the last byte of used Ram is as that depends upon the stack space used at run-time. It is possible to know the start of stack ( through word[noparse][[/noparse]$000A] ) which would give an indication of how much free Ram there were when the program starts.

    You could run your program using minimal Ram then check where the stack 'high-water mark' was to get a ballpark idea of stack space being used once you'd exercised the code.
  • RossHRossH Posts: 5,422
    edited 2008-07-22 01:43
    Thanks Mike and hippy.
Sign In or Register to comment.