Thread: Assembly language in C

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    266

    Assembly language in C

    I was reading an article on assembly language in wikipedia and was a little suprised to read this line.
    >>Relatively low-level languages, such as C, often provide special syntax to
    >>embed assembly language directly in the source code.
    Any ideas how to do that? Is it compiler specific?
    Last edited by lruc; 08-26-2008 at 06:59 PM.

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    It is compiler specific, but that's a pretty good explanation above. Another common syntax is

    Code:
    asm { ... }
    (IIRC that's what Borland compilers use)

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    As stated, it is compiler specific, so each compiler (that supports inline assembler at all) will have it's own variant.

    MS Visual Studio uses the
    Code:
    asm { ... }
    format.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    So if im using code blocks on linux, which im pretty sure uses gcc, the format would be asm("")?

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yup, and that would work in windows using gcc too [as long as the assembler itself doesn't rely on unportable constructs - e.g. calling system calls or functions that aren't present on the other architecture]. And if you want to be ANSI compatible use __asm__.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  2. Benefits of learning assembly language?
    By 747ken in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-02-2003, 07:16 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. bubble sort in assembly language!!!!!!
    By lorenzohhh in forum C++ Programming
    Replies: 1
    Last Post: 04-15-2002, 08:30 PM
  5. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 03:35 AM