Homework problems homework problem 331 category 1 you

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 file, and the compiled C code is combined with the assembled assembly code by the linker. For example, if file p1.c contains C code and file p2.s contains assembly code, then the compilation command: unix> gcc -o p p1.c p2.s will cause file p1.c to be compiled, file 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 specific 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.

Ask a homework question - tutors are online