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

mix assmbly and c

Hi all, can any one tell me the way how to mix c and assembly programing....... i know one way of inline programming i.e.

.......
.......
C code....
.....
.....

#pragma asm
........
assembly code....
........
#pragma endasm

but this type of file written cannot be included in any other file......

i have used IAR assembler for other microcontroller, in which writting

asm ("assembly code");

was working perfectly......

i dont know wether keil supports this.... if yes than what prototype file has to be included for this......

Any help is appriciated....

Thanking You,
Pranav Saraswala.

  • My comments against using the SRC directive state that in my opinion using the SRC directive to generate ASM code for a given function prototype (meaning a given set of passed parameters) is less than optimal, since you will usually have to rewrite the parameter accessing code from the bank registers, because that code will depend on the function body, which will obviously not be written in C. My point is that the SRC compilation cycle takes more time than simply write the ASM code directly in .A51 files, using the very well documented C51 procedure call standard.

    If you do it on a regilar basis and have the "C51 procedure call standard" memorized, I guess you are right.

    However, most of us (I guess) only do this a few times a year and the the old adage "better safe than sorry" do apply. Using the proto/SRC method gives a guaranteed result, using the "C51 procedure call standard" allow for mistakes.

    Erik

  • I totally agree with you. The SRC directive can effectively be a template generator, and have its value as a learning tool, as I have said before.

    I usually write several functions in assembly for any large project in C51, for both space and performance sake. When you are seeking any of those, the SRC templating method is not indicated, due to the reasons discussed above.

    The procedure call standard for C51 is described in the compiler manual, has fixed rules and is very simple. Actually, knowing it helps to write fast C/C function prototypes, not just only ASM/C prototypes.