Shop OBEX P1 Docs P2 Docs Learn Events
SPIN Code Generator with Text String Optimisation — Parallax Forums

SPIN Code Generator with Text String Optimisation

he1957he1957 Posts: 58
edited 2009-08-15 17:28 in Propeller 1
Not sure of some semantics so please allow some leeway here.

I've been examining (in particular) the FemtoBasic source code and wonder why the use of "in-line" ASCII text is used in most "error" message emissions.· WRT the SPIN manual it implies the·reference·to "frequently"·accessed "text" is best coded using access to DAT 'objects' (defined as·ZeroTerminated 'byte array(s)' [noparse][[/noparse]symbols]).

I guess the real question(s) is/are would it be more efficient (size wise) to:

1. Use symbol references in messages/abort code method/function calls (to TEXT in a DAT block)
2.·Use same in generic [noparse][[/noparse]static] message emissions

In familiar language usage I've noted compilers "collect" strings and place them into "common" storage where applicable so I'm wondering if SPIN does similar.

I'm just trying to get the most "free" space available for user code rather than 'overheads'.


Thanks in advance,

HarryE.




·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-15 17:28
    The Spin compiler does no optimization on literal strings. Each "string()" occupies its own storage. For strings where there are duplicates, you're better off putting them in a DAT section and using @stringLabel. If the string is unique, there's no advantage either way.

    FemtoBasic was not written for optimal memory use. Most error text is unique so it's clearer to use "string()". Note that the message "Syntax Error", which is used many times, is in a DAT section. There are probably a few other strings that are used often where manually collecting them would be useful, but I don't think you'd save much overall.
  • jazzedjazzed Posts: 11,803
    edited 2009-08-15 17:28
    You can use a third-party compiler like BSTC or Homespun to generate Spin listings for optimizations.
    I believe using 'string("Hello World")' multiple times in a Spin program generates as multiple entries.

    Forum search is effective with one word searches.

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


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
Sign In or Register to comment.