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

Manipulating Standard Libraries (C51S.LIB)

So I want to replace a standard function in the C51S library. Shouldn't be too hard, right?

I rewrote the function (?C?LMUL to be specific) in assembly and compiled it using the A51 assembler. (processes it without complaint) The code looks like this:

; Segment Definition
?C?LMUL	SEGMENT	CODE

; Module Start
RSEG	?C?LMUL
MOV	...
...
END

I fire up the LIB51 from the command line...
LIB51 DELETE C51S.LIB (?C?LMUL)
A check using LIB51 LIST confirms that I squashed the old ?C?LMUL. Now to put mine back in.
LIB51 ADD NEW_LMUL.OBJ (?C?LMUL) TO C51S.LIB
>> ERR 223 CANNOT FIND MODULE
So I tried to add the whole thing...
LIB51 ADD NEW_LMUL.OBJ TO C51S.LIB
LIB51 LIST C51S.LIB
This listing show that "NEW_LMUL" is in there, but ?C?IMUL is not...

Can anyone help me on this one? Thanks.

Parents
  • It doesn't appear that you made ?C?LMUL PUBLIC.

    Also, why replace these files in the library? You can create your own library and just include it in the linkage BEFORE the Keil libraries. Replacing the modules in the Keil libraries is potentially going to cause you lots of problems in the future.

    Jon

Reply
  • It doesn't appear that you made ?C?LMUL PUBLIC.

    Also, why replace these files in the library? You can create your own library and just include it in the linkage BEFORE the Keil libraries. Replacing the modules in the Keil libraries is potentially going to cause you lots of problems in the future.

    Jon

Children
  • Jon:

    I had tried making the symbol public also, but when assembling the following...

    ; Segment Definition
    ?C?LMUL	SEGMENT	CODE
    
    ; Going Public...
    PUBLIC ?C?LMUL
    
    ; Module Start
    RSEG	?C?LMUL
    MOV	...
    ...
    END
    
    ... I get error 33 from the assembler, ie conflicting attributes - "A symbol may not contain the attributes PUBLIC and EXTRN simultaneously" - on the 'PUBLIC ?C?LMUL' line.

    I agree with you 110% that replacing this in the standard library is not a best practice - I just needed a quick proof of concept.

    As for making my own library, that sounds like a better direction of travel - but I don't know how to get my routine to be called instead of the standard LMUL.

    You mention including it in the linkage "before" the KEIL libraries. In uVision, would I do this on the BankerLinker Misc tab or as a preprocessor directive in the C code that I am trying to roll this new LMUL into.

    Your help is greatly appreciated!

  • A segment is not a symbol, therefore you get syntax error.

    See: http://www.keil.com/appnotes/docs/apnt_149.asp

    This explains how to structure assembler files. Also you find plenty of examples under http://www.keil.com/support.

    As a general rule: do not modify C51 run-time libraries. Just add your modifications to an own library.

  • I can not say this is the cause, but on some library work I have seen the NAME pseudo-op being extremely important. Try inserting a NAME statement.
    Oh, i recall, if you copy a module to another name to make two slighbtly different libray functions and forget to change the NAME statement in the modified copy, all hell breaks lose with meaningless error messages and who knows what.

    Erik

  • You mention including it in the linkage "before" the KEIL libraries. In uVision, would I do this on the BankerLinker Misc tab or as a preprocessor directive in the C code that I am trying to roll this new LMUL into.

    You can do it this way or an easier way is to just add the LIB file to the project just like it was a C or ASM file. uVision knows how to handle it.

    Jon

  • Thanks to all of you for your help and suggestions - I now have it working seamlessly. (The linking process at least - I'll have to finish debuging my new LMUL code tomorrow.)

    For posterity (as well as the purpose of science) I figured it best if I posted back the solution to the problem.

    The source code eneded up looking like this...

    ; Going Public
    PUBLIC ?C?LMUL
    
    ; Segment Definition
    ?PR?LMUL	SEGMENT	CODE
    
    ; Module Start
    RSEG	?PR?LMUL
    ?C?LMUL:
    MOV	...
    ...
    END
    
    As you can see, I had to throw a label in there at the top of the routine and declare THAT as public at the start of the file.

    This ASM file was added to my source group and uV2 substitutes it for the STDF without complaint. What a great tool.

    Like I said, this links perfectly - I checked the machine code. As for why my new rounine not working, I don't think that problem is associated with the topic of this thread, but if in the end it is - I will be back to correct myself for anyone else reading for sure.

    Thanks again for everyone's input.