flat assembler
Message board for the users of flat assembler.

Index > Main > rb fasm syntax

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 17 Jun 2009, 03:22
ok i have never used rb instead of db before, does rb mean i can redefine the variable or......


sorry if this is a pitiful question, i have found it in the documentation, wanted to know if this will be useful for my development

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 17 Jun 2009, 03:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 17 Jun 2009, 03:33
rb = reserve bytes.
Code:
rb 100 ;place 100 bytes into the code    
Same as:
Code:
db 100 dup (?)    
There is no effect on the label (if you have one), just the defined data.
Post 17 Jun 2009, 03:33
View user's profile Send private message Visit poster's website Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 122
iic2 17 Jun 2009, 04:34
I keep up better by using dd and db. It a matter of appeal i guest.
Post 17 Jun 2009, 04:34
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 17 Jun 2009, 04:49
it just puts 100 spaces in the code?

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 17 Jun 2009, 04:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 17 Jun 2009, 04:53
GhostXoPCorp wrote:
it just puts 100 spaces in the code?
Do I hear and echo?
Post 17 Jun 2009, 04:53
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 17 Jun 2009, 05:14
Code:
MyData rb 100    
It is important to modeling data structure, and allowing access through a symbolic address. Rather than explicitly stating the address of each reference we can represent the desired structure and let the assembler keep track of addresses and offsets. FASM also tracks the size of definition to catch common coding errors which use the symbolic name.
Post 17 Jun 2009, 05:14
View user's profile Send private message Visit poster's website Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 17 Jun 2009, 07:50
is this a better option in making buffers?

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 17 Jun 2009, 07:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 17 Jun 2009, 08:08
Better option than what?
Post 17 Jun 2009, 08:08
View user's profile Send private message Visit poster's website Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 17 Jun 2009, 17:16
is rb a better option for making buffers for getting keys and other stuff that needs stored in buffers

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 17 Jun 2009, 17:16
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 122
iic2 17 Jun 2009, 21:04
You're talking about gathering -up your security files or needing organization, etc? I really don't think it makes no difference, they both work!... but I would never overlook any previous response which carries it own weight in gold.

I like db and dd because as well as FASM, other ASM communities also carry thousands of top-of-the-line examples that will teach you *minumun* the advanced stuff so fast it's embarrassing. This is masm32.

I don't like preliminaries, I like light/warp speed, so I go one-below where the (real) action is Smile

I like keeping things as simple as possible when it's time to translate, with-out the need of involving other lang to get a simple job done.
Post 17 Jun 2009, 21:04
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 17 Jun 2009, 22:49
GhostXoPCorp wrote:
it just puts 100 spaces in the code?
There's a difference because rb is uninitialized data, and might not waste space in your executable but only reserve once loaded in memory. On the other hand db will surely put that data in your executable.

_________________
Previously known as The_Grey_Beast
Post 17 Jun 2009, 22:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 18 Jun 2009, 00:07
Borsuc wrote:
On the other hand db will surely put that data in your executable.
That is wrong. See the second post above. db can also put uninitialised data
Code:
db ?    
Post 18 Jun 2009, 00:07
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 18 Jun 2009, 00:29
revolution wrote:
That is wrong. See the second post above. db can also put uninitialised data
Code:
db ?    
You know what I was talking about, putting values not question marks Wink

_________________
Previously known as The_Grey_Beast
Post 18 Jun 2009, 00:29
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 01 Mar 2024, 17:15
I have two different programs which reserve bytes, but strange, one of the EXE remains small while another gets bigger.

Code:
section '.data' data readable writable

    _buffer         rb      640*1024      


On what occasion the reserve bytes are expanded and occupied the EXE file?
Post 01 Mar 2024, 17:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 01 Mar 2024, 17:23
If you have initialised values after uninitialised data then it all gets included.
Code:
rb 1 shl 24 ; uninitialised
db 0        ; this is an initialised datum and must be output so all previous data in also included
rb 1 shl 24 ; uninitialised at the end so it doesn't need to be included    
Post 01 Mar 2024, 17:23
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 926
Location: Russia
macomics 01 Mar 2024, 17:24
If other declarations appear after the declared rb via db/dw/etc (other than db ?), then the entire buffer volume will have to be written to the file because initialized data will appear after it.
Post 01 Mar 2024, 17:24
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 01 Mar 2024, 17:28
Thanks for the clues, I am starting to understand:

Code:
BUFFER_SIZE = 640 * 1024

section '.data' readable writable


_buffer   rb BUFFER_SIZE
_offset   dd ?       
    


...doesn't expand the EXE.

But,

Code:
BUFFER_SIZE = 640 * 1024

section '.data' readable writable


_buffer   rb BUFFER_SIZE
_offset   dd 0    


...expands the EXE by 640KB.

So the best practice is put initialized values before uninitialized data? Next time I should do this.
Post 01 Mar 2024, 17:28
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 926
Location: Russia
macomics 01 Mar 2024, 17:32
MatQuasar wrote:
So the best practice is put initialized values before uninitialized data?
Certainly
Post 01 Mar 2024, 17:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 01 Mar 2024, 18:11
MatQuasar wrote:
So the best practice is put initialized values before uninitialized data?
Depends upon your goal.

Some OS loaders will zero-initialised the uninitialised memory sections on startup, other OSes might not. Some do zeroing anyway but don't guarantee it, so you still have to make sure that your code can work if the buffer isn't all zeros on startup.

Aside: fasm also makes any included uninitialised buffer all zeros, but I haven't seen anything in the docs that explicitly states that it will. Perhaps I missed it, and it is guaranteed, but probably best not to reply upon it.
Post 01 Mar 2024, 18:11
View user's profile Send private message Visit poster's website Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 02 Mar 2024, 15:12
revolution wrote:
Some OS loaders will zero-initialised the uninitialised memory sections on startup, other OSes might not.
If we're talking about the .bss section which by definition is uninitialized (and not referred to by the other posts) I would say that all (the major) OSes do zero the section, if not because it's expected but for security.
revolution wrote:
Some do zeroing anyway but don't guarantee it, so you still have to make sure that your code can work if the buffer isn't all zeros on startup.
Once again, it's guaranteed that if the section size is less than or crosses a page and the zeros you need are in that page you'll be alright.
revolution wrote:
Aside: fasm also makes any included uninitialised buffer all zeros, but I haven't seen anything in the docs that explicitly states that it will.
FASM calls VirtualAlloc with MEM_COMMIT on WIN32 (and probably something similar on LINUX) which provides zeroed memory (for security).

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com
Post 02 Mar 2024, 15:12
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.