delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq156.html   search  

| Previous | Next | Up | Top |

18.13 Inline Assembly code with GCC

Q: I am used to writing inline assembly with Borland C, but can't figure out the way to do it with GCC...

Q: How can I reference C variables from my inline assembly code?


A: GCC has extensive inline assembly facilities. They allow you to specify everything other compilers let you (like the registers where GCC will put specific results), but in a way that doesn't interfere with the compiler's optimizations of the C code that includes inline assembly. Because of this flexibility, the syntax of the inline assembly code is very different from the other DOS-based compilers. The GCC on-line docs describe these facilities in detail; to read the relevant sections, type this from the DOS prompt:
       info gcc "C Extensions" "Extended Asm"

(Note the quotes: they are important.) You will, of course, need that the stand-alone Info reader be installed on your system for the above command to work. If it is not already installed, get the file v2gnu/txi312b.zip from the DJGPP distribution and install it.

If you read this FAQ via WWW, you can also read about the GCC inline assembly extensions with your Web browser.

Brennan Underwood has written a tutorial on using inline assembly, which is another valuable resource on this issue.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright ⌐ 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)