This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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
  • In that case, why is the exact address of the function important? Just declare the function's existence to the assembler with EXTERN and let the linker resolve the address.

    Programmers usually run into a need to specify the address when their program is delivered or upgradable in separate pieces. For example, there might be a library of flash routines in ROM, and an upgradeable application in rewritable flash. The app code has to be able to call the flash library; one way to do that is to specify the exact entry points of the library calls.

    But the situation you describe sounds like the normal use of a function -- to gather up repeated code into a resuable subroutine. Usually it's not important where each function actually lives. People invented linkers to avoid having to do that work by hand.

Reply
  • In that case, why is the exact address of the function important? Just declare the function's existence to the assembler with EXTERN and let the linker resolve the address.

    Programmers usually run into a need to specify the address when their program is delivered or upgradable in separate pieces. For example, there might be a library of flash routines in ROM, and an upgradeable application in rewritable flash. The app code has to be able to call the flash library; one way to do that is to specify the exact entry points of the library calls.

    But the situation you describe sounds like the normal use of a function -- to gather up repeated code into a resuable subroutine. Usually it's not important where each function actually lives. People invented linkers to avoid having to do that work by hand.

Children
No data