Shop OBEX P1 Docs P2 Docs Learn Events
Some optimisation? — Parallax Forums

Some optimisation?

Luis DigitalLuis Digital Posts: 371
edited 2009-03-25 03:16 in Propeller 1
Why this (a:=9) not occupies space in the memory?

PUB Main| a
a:=9
a:= a+1

Some optimisation?

I use BST.

Thanks.

Comments

  • BradCBradC Posts: 2,601
    edited 2009-03-24 23:37
    I'm not sure I understand. Here is the list file output from bstc using your test code. The a:=9 is there.

    |===========================================================================|
    Spin Block Main with 0 Parameters and 1 Extra Stack Longs. Method 1
    PUB Main| a
    
    Local Parameter DBASE:0000 - Result
    Local Variable  DBASE:0004 - a
    |===========================================================================|
    1                      a:= 9
    Addr : 0018:          38 09  : Constant 1 Bytes - 09 
    Addr : 001A:             65  : Variable Operation Local Offset - 1 Write
    2                      a:= a+1
    Addr : 001B:             64  : Variable Operation Local Offset - 1 Read
    Addr : 001C:             36  : Constant 2 $00000001
    Addr : 001D:             EC  : Math Op +     
    Addr : 001E:             65  : Variable Operation Local Offset - 1 Write
    Addr : 001F:             32  : Return        
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • Luis DigitalLuis Digital Posts: 371
    edited 2009-03-24 23:44
    Maybe is a problem with the presentation.
    Look these screens.

    Post Edited (Luis Digital) : 3/25/2009 12:01:19 AM GMT
    480 x 344 - 18K
    525 x 357 - 26K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-25 00:41
    I think I see what Luis means: The program, with the a := 9 occupies eight bytes, per Brad's dump above. That's two longs. Without the assignment, the program occupies five bytes. But that's still two longs, since you have to count whole longs.

    -Phil
  • Luis DigitalLuis Digital Posts: 371
    edited 2009-03-25 01:10
    Phil Pilgrim (PhiPi) said...
    I think I see what Luis means: The program, with the a := 9 occupies eight bytes, per Brad's dump above. That's two longs. Without the assignment, the program occupies five bytes. But that's still two longs, since you have to count whole longs.

    -Phil

    That makes sense.
    With second example (screens) should be something seemed.

    Many thanks boys!

    Post Edited (Luis Digital) : 3/25/2009 9:32:29 PM GMT
  • BradCBradC Posts: 2,601
    edited 2009-03-25 03:16
    Yes indeed. Phil is absolutely right, as the variables and stack are located after any object code, and they both must be long aligned there is padding inserted to bring the code length up to a long boundary if required.

    I'll have a look at the dialog box cutting bits off. I've not played with the alignment of components much outside of my laptop and development box. They both have the same DPI setting and at least 1024x768 resolution. I'll see if I can reproduce that mis-alignment and get it fixed

    Thanks for the screenshot. They help a lot.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
Sign In or Register to comment.