Calculator Community > Axe

Pointers memory location

(1/5) > >>

DJ Omnimaga:
There's something I wondered for a while but I couldn,t find where is it: Would it be possible to know what's the memory address equivalent of each pointers, like Str1, Str2, etc? I was wondering since I was afraid that for example, if I stored way too many things in Str1, that I could overflow on the next pointer below, and if each pointers doesn't have a specific memory location, I can,t seems to wrap my mind about how Axe parser decides which RAM address to allocate a pointer to

calcdude84se:
IIRC, data is just tacked on at the end and the address it is put at is the address.
What do you mean by storing to Str1 too many times? If you store something to Str1 like "Text Here"->Str1 and later in your code use "Other TEXT"->Str1, it will just fail to compile.
If you're talking about creating arrays, then if you're not careful, yeah, you can overflow by storing past the end (this is why C is so much fun).
At any rate, If you need to know the addr from inside the program, the pointer is just a number.
For example:

--- Code: ---"Demo Text"->Str1
"More Text"->Str2
Str2-Str1->X
If X<<0
-X->X
End
Disp X->Dec,i
--- End code ---
will tell how far apart the beginning of Str2 is from Str1, regardless of order of the two (Well, it should. I haven't tried)

DJ Omnimaga:
What I meant about storing to Str1 too much was for example, if I did 1->{Str1+255}, how am I sure there isn't something else within that 255 bytes range?

calcdude84se:
Oh. you don't. (again why C is so much fun)
If you want a large, arbitrary amount of RAM, use L1 to L6.
I don't think Quigibo has added a command to create arbitrary-length empty space in a program yet. (Not sure he ever will).

DJ Omnimaga:
I am confused even more now x.x

I guess I'll wait until he awnsers. I am just worried if for example I use both Str1 and Str2 that I end up accidentally overwriting stuff on Str1 while storing values early in Str2 or vice versa

Btw what does arbitrary means?

Navigation

[0] Message Index

[#] Next page

Go to full version