flat assembler
Message board for the users of flat assembler.

Index > Main > reserve, times and dup!

Author
Thread Post new topic Reply to topic
Kenny80



Joined: 08 May 2005
Posts: 22
Kenny80 05 Oct 2005, 11:03
how does reserve, times and dup work with non constant values?

if i use any of the above i can't change value in them but if u use for example db instead then i can change value!

i read info about them but wasn't much told on what's diffrense on them!

i tried diffrent methods of those above with "RegQueryValueEx" and if i have

LPDWORD lpcbData // address of data buffer size as rb or dup or times it won't work, but if i change to db, dd, dw....so on it works!

does reserve, times and dup lock the memory space it uses? does it only work with non changing values where program only reads the values and don't try change them!?
Post 05 Oct 2005, 11:03
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 05 Oct 2005, 12:03
ke?!? anyway:

"name db value" creates one byte with value <value> in output file. <name> is address of that byte (when program is loaded in memory).

"name rb value" reserves <value> bytes with undefined contents, address of first one is stored in <name>.
Post 05 Oct 2005, 12:03
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Kenny80



Joined: 08 May 2005
Posts: 22
Kenny80 05 Oct 2005, 19:45
my question is simple, what is reserve, times and dup and how do they work?

rb for me sounds like "db ?"!

i'm used to masm "dup" but it seems like masm dup is same as "times" in fasm or?
Post 05 Oct 2005, 19:45
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 05 Oct 2005, 21:18
oh. i already explained "db" and "rb" enough i hope.

db is same as in masm i think
"rb <count>" is like masm "db <count> dup(?)" - it reserves <count> bytes (but is nicer)

times count <anything> just repeats <anything> <count> times, for example
"times 5 db 0" is like
db 0
db 0
db 0
db 0
db 0
plus you can use "%" symbol which is (innermost) repeating count:
"times 5 db %" is like
db 1
db 2
db 3
db 4
db 5

also "dup" works just like in MASM, you can use it too
db 5 dup ('a',0)

hope it helped Wink
Post 05 Oct 2005, 21:18
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Kenny80



Joined: 08 May 2005
Posts: 22
Kenny80 06 Oct 2005, 09:17
o, ya alot better hehe than info in manual about fasm!

what i meant above before was when i use this code below

invoke RegQueryValueEx, [hKey], PI, 0, ValueType, [PI_DATA], PI_Data_Size

in this particular question we focus on "PI_Data_Size", if i declare "PI_Data_Size" with a "rb" or "times" then it won't work, i get error back from "RegQueryValueEx" in eax (for all u who don't know if all went fine then it will return 0 in eax) and that is "EA" but if u change it to "db" then it works, so i still confused why "rb or times" don't work with that function!? hope my questions is bit easier to read now!
Post 06 Oct 2005, 09:17
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Oct 2005, 09:29
The lpcbData parameter for the RegQueryValueEx needs to be a pointer to value containing the size of your buffer (which the function replaces with the size of data actually copied into that buffer). This means you either need to have this value initialized - you can initialize it at compilation time by using definition like "PI_Data_Size dd 100" (where 100 is the example size of your buffer); or you can define it as unitilialized, with "PI_Data_Size dd ?" or "PI_Data_Size rd 1", but then you have to initialize it at run time, before calling the RegQueryValueEx, for example with "mov [PI_Data_Size],100". The second method is actually better, because if you want to call RegQueryValueEx many times, you will have to re-initialize this variable each time any way, since RegQueryValueEx replaces the value in that variable with the data size.
Post 06 Oct 2005, 09:29
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:  


< 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.