flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > .data?

Author
Thread Post new topic Reply to topic
Postal



Joined: 28 May 2006
Posts: 12
Location: Russia
Postal
How to make in fasm section ".data?" ??

In MASM (for example):
.data?
buffer db 100000 dup (?)

Then size of .exe file is SMALL !!!!

In fasm:
.data
buffer db 100000 dup (?)

Then size of .exe file is big... Sad
Post 01 Jun 2006, 10:48
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
This just 1536 bytes:
Code:
include 'win32axp.inc'

.data
  ; PUT HERE INITIALIZED DATA IF YOU WANT
  buffer db 100000 dup (?)
  ; DON'T PUT ANY INITIALIZED DATA HERE BECAUSE IT WILL FORCE INITIALIZATION TO ZER0 OF THE UNINITIALIZED DATA ABOVE
.code
start:
  ret

.end start      


Check the comment to see how to avoid big files

Regards
Post 01 Jun 2006, 13:55
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Postal,

Without using "macros"

Code:
section '.bss'          readable        writeable

;put uninitialized data here

section '.data'         data            readable        writeable

;put initialized data here

section '.code'         code            readable        executable

;put code here    


You can also use macros contained in the Fresh projects GlobalMem.inc file which allow you to specify multiple initialized and uninitialized data sections in a single or multiple files. The macros combine the multiple sections into one each initialized and uninitialized section for assembly. Use as follows:
Code:
include '\Program Files\fasm\include\GlobalMem.inc'

iglobal
_ClassName      db      'QBBU', 0
_AppName        db      'QBBU', 0
_MenuName       db      'MainMenu', 0
endg

uglobal
gIst    dd      ?
gWnd    dd      ?
endg

...

section '.data'         data            readable        writeable
        IncludeAllGlobals 
    



The attached file show the use of GlobalMem.inc, uncomment the line in the iglobal section to see the difference in file size.

hth,

farrier


Description:
Download
Filename: GMExample.asm
Filesize: 1.61 KB
Downloaded: 160 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 01 Jun 2006, 14:27
View user's profile Send private message Reply with quote
Postal



Joined: 28 May 2006
Posts: 12
Location: Russia
Postal
Thanks!

Clearly! Very Happy
Post 01 Jun 2006, 14:47
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
farrier, using a section named '.bss' doesn't prevent defining initialized data, it's enough to put uninitialized data at the end of any section, the waste of space is when you interleave initialized data and uninitialized data.

this:
Code:
.data
db 0
buffer db 100000 dup (?) 
    

will define a data section of very few bytes but this one:
Code:
.data
buffer db 100000 dup (?) 
db 0    
will define a data section really bigger.

I think that using only one section is better since it saves the memory (and disk space) required to hold an extra section. However if you want your initialized data read-only then you need to define that section readable and the section for uninitialized data readable writable.

Regards

PS: Of course both codes takes the same amount of RAM memory, the difference is on the disk space requiered.
Post 01 Jun 2006, 14:53
View user's profile Send private message Reply with quote
WiESi



Joined: 15 May 2006
Posts: 14
Location: Austria
WiESi
What about using rb? For instance:
Code:
buffer rb 100000    
Post 01 Jun 2006, 16:54
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
That's works too in the same manner that dup does. If you don't want that reserved bytes to be written to disk then you must be sure that there is no more initialized data below that declaration.
Post 01 Jun 2006, 17:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.