We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
when i add startup.a51 ,init.a51 and C51S.LIB to my project.the link result as below:
INPUT MODULES INCLUDED: test.obj (TEST) aa.obj (AA) .\STARTUP.obj (?C_STARTUP) .\INIT_TNY.obj (?C_INIT) C:\Keil\C51\LIB\C51S.LIB (?C?COPY)
?c_init segment is not the last segment in the link process, is that right?
when i delet startup.a51 and init.a51 from project ,then rebuild it ,the segment of ?c_init is linked at the last step showed below;
INPUT MODULES INCLUDED: test.obj (TEST) aa.obj (AA) C:\Keil\C51\LIB\C51S.LIB (?C_STARTUP) C:\Keil\C51\LIB\C51S.LIB (?C?COPY) C:\Keil\C51\LIB\C51S.LIB (?C_INIT)
i think the send link is right, how about the first link step, is it right?
thanks you!
What made you believe you hat to add the default runtime library to your project, instead of just letting tools find it by themselves?
when i use some inline assembly in my C projiect, so i have to set the "src "option. then the complier gives me a error massege: "?c?copy reffer error", so i have to add the runtime lib in my project manully.
Today I try this again: 1. the files in my project column:
startup.a51 TEST.C(with "src" option check) AA.C C51S.LIB.
2.The link proceture :
C:\KEIL\C51\BIN\BL51.EXE .\STARTUP.obj, test.obj, aa.obj, C:\Keil\C51\LIB\C51S.LIB TO Test INPUT MODULES INCLUDED: .\STARTUP.obj (?C_STARTUP) test.obj (TEST) aa.obj (AA) C:\Keil\C51\LIB\C51S.LIB (?C_INIT) C:\Keil\C51\LIB\C51S.LIB (?C?COPY)
Then i build the project, no error,no warning.But the link proceture that the ?c_init isn't the last segment linked by BL51 maks me worry: if some globle variables with initiation in the C51s.lib and the ?c_init isn't linked at the last step. then the gloable variables in C51S.LIB will never be initiated because of the last space "DB 0" in ?C_INITSEG segment.
when i use some inline assembly in my C projiect, so i have to set the "src "option.
You're being really vague there, but let me guess: you turned on the SRC option for every single C file in your project, didn't you? Maybe even turned it on globally, for the entire project?
Well, don't do that. If you can't keep any single source file in your program free of inline assembly, you probably shouldn't be writing the program in C in the first place. Or maybe you need to understand that inline assembly is generally not as good an idea as many pundit make it out to be.
then the complier gives me a error massege: "?c?copy reffer error",
That's beyond reasonable doubt not the error message you actually got.
so i have to add the runtime lib in my project manully.
No, you don't. What you actually have to do is fix what broke the compiler's automatic inclusion of the runtime library in the first place.
get rid of inline assembly.
DO show an example of where you use it and tell why you need it.
If you have something that MUST be in assembly make a separate .a51 mosule and call it from your C
Erik
I don't think there are many (any?) of the pundits on this forum who would ever advocate inline assembly as a good idea at all - especially not inline assembly as implemented by Keil C51!
I, for one, am certainly of the opinion that virtually all attempts at inline assembly seen on this forum (and others) are fundamentally flawed.
As already suggested, if you really need assembler in your project, then do it properly in separate assembled modules.
For an example of how to do this, see: www.8052.com/.../149030
I don't think there are many (any?) of the pundits on this forum who would ever advocate inline assembly as a good idea at all
You're right about this here forum. But obviously those evangelists of inline assembly must exist somewhere out there. How else to explain that so many Keil newbies come here firmly believing inline assembly is the be-all and end-all of efficient programming in C?
But obviously those evangelists of inline assembly must exist somewhere out there. How else to explain that so many Keil newbies come here firmly believing inline assembly is the be-all and end-all of efficient programming in C?
I have, on occasion seen C51 horrible code based on the philosophy that "C is C". If you do not know the difference between a PC and a '51 that is what you get.
An example would be that some complain about efficiency while using the large model (I can not be bothered by memory spaces, by the way, what is that?). Another would be looking at 'blinky' and asking "where is the OS?".
Fortunately, the want ads for "a programmer" for a micro without requiring micro experience are slowly waning. However it is still often seen as 'desired' rather than 'required'
You may be right.
:-(
But, to me, it seems more likely that the vast majority of inline assembly usage is pure naivety of novice programmers who see that the faclity is present and, therefore, assume that it must be good to use...
.... that they are used to assembler and so 'novice' in C, that if they do not know the appropiate C construct then "just do it in assembler'.
Yes, there is certainly a lot of that!
I was thinking of that as an example of "naivety of novice [C51] programmers"
Thanks your advice and dicuss about that.
The solution to link the ?C_initseg at the last setp is very easy.
I just want to know about that link procetrue is right or safe? Maybe it is a keil's bug.
After I check ,it is safe.
anyway thanks
No - it is your mis-use (and/or misunderstanding) of the tools that is causing the problem!
The solution is to fix the basic problem in your project structure - not to try to workaround the fallout from it!