I am trying to compile hello.c (The same code that comes with Keil Examples) using C51 from DOS and following these steps:
On DOS prompt I am typing
1. C51 hello.c src
2. A51 hello.src
3. BL51 hello.obj this creates 4 warnings and 0 error messages.
4. OH51 hello
Now my problem is that the hex file generated through these steps are not same as the file I get after compiling through uV2 from windows. Also the OBJ and LST are not same.I need the solution for this.
I am using Atmel 89S52 chip.
Doing it that way probably doesn't include the startup and init code that uV2 would have included.
It does not, you need to include it in the linker call.
Erik
"3. BL51 hello.obj this creates 4 warnings and 0 error messages ... I need the solution for this. "
Did it not occur to you to say what the 4 warnings are?
How do you suppose that any one can fix them, if they don't know what they are!
"Doing it that way probably doesn't include the startup and init code that uV2 would have included."
I don't think uVision has anything to do with it.
He's getting the compiler to output assembler source, then getting the assembler to translate that to object. (why? who knows!)
Doing this will never include the startup & runtime stuff - even if you do it from uVision!
This is because the Assembler can't tell that the SRC was generated from a 'C' file, so that information is not in the OBJ file. Therefore the Linker doesn't know to include all the necessary 'C' support stuff.
If the OP had bothered to state what the 4 warnings were, I bet they would have been the giveaway to this!
What Do I have to include in Linker Call???
The 4 Errors are
*** Warning L1: Unresolved External Symbol SYMBOL: _PRINTF MODULE: Hello.obj (HELLO)
*** Warning L1: Unresolved External Symbol SYMBOL: ?_PRINTF?BYTE MODULE: Hello.obj (HELLO)
*** Warning L1: Unresolved External Symbol SYMBOL: C_STARTUP MODULE: Hello.obj (HELLO)
*** Warning L1: Unresolved External Symbol SYMBOL: _PRINTF MODULE: Hello.obj (HELLO) ADDRESS:0817H
You should link your own Object file with standard library which contains external symbols like printf,etc you have refered in your own code.
You should link your own Object file with standard library which contains external symbols like printf,etc you have refered in your own code. Just include the library in the linker line even startupo etc can be 'library called' an example:
c:\tools\keil\c51\bin\bl51 SDstart.obj, SDisr.obj, SD485.obj, SDxdata.obj, ams.lib, c51s.lib TO ams.omf RS(256) IX
erik
The root of your problem is here. Why do you compile this source file via A51? And, possibly more important: how do you expect to get a complete, working project without a properly adjusted startup file?
The root of your problem is here. Why do you compile this source file via A51? Possibly a result of previously using one of the 'do it all in one sweep' tools such as the Metalink.
to the OP if you do not work (not read) your way through the "getting started guide" you may as well delete the Keil tools from your PC.
contrary to the belief of many "Compiling with C51 from DOS" is the advanced method.
Thanks to you Erik and all the forum members. My problem is solved.
To my surprise I repeated all the steps once again but with a difference in one step.
Instead of BL51 hello.obj only I typed
BL51 hello.src,C:\keil\C51\Lib\c51s.lib
and then the next step was
OH51 hello
This worked...
Sorry, there a correction in above posted message
Instead of
it was
BL51 hello.obj,C:\keil\C51\Lib\c51s.lib
The file extension is not .src but .obj