Thread: C and Assembly

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Rep Power

    C and Assembly

    I am new to the assembly world. I am trying to use assembly with C . how do i integrate assemmbly with C.
    How do i pass the parameter.
    How do i access the arrays passed to the assemlby part of the program.
    I am using İntel- base and NASM under Linux
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2004
    Rep Power
    Any advertisement triggered by IntelliTxt in this post is not endorsed by the author of this post.
  4. #3
  5. Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Rep Power
    I know this isn't really what you asked, but GCC has an inline assembler option.

    There's a little tutorial about it here:

    To enter an ASM block in C code with GCC, you could do:
    char* str = "abc %i\n";
    int main() {
        __asm__ (
            "pushl $123\n"
            "pushl str\n"
            "call printf\n"
    Which would printf abc 123.

    There is also an extended ASM option which allows you to use C variables, where the compiler will translate the actual addresses and such for you, then insert them into your given ASM code template.

    Syntax is a little different from Intel's, but it's not too bad, and it's convenient to use inline to experiment.
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Rep Power
    Here are some good tutorials on Assembly languages :

    Most particularly, I recommend you to read
    Although it uses the AT&T syntax, it provides a lot of useful information, especially on the C calling convention and stackframe

    Here is a link to another book with examples written in NASM :

IMN logo majestic logo threadwatch logo seochat tools logo