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.

Parents
  • Thanx for this such useful tips.......

    the only problem i foresee is the passing of variable from the caliing functing (written in c, and function defination written in assembly) to the called function.

    wat i mean......

    suppose in my

    main()
    { c code
    ........
    ........
    assembly_function(some_arguments);
    ......
    ......
    }

    and in the other xx.a51 file

    assembly_function:

    routine written in assembly
    ..........
    ..........
    ..........
    ret

    end

    than for the variable to be passed, should declared as global......

    pls correct me if i am wrong......

    other thing is those thing which appears like ?xx?xxxx.a51?...

    what is all this things ......
    is there any document which gives explanation of all this things.......
    if you are having than pls mail it to me.....
    my mail id is pranav9us@yahoo.com

    Thanks and regards
    Pranav Saraswala

Reply
  • Thanx for this such useful tips.......

    the only problem i foresee is the passing of variable from the caliing functing (written in c, and function defination written in assembly) to the called function.

    wat i mean......

    suppose in my

    main()
    { c code
    ........
    ........
    assembly_function(some_arguments);
    ......
    ......
    }

    and in the other xx.a51 file

    assembly_function:

    routine written in assembly
    ..........
    ..........
    ..........
    ret

    end

    than for the variable to be passed, should declared as global......

    pls correct me if i am wrong......

    other thing is those thing which appears like ?xx?xxxx.a51?...

    what is all this things ......
    is there any document which gives explanation of all this things.......
    if you are having than pls mail it to me.....
    my mail id is pranav9us@yahoo.com

    Thanks and regards
    Pranav Saraswala

Children
  • "for the variable to be passed, should declared as global"

    Of course.
    But you can still also pass values in parameters, and use the function's return value.

    "is there any document which gives explanation of all this things"

    Of course there is - it's called the Manual.

    There is a chapter specifically titled, "Interfacing 'C' and Assembler" - guess what that's all about...

    You can also do as Erik suggested: write a simple 'C' "skeleton" with examples of all these things (parameter passing, return value, accessing globals), then compile it with the SRC option and look at the generated assembler.
    Then follow the compiler's example.

    The SRC option is, of course, described in the Manual.

  • "other thing is those thing which appears like ?xx?xxxx.a51?...

    what is all this things ......
    is there any document which gives explanation of all this things.......
    "

    Yes, they are all in the MANUAL: totallyfuckedup.com/.../Please read the manual.jpg

    Read the C51 manuals, (Compiler, Linker and Assembler).