Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Array storage in Memory

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Thu Mar 19, 2009 2:34 pm    Post subject: Array storage in Memory Reply with quote

When you make an Integer value, lets for instance take 133337, it will be stored in the memory as the following:
Code:
D9 08 02 00

because 133337dec = 000208D9hex, and backwards

But what if i took an array of ints, lets say
Code:
int var[2] = {133337, 1333337, 13333337};

How would it be stored then?, like this?:
Code:

var[0]           var[1]           var[2]
D9 08 02 00 59 58 14 00 59 73 CB 00


Or how would it be stored?
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Thu Mar 19, 2009 2:36 pm    Post subject: Reply with quote

Yeah.

The way the compiler accesses the location of an index of an array is with this simple algorithm:

Code:

Location = ArrayBase + Index * sizeof( DataType )

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Thu Mar 19, 2009 3:14 pm    Post subject: Reply with quote

samuri25404 wrote:
Yeah.

The way the compiler accesses the location of an index of an array is with this simple algorithm:

Code:

Location = ArrayBase + Index * sizeof( DataType )


So, if var was located at 00400000 accessing var[2], where var is an array of integers, it would be at 0040000C?
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Thu Mar 19, 2009 3:20 pm    Post subject: Reply with quote

Anden100 wrote:
samuri25404 wrote:
Yeah.

The way the compiler accesses the location of an index of an array is with this simple algorithm:

Code:

Location = ArrayBase + Index * sizeof( DataType )


So, if var was located at 00400000 accessing var[2], where var is an array of integers, it would be at 0040000C?


No, it would be 00400008.

1st integer = 00400000 = var[0]
2nd integer = 00400004 = var[1]
3rd integer = 00400008 = var[2]
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Thu Mar 19, 2009 3:31 pm    Post subject: Reply with quote

smartz993 wrote:
Anden100 wrote:
samuri25404 wrote:
Yeah.

The way the compiler accesses the location of an index of an array is with this simple algorithm:

Code:

Location = ArrayBase + Index * sizeof( DataType )


So, if var was located at 00400000 accessing var[2], where var is an array of integers, it would be at 0040000C?


No, it would be 00400008.

1st integer = 00400000 = var[0]
2nd integer = 00400004 = var[1]
3rd integer = 00400008 = var[2]


What if the variables were WORD or BYTE ;O
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Thu Mar 19, 2009 3:38 pm    Post subject: Reply with quote

S3NS4 wrote:
smartz993 wrote:
Anden100 wrote:
samuri25404 wrote:
Yeah.

The way the compiler accesses the location of an index of an array is with this simple algorithm:

Code:

Location = ArrayBase + Index * sizeof( DataType )


So, if var was located at 00400000 accessing var[2], where var is an array of integers, it would be at 0040000C?


No, it would be 00400008.

1st integer = 00400000 = var[0]
2nd integer = 00400004 = var[1]
3rd integer = 00400008 = var[2]


What if the variables were WORD or BYTE ;O


WORD = 2 bytes
BYTE = 1 byte

so add respectively
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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

CE Wiki   IRC (#CEF)   Twitter
Third party websites