Re: C question 2
- From: Anchor <anchorelectronics@xxxxxxxxxxxx>
- Date: Wed, 27 Jul 2005 10:10:39 -0400
On Wed, 27 Jul 2005 15:50:39 +0200, Xarion wrote:
> why would i want to place a code segment at a specific location in memory
> rather than let the linker decide where to put it?
>
> - Xarion
Two examples come to mind.
When you power up the computer it jumps to the special start location
expecting to find the start of your program.
When an interrupt occurs, again the computer jumps to a special location
expecting to find an interrupt service routine that will handle the
interrupt.
For example on most 16F Microchip PIC processors, the program starts at
address 0x0 and the interrupt handler starts at address 0x4. So most PIC
programs in assembler look something like:
ORG 0x0
goto Start
ORG 0x4
goto ISR
Start:
...
ISR:
...
retfie ; return from interrupt instruction
A C compiler must arrange for the C code to mimic the assembler layout for
the code to function as expected.
Some linkers can force load a subroutine at a specified location. Usually
this information is passed from the compiler or read from a linker
configuration file that you create for the application you are developing.
.
- References:
- C question 2
- From: Xarion
- C question 2
- Prev by Date: Tiny ARM Development
- Next by Date: Re: Jump addresses messed up with GNU as
- Previous by thread: C question 2
- Next by thread: Re: C question 2
- Index(es):
Relevant Pages
|