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

INLINE ASSEMBLY

hi

i want to use the assembly code in my c file
how can i do this
i refered the link below
but did not the clear idea

http://www.keil.com/support/man/docs/c51/c51_cm_srcfile.htm i gone through following step's
upto step 3 it is ok
but after that i can't get any thing
i used #pragma src at 1st line of my c file
#pragma asm
some asm code
#pragma endasm
help me

1.Create a C source file.

2.Add any required inline assembly instructions.

3.Compile using the SRC directive.

4.Rename the .SRC file so that it is not overwritten by subsequent compilations of the original C source (if required).

4.Make changes to the created assembler source file.

5.Assemble using the assembler.

  • "after that i can't get any thing"

    What do you mean by that?

    Steps 4-6 are things that you need to do - so just do them!

    Perhaps if you explained what you're actually trying to achieve, people might be able to help you reach that goal...

  • STEP's which i follows

    1-> opened up new project and added the the new C file (this file working properly)

    2-> #pragma src wrote at the top of file
    below that other include file which already in prog.
    ex.
    #include <REGx55.h> // include file for at89c55wd
    #include <def.h> // my dfination file for at89c55wd which include other definations related controllers and some micros
    etc.

    3-> added some assembly code
    between #pragma asm & #pragma endasm

    3->enable
    Generate Assembler SRC File
    and
    Assemble src file options.

    but the problem stared now

    4->Rename the .SRC file so that it is not overwritten by subsequent compilations of the original C source (if required).
    what's this
    5->Make changes to the created assembler source file.
    what kind of changes
    6->Assemble using the assembler.
    again i can't get how to assemble using asembler

  • one more thing
    3.Compile using the SRC directive.
    i build the the target is it fine or i am wrong some where

  • "4->Rename the .SRC file so that it is not overwritten by subsequent compilations of the original C source (if required).
    what's this"

    Exactly what it says!

    The SRC directive causes the compiler to translate your file.c source file to a file.SRC output file.

    If you recompile file.c, the compiler will overwrite the previous file.SRC with its new output - so if you want to retain the original file.SRC, you will obviously have to rename it, or copy it to somewhere else, won't you?

    If you don't want to retain the original file.SRC, then you obviously don't need to bother - which is why it says, "if required"

    "5->Make changes to the created assembler source file.
    what kind of changes"

    Whatever changes you require!

    eg, if you are creating a C-callable assembler function, you would create the "skeleton" in 'C', use the SRC directive to convert this to a "skeleton" in assembler, and then insert the body of the assembler function at this point.

    "6->Assemble using the assembler.
    again i can't get how to assemble using asembler"

    Read the section in the Assembler Manual titled, "Assembling Programs"
    http://www.keil.com/support/man/docs/a51/a51_assembling.htm

    Or, if you're using a uVision Project, just add the assembler file to the Project - uVision will automatically recognise it as an assembler source file (based on its filename extension), and use the appropriate tool to translate it (ie, the assembler)

  • "3.Compile using the SRC directive.
    i build the the target is it fine or i am wrong some where"

    If you are using uVision, and you select both 'Generate Assembler Source' and 'Assembler SRC File', then the whole process is automatic - the build will do both the C-to-Assembler translation and the Assembler-to-Object translation

    But, of course, this means that you can't make any manual changes to the .SRC file...