Shop OBEX P1 Docs P2 Docs Learn Events
Reclaiming DAT space? — Parallax Forums

Reclaiming DAT space?

mparkmpark Posts: 1,305
edited 2008-08-11 21:34 in Propeller 1
It seems to me that after I send my assembly language DAT code to the various cogs, it's just taking up valuable hub memory. I need 12k contiguous bytes for screen memory and I'm getting dangerously close to running out of memory. Is there some way to arrange for my assembly code to be next to some large buffer space so that I can use the buffer and the DAT space together as one contiguous memory space?

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-08-28 07:17
    Yes, if you do not need to reload the assembly, this is no problem with overwriting the DAT section

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

    Parallax, Inc.
  • mparkmpark Posts: 1,305
    edited 2007-08-28 14:29
    But how do I know where the DAT section resides in the hub? And how do I ensure it's next to a sufficiently large area of free memory? E.g. Suppose I need 12kbytes contiguous, but I only have 10k free, but I have 2k of assembly that I can overwrite. How do I arrange things so that the 10k is next to the 2k?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-08-28 16:21
    You declare it as such, IOW you put the assembly right before the declared buffer then use the assembly's label.

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

    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2007-08-28 16:29
    Maybe it is too straightforward? This is one example of many:
    DAT
      org 0
    theBuffer
    theASM
        NOP
        NOP
    theEnd
        LONG 0[noparse][[/noparse]512- (theEnd-theASM)]
    



    Note that assembly labels count COG cells , not "bytes"

    Post Edited (deSilva) : 8/28/2007 4:34:23 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-08-28 17:08
    I think you might want to put the ORG 0 after theBuffer, so the assembly begins at cog address 0. This will not affect the hub address of either theBuffer or theASM.

    -Phil
  • mparkmpark Posts: 1,305
    edited 2007-08-28 17:18
    Thanks all, esp. deSilva. Allocating the buffer in DAT space was indeed too straightforward. I was complicating things in my mind, thinking I'd have to align DAT space and unallocated space somehow. Duh.
  • mparkmpark Posts: 1,305
    edited 2007-08-30 20:17
    A further wrinkle: If I have assembly in several objects, is there a way to get all their DAT sections next to each other so I can reuse them all as one big block?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-08-30 20:20
    No

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

    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2007-08-30 20:31
    When you compile appropriate code, press F8 and look at the colorful memory map, you will see, it does not work smile.gif DAT is handeled nearly identical to PUB/PRI code, which was to be expected...
    obj
      N2 : "n2"
    PUB N1
     return 1
     return 2
     return 3
     return 4
     return 5
     return 6
     return 7
     return 8
    DAT
     NN1 long $11111111[noparse][[/noparse]10]  
    
    


    PUB N2
     return 1
     return 2
     return 3
     return 4
     return 5
     return 6
     return 7
     return 8
    DAT
     NN2 long $22222222[noparse][[/noparse]10]
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-08-11 00:56
    I've reread this thread, since it was linked to in a more recent thread. There's no reason you can't combine all your assembly code from several objects into one long DAT section, thus:

    '' Top object
    
    CON
    
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    
    OBJ
    
      myobj : "my_object"
    
    PUB  start
    
      myobj.start(@myobjasm)
      cognew(@mylocalasm, 0)
    
    DAT
    
                  org       0
    mylocalasm    mov       dira,#1
    :loop         mov       outa,#1
                  mov       outa,#0
                  jmp       #:loop
    
                  org       0
    myobjasm      mov       dira,#2
    :loop         mov       outa,#2
                  nop
                  mov       outa,#0
                  jmp       #:loop
    
    ''___________________________________________
    
    '' my_object.spin (separate file)
    
    PUB start(asmaddr)
    
      cognew(asmaddr, 0)
    
    
    


    It's not exactly what you'd call "object encapsulation" but it does force all the assembly code into one contiguous block.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • mparkmpark Posts: 1,305
    edited 2008-08-11 03:57
    Where were you when I needed this last year?!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Michael Park

    PS, BTW, and FYI:
    To search the forum, use search.parallax.com (do not use the Search button).
    Check out the Propeller Wiki: propeller.wikispaces.com/
  • RaymanRayman Posts: 14,162
    edited 2008-08-11 16:22
    For a second, I though deSilva was back [noparse]:)[/noparse] Then, I saw it was last year...
  • simonlsimonl Posts: 866
    edited 2008-08-11 21:34
    @Rayman: Me too!

    @deSilva: You're still missed wink.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

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