flat assembler
Message board for the users of flat assembler.

Index > Main > Memory question

Author
Thread Post new topic Reply to topic
The_Unknown_Member



Joined: 28 Aug 2017
Posts: 17
The_Unknown_Member 11 Sep 2017, 20:57
Hi. This is probably a stupid question but I didn't find the answer for this so I decided to ask here. Let's look at this example:
section '.data' data readable writeable
num dd 10 dup (0) // The value in the brackets means the initial value for the declared address right ? And this value will be set in run-time right ?

Here what exactly happens ? I'm declaring an address in the memory that is able to save in itself a number up to the size of 10 Dwords ? And after this with how many bytes the next address will be bigger ?
Post 11 Sep 2017, 20:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 11 Sep 2017, 21:05
For x86 a dword (dd) is 4 bytes. So your allocated memory is 40 bytes. At program start the memory is initialised to 10 copies of 0x00000000 (40 bytes of 0x00).
Post 11 Sep 2017, 21:05
View user's profile Send private message Visit poster's website Reply with quote
The_Unknown_Member



Joined: 28 Aug 2017
Posts: 17
The_Unknown_Member 11 Sep 2017, 21:07
revolution wrote:
For x86 a dword (dd) is 4 bytes. So your allocated memory is 40 bytes. At program start the memory is initialised to 10 copies of 0x00000000 (40 bytes of 0x00).

The initialization happens in run-time or assemble-time ?
Post 11 Sep 2017, 21:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 11 Sep 2017, 21:11
The assembler sets the initial values. At runtime the loader will allocate the memory and copy the initial values from the exe file into RAM.
Post 11 Sep 2017, 21:11
View user's profile Send private message Visit poster's website Reply with quote
The_Unknown_Member



Joined: 28 Aug 2017
Posts: 17
The_Unknown_Member 11 Sep 2017, 21:50
revolution wrote:
The assembler sets the initial values. At runtime the loader will allocate the memory and copy the initial values from the exe file into RAM.

Okay so the initial values are in the exe after the assemblation but If I change the value of the address with an instruction it will be done in run-time ? Did I understand it correctly ?
Post 11 Sep 2017, 21:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 11 Sep 2017, 21:55
If the memory is marked as writeable then you can change the values at runtime as many times as needed. At startup the initial values will always be 0x00000000 as loaded from the exe file.
Post 11 Sep 2017, 21:55
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.