flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > Memory question

Author
Thread Post new topic Reply to topic
The_Unknown_Member



Joined: 28 Aug 2017
Posts: 17
Memory question
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: 15241
Location: 1I/╩╗Oumuamua
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

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: 15241
Location: 1I/╩╗Oumuamua
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

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: 15241
Location: 1I/╩╗Oumuamua
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.