PDA

View Full Version : Some optimisation?



Luis Digital
03-25-2009, 06:24 AM
Why this (a:=9) not occupies space in the memory?

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

Some optimisation?

I use BST.

Thanks.

BradC
03-25-2009, 07:37 AM
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 Digital
03-25-2009, 07:44 AM
Maybe is a problem with the presentation.
Look these screens.

Post Edited (Luis Digital) : 3/25/2009 12:01:19 AM GMT

Phil Pilgrim (PhiPi)
03-25-2009, 08:41 AM
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 Digital
03-25-2009, 09:10 AM
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

BradC
03-25-2009, 11:16 AM
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.