Take for exampleDoes R1 point to the the program counter plus the location of Sample OR the value of Sample?Code:LDR R1, =Sample
This is a discussion on PC relative addressing mode within the Tech Board forums, part of the Community Boards category; Take for example Code: LDR R1, =Sample Does R1 point to the the program counter plus the location of Sample ...
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?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
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".
Last edited by smokeyangel; 10-21-2011 at 05:08 PM.