#9076 - slip - Mon Jul 28, 2003 12:41 am
Using the GNU assembler I have the following line of code.
ldr r2,=0x1010101
When compiling though I get an error
"Literal referenced across section boundary (Implicit dump?)"
anyone care to explain? =\
_________________
[url="http://www.ice-d.com"]www.ice-d.com[/url]
#9079 - tepples - Mon Jul 28, 2003 3:15 am
Did you forget your .pool after each function?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#9086 - slip - Mon Jul 28, 2003 10:30 am
.pool?
I'm this code is ment to be inline but the thing is, ldr r2,=0x1 works just a greater number doesn't =\
_________________
[url="http://www.ice-d.com"]www.ice-d.com[/url]
#9091 - tom - Mon Jul 28, 2003 12:34 pm
the arm cpu's opcodes are 32 bits (respectively 16 in thumb mode) wide. that's not enough to have big immediate values in the opcodes.
the syntax
generates a pc relative ldr instruction, that is, the assembler puts the constant 0x01010101 somewhere in memory, and generates a pc relative ldr opcode which loads this constant (called a literal) into r2.
now, how does gas know where it can put your literals ? you have to tell it, by adding a .pool directive, like this:
Code: |
sillyfunction:
ldr r2,=0x01010101
bx lr
.pool
|
the reason why it works with small numbers, like 0x01 is that gas is a smart assembler =)
when it sees that a constant is small enough to be loaded with a mov instruction, it will do so and thus it won't need a literal pool.
#9131 - slip - Tue Jul 29, 2003 12:23 am
ahh right I understand now =) thanks
_________________
[url="http://www.ice-d.com"]www.ice-d.com[/url]