This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ainly of C with a small amount written in assembly language. One method is to write a few key functions in assembly code, using the same conventions for argument passing and register usage as are followed by the C compiler. The assembly functions are kept in a separate ﬁle, and the compiled C code is combined with the assembled assembly code by the linker. For example, if ﬁle p1.c contains C code and ﬁle p2.s contains assembly code, then the compilation command:
unix> gcc -o p p1.c p2.s will cause ﬁle p1.c to be compiled, ﬁle p2.s to be assembled, and the resulting object code to be linked to form an executable program p. 3.15.1 Basic Inline Assembly
With GCC, it is also possible to mix assembly with C code. Inline assembly allows the user to insert assembly code directly into the code sequence generated by the compiler. Features are provided to specify instruction operands and to indicate to the compiler which registers are being overwritten by the assembly instructions. 188 CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS The resulting code is, of course, highly machine-dependent, since different types of machines do not have compatible machine instructions. The asm directive is also speciﬁc to GCC, creating...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American