Using Assembly Procedures with C

Discussion in 'C Programming' started by Amol Vaidya, Dec 26, 2004.

  1. Amol Vaidya

    Amol Vaidya Guest

    I'm still very much a beginner when it comes to programming assembly for
    the x86. I've read through one book, so I understand the very basics,
    but that's about as far as my knowledge in Assembly goes. Now, I've been
    writing a bit of assembly code that I'd like to be able to call as a C
    function. My book doesn't describe how to do this. Could someone please
    point me to a resource which would allow me to learn this skill? I'm
    using NASM, if that helps any. Thanks in advance for any advice.

    -Regards
    Amol Vaidya
     
    Amol Vaidya, Dec 26, 2004
    #1
    1. Advertising

  2. Amol Vaidya

    Jack Klein Guest

    On Sun, 26 Dec 2004 06:13:55 GMT, Amol Vaidya <>
    wrote in comp.lang.c:

    > I'm still very much a beginner when it comes to programming assembly for
    > the x86. I've read through one book, so I understand the very basics,
    > but that's about as far as my knowledge in Assembly goes. Now, I've been
    > writing a bit of assembly code that I'd like to be able to call as a C
    > function. My book doesn't describe how to do this. Could someone please
    > point me to a resource which would allow me to learn this skill? I'm
    > using NASM, if that helps any. Thanks in advance for any advice.


    Sorry, but you're asking in the wrong place. The C language does not
    define linkage to _any_ other language, so what you want to do is
    off-topic here.

    Most C implementations provide some method of doing this, but the
    details are quite different between compilers and operating systems.

    There are two places you should ask for better information.

    1. The moderated newsgroup news:comp.lang.asm.x86

    2. A group that supports your particular compiler and operating
    system combination.

    In both cases, you need to provide more information about your
    compiler and OS.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Dec 26, 2004
    #2
    1. Advertising

  3. Amol Vaidya

    Amol Vaidya Guest

    Jack Klein wrote:
    > On Sun, 26 Dec 2004 06:13:55 GMT, Amol Vaidya <>
    > wrote in comp.lang.c:
    >
    >
    >>I'm still very much a beginner when it comes to programming assembly for
    >>the x86. I've read through one book, so I understand the very basics,
    >>but that's about as far as my knowledge in Assembly goes. Now, I've been
    >>writing a bit of assembly code that I'd like to be able to call as a C
    >>function. My book doesn't describe how to do this. Could someone please
    >>point me to a resource which would allow me to learn this skill? I'm
    >>using NASM, if that helps any. Thanks in advance for any advice.

    >
    >
    > Sorry, but you're asking in the wrong place. The C language does not
    > define linkage to _any_ other language, so what you want to do is
    > off-topic here.
    >
    > Most C implementations provide some method of doing this, but the
    > details are quite different between compilers and operating systems.
    >
    > There are two places you should ask for better information.
    >
    > 1. The moderated newsgroup news:comp.lang.asm.x86
    >
    > 2. A group that supports your particular compiler and operating
    > system combination.
    >
    > In both cases, you need to provide more information about your
    > compiler and OS.
    >


    Ahh. My appologies for posting this in the wrong place. Thanks for the
    information.
     
    Amol Vaidya, Dec 26, 2004
    #3
  4. Amol Vaidya

    Bonj Guest

    basically it's *very* hard to do it any other way than using an __asm block,
    so just put __asm {..<your assembly here > ..} in your function.
    Doing it any other way is possible and some would argue better but to be
    honest I've tried it and it's far more trouble than it's worth, an immense
    PITA for what you would think would be an easy process. Oh no. Basically I
    tried to find the Microsoft assembler only to find it wasn't included in the
    SDK, I was then led on a wild goose chase round a load of warez sites trying
    to find what the compiler can do internally of its own accord and without
    any (otherwise unnecessary) boilerplate definitions at the top of the asm
    file anyway.

    "Amol Vaidya" <> wrote in message
    news:DEszd.7164$...
    > I'm still very much a beginner when it comes to programming assembly for
    > the x86. I've read through one book, so I understand the very basics, but
    > that's about as far as my knowledge in Assembly goes. Now, I've been
    > writing a bit of assembly code that I'd like to be able to call as a C
    > function. My book doesn't describe how to do this. Could someone please
    > point me to a resource which would allow me to learn this skill? I'm using
    > NASM, if that helps any. Thanks in advance for any advice.
    >
    > -Regards
    > Amol Vaidya
    >
     
    Bonj, Dec 30, 2004
    #4
  5. Amol Vaidya wrote:
    > I'm still very much a beginner when it comes to programming assembly for
    > the x86. I've read through one book, so I understand the very basics,
    > but that's about as far as my knowledge in Assembly goes. Now, I've been
    > writing a bit of assembly code that I'd like to be able to call as a C
    > function. My book doesn't describe how to do this. Could someone please
    > point me to a resource which would allow me to learn this skill? I'm
    > using NASM, if that helps any. Thanks in advance for any advice.
    >
    > -Regards
    > Amol Vaidya
    >


    Although, off-topic, a better option would be to write your assembly
    code for a particular assembler and assemble it to make object files.
    NASM is a good option. Link your object files with your C code to form
    the final executable.

    Regards,
    Jonathan
     
    Jonathan Burd, Jan 2, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Prasanna Padmanabhan
    Replies:
    1
    Views:
    825
    Mattias Sjögren
    Nov 19, 2003
  2. Brent
    Replies:
    1
    Views:
    1,375
    Brent
    Jan 23, 2004
  3. SA
    Replies:
    0
    Views:
    483
  4. Horatiu Margavan via .NET 247

    Assembly's manifest definition does not match the assembly reference.

    Horatiu Margavan via .NET 247, Aug 30, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    3,628
    Horatiu Margavan via .NET 247
    Aug 30, 2004
  5. Grant Merwitz
    Replies:
    3
    Views:
    9,078
    Grant Merwitz
    Sep 15, 2005
Loading...

Share This Page