Tech Support > Computer Hardware > Microprocessors > AT91SAM7: C-startup
AT91SAM7: C-startup
Posted by Roman Mashak on June 25th, 2008


Hello,

"Not Really Me" sc...@validatedQWERTYsoftware.XYZZY.com wrote:

I see, it's a bit clearer now. And what about this snippet from the Atmel's
appnote "Getting started with at91sam7 controllers":
.....
reset_vector:
ldr pc, =reset_handler
undef_vector:
b undef_vector /* Undefined Instruction */
swi_vector:
b swi_vector /* Software Interrupt */
.....

They put the vectors table and IRQ handler in the seperate section named
..vectors, while "reset_handler" in .text. Is that why they load absolute
address of 'reset_handler' in to PC ?
By the way, I checked it disassembles in to "ldr pc, [pc, #NUM]", so it
would be equivalently to write "ldr pc, [pc, #reset_handler]", is that right
?

Best regards, Roman Mashak



Posted by Tauno Voipio on June 25th, 2008


Roman Mashak wrote:
No - #NUM is the distance from the instruction (or actually where pc
points at the instruction execution time) to a fullword in the .vectors
segment. The fullword contains the absolute address of the startup
routine.

To have the constant at an accessible place, you'll need a .pool
directive in the .vectors segment.

A plain branch (b target) will have a better reach than a
ldr pc,#target. See the instruction set description for details.

The assembler translates a literal addressing (=dataitem) to
either an immediate load (ldr reg,#dataitem) or to a reference
to a literal pool accessible via pc-relative addressing. The
selection is based on the data item value and whether it is
known at assembly time.

The first method is not very far from the second one. If you do not
create exceptions during the initialization, you do not need any other
vectors than the reset vector.

--

Tauno Voipio
tauno voipio (at) iki fi

Posted by Roman Mashak on June 26th, 2008


Hello,

IRQ/FIQ handlers only:
....
..section .vectors
..arm

reset_vector:
ldr pc, =reset_handler
undef_vector:
b undef_vector /* Undefined Instruction */
swi_vector:
b swi_vector /* Software Interrupt */
....
..section .text
reset_handler:
ldr pc, =lowlevel_init
....

section I declared .pool in ?

Then what's the difference?
"ldr pc, <label_name>", where label_name contains a word with address to a
handler, also results in "ldr pc, [pc, #num]". However it's not limited with
32-bit space as 'B' instruction is.


then I don't need the full-blown vector table?

Best regards, Roman Mashak




Similar Posts