storing two programs at different memory location

Hello All,

I want to write some algorithm (program) in C and store it in some specifc memory area .In between my assembly code I would like to call my C routine stored at specific memory location.I wud like to know where i could store the algorithm ..I dont want this algorithm to be stored along with the memory area where my original program resides...I am giving an example below....


AREA PROGRAM,CODE, AT 0x40000000
ENTRY

//(a*b)+(c+d)
LDR r0,=numbers
ldr r1,[r0],#4 //a
ldr r2,[r0],#4 //b
ldr r3,[r0],#4 //c

function(1102);//this is the function writen in C that I want to store at some specific memory location.I would lie to know where I could store this and how I can insert a C fuction in between an assembly program?
ldr r4,[r0],#4 //d
mul r2,r1,r2 //a*b
add r3,r3,r4 //c+d
add r4,r3,r2 //(a*b)+(c+d)
str r4,[r0,#4]


AREA DATAMEM ,DATA,READWRITE

numbers :DD 0x5,0x6,0x7,0x8

End


looking for your help.

t.senthil

Parents
  • The linker controls where segments of the program live. See chapter 9 of the Assembler/Utilities manual -- in particular, the section "Segment and Memory Location Controls" (page 331 in my version).

    You'll want your C function to be in its own .c file. A .c file corresponds to a single code segment named ?CO?filename. You can then locate that segment whereever you wish.

    To put that segment in the middle of other code, you'll need to break that other code into at least two segments (two files), if it's not already. You can then use the linker directives to assign the order of segments and fixed addresses as you wish.

    If you're planning on jumping to a fixed address (rather than using public/extern and linking, or using some sort of vector table), you should probably disable the optimizations for common entry/exit code. Sharing code in the procedure entry seems like it would be likely to make the job of starting at the real beginning of the function harder.

Reply
  • The linker controls where segments of the program live. See chapter 9 of the Assembler/Utilities manual -- in particular, the section "Segment and Memory Location Controls" (page 331 in my version).

    You'll want your C function to be in its own .c file. A .c file corresponds to a single code segment named ?CO?filename. You can then locate that segment whereever you wish.

    To put that segment in the middle of other code, you'll need to break that other code into at least two segments (two files), if it's not already. You can then use the linker directives to assign the order of segments and fixed addresses as you wish.

    If you're planning on jumping to a fixed address (rather than using public/extern and linking, or using some sort of vector table), you should probably disable the optimizations for common entry/exit code. Sharing code in the procedure entry seems like it would be likely to make the job of starting at the real beginning of the function harder.

Children
More questions in this forum