hi PAL,
I have one question, when I write code with assembly language , I can write a subroutine code within a fixed location in memory, like
ORG 0A0CH
....................................
How can I do the same thing with C language ?
how to wirte code like ORG command in C
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 2993
- Joined: Fri Aug 17, 2007 9:33 pm
You can't directly. You can set the section a variable or function appears in like so:
The section can be whatever sections your linker script supports, so you could make it a custom section like ".special" and then set the specific address for that section in the linker script.
It's easier to deal with in assembly. Using fixed locations for anything except the initial header for the rom is not a good idea, and the rom header should be done in assembly. All other addresses should be left to the linker.
Code: Select all
void sd_op_delay() __attribute__ ((section (".data")));
void sd_op_delay()
{
short i,j;
for (i = 0,j = (do_init != 0) << 4;i < j;i++) { /*16 nops/bit should be enough even for the slowest card*/
asm("nop\n");
}
}
It's easier to deal with in assembly. Using fixed locations for anything except the initial header for the rom is not a good idea, and the rom header should be done in assembly. All other addresses should be left to the linker.