Take for exampleDoes R1 point to the the program counter plus the location of Sample OR the value of Sample?Code:LDR R1, =Sample
Printable View
Take for exampleDoes R1 point to the the program counter plus the location of Sample OR the value of Sample?Code:LDR R1, =Sample
Are we supposed to guess which processor/assembler you're using, or are we to guess you're using ARM like last time?
ARM. I thought it would be the same in all assembly languages?
In this case I think it also depends on the particular assembler. LDR Rd, =... is a pseudo instruction in at least the ARM and GNU assembler. The behaviour depends on what "Sample" is.
If "Sample" is an expression, e.g. a constant, then the value of Sample will be loaded. Sample might not even have an address if it is small enough.
If Sample is a symbol, e.g. a label, the assembler will load the address of Sample.Code:.equ SmallSample,5
.equ BigSample,0xdeadbeef
LDR r1, =SmallSample
# ---> this will assemble to "MOV r1, 5".
LDR r1,=BigSample
# ---> the assembler will generate a literal pool containing 0xdeadbeef and load from it using LDR r1, [pc,#offset]
Likewise if "Sample" is a function name, it'll load the address of the symbolCode:Sample .word 0xf00df00d
LDR r0, =Sample
#--> In this case the assembler will probably generate a literal pool containing the address of "Sample".