0

I want to create an array in memory like I would in C with

int i[] = {0,2,3,124,324,23,3,2}

How to do this in ARM assembly? Apparently I could declare some values like this:

AREA     mydata, DATA
array    DCD 0,2,3,124,324,23,3,2

But how to copy them to RAM in the most easiest way?

artless noise
  • 21,212
  • 6
  • 68
  • 105
JohnnyFromBF
  • 9,873
  • 10
  • 45
  • 59

1 Answers1

1

When you assemble/link a file with the lines you have given, the values will already be stored in RAM. There will be a symbol called 'array' which represents a pointer to the data.

If you wish to access the symbol from another file, you will also need to add an EXPORT directive to the file which contains the definition, eg

EXPORT array

and add an IMPORT directive to the file where you wish to use the symbol, eg

IMPORT array

You can also check the assembler syntax by looking at the assembly language output from the compiler which compiling a trivial source file containing your declaration of i.

Charles Baylis
  • 851
  • 7
  • 8
  • At which memory location should array be stored at? I expected it to be at 0x20000000 but it's not. – JohnnyFromBF Apr 06 '15 at 10:27
  • The linker will place the symbol according to its own algorithms. You can get a pointer to array with something like `LDR r0,=array` which will load the address of array into r0 – Charles Baylis Apr 06 '15 at 11:01