Shop OBEX P1 Docs P2 Docs Learn Events
How to align a table to a specific address? — Parallax Forums

How to align a table to a specific address?

ManAtWorkManAtWork Posts: 2,178
edited 2009-12-02 01:51 in Propeller 1
Hello,

I'd like to replace the standard sine table with my own version. (The reason is my hardware causes distortions, so I have to add precompensation). Of course, I could simply write my table into a DAT section. But the standard sine/cosine routines (Prop manual appendix B) are highly optimized and rely on the fact that the table starts at an adress with the least significant bits equal to zero.

How can I align my table to a specific address in hub RAM? Is there a way to include/import a hex data file?

Thanks for any help
·

Comments

  • BradCBradC Posts: 2,601
    edited 2009-12-01 15:13
    ManAtWork said...


    How can I align my table to a specific address in hub RAM? Is there a way to include/import a hex data file?

    Ok, this example is only valid for the top object. This will import the binary file called "fred" and locate it at $2000 in the hub

    
    DAT
    
    here
      byte 0[noparse][[/noparse]$2000-@here-$10]
    freds_symbol_name
      file  "fred"
    
    
    



    Basically we take the address of "here" and pad it out until it is $2000 into the object. Given the object is the top object it's $10 into the hub.

    This takes any file of bytes and inserts it where you want it.

    List file output to verify what went where.

    Object Fred
    Object Base is 0010
    |===========================================================================|
    Object Constants
    |===========================================================================|
    |===========================================================================|
    Object DAT Blocks
    |===========================================================================|
    0018(0000)             | here
    0018(0000) 00          | byte    0[noparse][[/noparse]$2000-@here-$10]
    2000(07FA)             | fred
    2000(07FA)             |         file "fred"
    |===========================================================================|
    |===========================================================================|
    Spin Block Start with 0 Parameters and 0 Extra Stack Longs. Method 1
    PUB Start
    
    Local Parameter DBASE:0000 - Result
    |===========================================================================|
    Addr : 2005:             32  : Return         
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you always do what you always did, you always get what you always got.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-01 15:17
    You can't align your table to a specific address in hub RAM. You can force alignment to a LONG or WORD boundary by using those statements on a line by themselves as in
    LONG
    label   BYTE   $00, $01, $02
    


    You can't include or import a hex data file, but you can include a binary file by using the FILE statement. This copies the binary content of a file so that it appears in your program in the place of the FILE statement. Normally you'd use cut and paste to place a hex source table into a program's DAT section.
  • ManAtWorkManAtWork Posts: 2,178
    edited 2009-12-01 21:43
    Hello Brad and Mike,

    thanks, that's exactly what I'm looking for. I think I can combine the two:
    DAT
    
    here
      byte 0[noparse][[/noparse]$2000-@here-$10]
    word 'copy/paste hex data here
    
    

    because it's much easier to copy/paste directly into the source instead of generating a binary file out of Excel...
    BTW, stupid question, where can I find the list file output? confused.gif

    Cheers
  • VIRANDVIRAND Posts: 656
    edited 2009-12-01 22:13
    I wonder why there is almost no provision for specifying the address of something.
    I've noticed that stack space and the GRAPHICS object buffers can be absolutely addressed,
    and stuff can be moved and stored and used in known BYTE[noparse][[/noparse] ] addresses, especially within the
    offscreen buffer if it is not used for video.

    I suppose that everything could be rearranged but would be hard to keep track of; and if there is
    any advantage to putting the table at a nice address like hex $2000, using BYTEMOVE,
    its former Hub RAM location becomes free and available relative to its label.
  • BradCBradC Posts: 2,601
    edited 2009-12-01 23:59
    ManAtWork said...

    BTW, stupid question, where can I find the list file output? confused.gif

    Oh, sorry. I don't use the Propeller Tool or Windows. It can't give you a list output.

    If you are on Windows and have .NET installed, grab mparks homespun compiler.
    propeller.wikispaces.com/Homespun+Spin+Compiler

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you always do what you always did, you always get what you always got.
  • mparkmpark Posts: 1,305
    edited 2009-12-02 00:15
    Brad's Spin Tool also produces a listing file. http://forums.parallax.com/showthread.php?p=755835
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-12-02 01:51
    There is no listing with the PropTool. However, as said above, Brad's bst and mpark's homespun both produce good listings. Each have their own advantages.

    homespun requires a compiler switch so, presuming Windoze, open a dos window and type c>homespun /? for a list of options (or is it -?)

    bst has an option in the titlebar for listing which opens a window, then compile, then open the window again and the listing is there.

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

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
    · Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
Sign In or Register to comment.