Hello everyone. I have two questions about linker. Actually I'm not sure, it's about linker, but I guess it's about it.
Target - Cortex M4F IDE - Keil uVision 5.15 Language - assembler Toolchain - Keil
So, I have a very small project written in assembler. I need assembler for students to study microcontrollers programming. It contains three files: "startup.s", "my_prog.s" (smth like "main.c") and "CPU_12.lib" (this one contains two mulitplication functions).
First question: In main program, one function from the "*.lib"-file is called. But during debug session it can be seen, that both functions were placed in memory. How can I avoid this? If i have a lib with 1000 function, and only use 1 of them - all lib will be linked to my project? I've tried to use "--feedback" for linker and compiler, but it didn't help.
Second question intro: if i have my program in flash memory and variables in RAM, i have to initialize them with values (smth like "int x = 1;" in C). In C-like projects it's done automatically - necessary functions are linked before "main()" inside a generated "__main()"-function. I've tried to find the way linker does initialization, but i couldn't. Usually algorithm is like this: from address A in flash, copy DATA_SIZE bytes to address B in RAM. So we need at least three variables, generated by linker - A, B and DATA_SIZE. Looks like they are in some auto-generated structure Region$$Table$$Base - first three words. I found this struct in map-file and examined it, though i couldn't find any info on this struct in the internet. So the question is - how can I do this initialization in assembler project? Looks like i have to reserve space in RAM with "SPACE" directive, and declare values with "DCD" directive. But how can I know where to copy this values during runtime? Where can i get analogues for "A", "B" and "DATA_SIZE" values?
I will appreciate any help in this question. Here's the project. It was created in uVision 5.15. Sorry for comments in Russian. www.yadi.sk/.../3RDF-OtY3CgoqD
Thanks everyone.
Ok, I've figured out, that a library is divided into "modules" and each source-file in Library Project represents a module. So these modules may be included in the project, if they are needed, and removed, when they are not needed. But what about the second question?
I need assembler for students to study microcontrollers programming.
Seriously, if you're going to be teaching this stuff, you really should be able to figure that out by yourself.
Well if you want Keil code to fix it up, then call __main and create a "main" entry point to your own code.
Alternatively do it manually, with LDR/STR instructions, it will reinforce the realization that RAM isn't actually initialized when the CPU starts.
I would prefer the visibility of an all-assembler solution, i.e. real bare-bone programming.
Use own labels or let the linker help.