Pages: [1]   Go Down
Author Topic: Setting up a block of space  (Read 496 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible to setup a block of RAM using constants?

<I am going to use compiler commands which make what I want to do obvious but they are just made up and/or mixed with old assembler commands in order to demonstrate what I want.>


In assembler I could do something like:

Code:
loc_hello: #defstring "Hello",0
loc_Goodbye: #defstring "Goodbye",0
loc_Error: #defstring "Error",0

so that referring to "loc_Goodbye" would give the address of the "G" in "Goodbye" etc

I could even replace the "Hello" with a constant from a table so....

Code:
loc_hello: #defstring $const_hello$

Also each of the definitions is relative to the previous one...  Is it possible to make one relative to another but offset by a fixed amount so:

Code:
loc_hello: #defstring "Hello",0
loc_Goodbye: #defstring "Goodbye",0
a1: #defspace (30-a1-loc_hello)
loc_Error: #defstring "Error",0

So that loc_Error is 30 bytes after loc_hello ??


Also is it possible to compile code to the EEPROM ???

So that I could have say the text for the sketch compiled straight to the EEPROM rather than programming space?
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 219
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

not exactly sure what you want, why program in assembler ?
its possible dough but its often slow or developing software, update or remove bugs.
Never the less it is possible.

You might perhaps use a fixed array of char  (bytes).

Then read a little bit about pointers in C++ ( http://www.cplusplus.com/doc/tutorial/pointers/ )
A pointer will get you the offset of where the array is stored
Pointers can point to objects, functions, variables,...
Basically they point to the memory location

next you might take a dive into this   http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1207370768/2

I think before you start assembler, first try c++
It might sound cool to be able to do it (i one could write assembler for the MSX), but its not an easy road
It might require lots of time to learn, and you be able to create small things with it, the same investment in other programming languages leads programmes who can do more (but 'might' not be as fast as assembler, on the other hand these program languages do a good job of translating code to assembler too, so you can focus better on higher goals and achieve more with less code to invent yourself.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 303
Posts: 26354
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is it possible to setup a block of RAM using constants?
Like this?
Code:
char* explanation [] = "This string exists in PROGMEM but gets copied to RAM before \"main\" runs";
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8535
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
char loc_hello = "Hello";
char loc_Goodbye = "Goodbye";
char loc_Error = "Error";

Then use loc_Hello etc to reference the strings.

If you really need the string to be 30 apart then maybe

Code:
char myArray [3][30] = {
   "Hello",  "Goodbye", "Error"
}

or

Code:
char myArray [100];

strcpy (myArray, "Hello");
strcpy (myArray + 30, "Goodbye");
strcpy (myArray + 60, "Error");

or

Code:
char myArray [] = {"Hello                    Goodbye                Error"}
This is all very wasteful of space though, there is usually a better way. What are you trying to do?

Quote
Also is it possible to compile code to the EEPROM ???
No, you may have to write it yourself at run time, although IIRC there are AVRdude/linker options to put stuff in EEPROM.

______
Rob



Logged

Rob Gray aka the GRAYnomad www.robgray.com

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You seem to be trying to control the layout of your data. The way to do that is to define your variables and types correctly so that the correct space is allocated for them, rather than trying to tell the linker how to do its job.

So that I could have say the text for the sketch compiled straight to the EEPROM rather than programming space?

Wait, what???
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: