flat assembler
Message board for the users of flat assembler.

Index > Windows > why rb rw rd rq fail when it is the last instruction in code

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi, could i know why the rb,rw,rd,rq fail when it is on the last instruction or the only instruction in a file.

eg.

fileA.asm
======
rb 10

once assembled, you get 0 zero byte

and i tried it with, rw 10, rd 10, rq 10 and all i received 0 byte too.

i see the thread http://board.flatassembler.net/topic.php?t=1309
the author use

Code:
rb SizeOfImport - ($-ImportSection) - 1 
db 0 
    


so, this mean, people already discovered that the rb, rw, rq ... cannot function when it is on the last instruction.

my question is, why it can't function when it is on the last instruction?

sincerely,
vbVeryBeginner d(??)b
Post 16 Sep 2004, 06:52
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
That is the normal behaviour of "reserve" directives. They simply reserves the memory, but the content of this memory is not defined in any way. That means, that if this area is at the end of the binary file, there is no need to save it in the file, only the length of the section (in case of PE file) have to be set to the proper value and Windows will reserve this memory at loading.

Regards.
Post 16 Sep 2004, 08:01
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
I understand that you're a very beginner but thias really was a problem of yours?

reserve means reserve =>do not put anything there

compile this:
Code:

org 256
int 20h
rb 100
times 255 db %
times 255 rb %
mov ax,bx
times 255 rb %
                 
    


look at the code and try to understand it.
ps.: you really wanna look at the documentation

MATRIX
Post 16 Sep 2004, 08:28
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
ok, ic, thanks JohnFound Smile
Post 16 Sep 2004, 08:56
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
thank you matrix, i hope i could make you happy Smile
i appreciate it eventough not at first Wink
Post 16 Sep 2004, 11:39
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Since now I haven't come across any reserve that differs from define, but
according to the definition, you MUST not rely on them being zero. Reserve
only makes this area "usable" to you (doesn't crash with read/write errors)
but does NOT guarantee the ingredients to be 0.
Define instead hardcodes everything in your output file and you can see
zeros there.
Yes, reserve sometimes fills your output, but ONLY when there is code or
data after that in your source. Then there is no way to reserve without
increasing filesize, because then some thing wil overlap and this is bad Very Happy
Post 17 Sep 2004, 15:03
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
In addition: To avoid wrong placing of defined and reserved data in the output file, I would suggest using of Fresh library "globals.inc". It handles your global data definitions in proper way placing reserved variables always at the end of the section, thus minimizing the size of the file. Also, it increases readability of the source.

Regards.
Post 17 Sep 2004, 17:01
View user's profile Send private message Visit poster's website ICQ Number 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. Also on YouTube, Twitter.

Website powered by rwasa.