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

How to include inline assembly when I have many C-files in project?

I have many C-files in the project. I would like to include inline assembly in some files so I do this step,
- I include assembly code between "#pragma asm" and "#pragma endasm"
- I include "#pragma src" on the top of that file.
when I compile, it said "Fatal Error L210: I/O Error on Input File"
"Exception 0021H: Path or File Not Found"
It has only 1 error. I try to use this step with the project that has only 1 C-file, it works. So I think it's because of many C-file.
One thing that I see is it tell me the same result even though I include only src directive(don't include any assembly code).
How should I do? Thank you very much for your suggestion. :)

  • "I compile, it said 'Fatal Error L210: I/O Error on Input File'"

    That's a Linker error - not a compiler error!

    "Exception 0021H: Path or File Not Found"

    It also tells you which file was not found - you should pay attention to that!

    Have you read and followed all the instructions about #pragma SRC from the Manual?

    Hint: What does the compiler generate when you use the SRC directive...?

  • Hi
    You have to change the options for "file.asm".

    I use this settings,

    Include in Target Build (on)
    Generate Assambler SCR File (on)
    Assamble SCR File (on)

    /ingo

  • "You have to change the options for 'file.asm'."

    No - these options apply to the 'C' source file(s).

  • Sorry
    You should change the option in "file.c"
    where you have the pragma scr, pragma asm.

  • Why do you want to use inline assembler anyway?

    Like I always say: if you need some assembler, have it properly as an assembler module - don't mess about with inline assembler in 'C' source files!

    Remember: the SRC directive turns your 'C' source into assembler, so you lose all 'C' source-level debug & browsing facilities for that file.

    Using the SRC directive is a great way to initially create 'C'-compatible assembler source as a starting point - with all the right calling & naming conventions, parameter passing, etc - but once you've done that, the 'C' file is of no further use; so throw it away!

    http://www.keil.com/forum/docs/thread4399.asp

  • Thank you for your suggestions.

    It also tells you which file was not found - you should pay attention to that!
    It tells me which file but I still don't know how to do because if I don't use any pragma it don't have any error.

    I use this settings,
    Include in Target Build (on)
    Generate Assambler SCR File (on)
    Assamble SCR File (on)

    I've already tried but it tells me
    Station.src(386): error A8: Attempt to define an already defined label

    I have no problem with inserting assembly's file but in this case I want to insert only 3-5 lines of assembly so I try to use pragma instead of assembly's file. If using pragma make me lose all 'C' source-level debug & browsing facilities then I think maybe inserting assembly's file is better. Thank you all very much :)

  • "Station.src(386): error A8: Attempt to define an already defined label"

    Again, it will tell you which label it thinks is being redefined - you need to pay attention to this!

    You need to review the assembler source code (station.src) - including any INCLUDEd files - to find the duplicate definition.

    Make sure you aren't "manually" defining stuff that is already implicitly defined by the assembler - see the Assembler Manual

  • Hi
    After open project with uV2 :
    1. Write

             #pragma asm
                  .
                your assembly code here
                  .
             #pragma endasm
    

    2.Right click on your file that inserted assembly code etc main.c in project workspace
    then select "Option for file...."

    3.in properties tab click two times on "Generate Assembler SRC file" and "Assembler source file"