The stack pointer esp holds the address of this

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: ed from least-significant to most as 44 94 04 08. 3.2. PROGRAM ENCODINGS 97 3.2.3 A Note on Formatting The assembly code generated by GCC is somewhat difficult to read. It contains some information with which we need not be concerned. On the other hand, it does not provide any description of the program or how it works. For example, suppose file simple.c contains the code: 1 2 3 4 5 6 int simple(int *xp, int y) { int t = *xp + y; *xp = t; return t; } when GCC is run with the ‘-S’ flag it generates the following file for simple.s. .file "simple.c" .version "01.01" gcc2_compiled.: .text .align 4 .globl simple .type simple,@function simple: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax movl (%eax),%edx addl 12(%ebp),%edx movl %edx,(%eax) movl %edx,%eax movl %ebp,%esp popl %ebp ret .Lfe1: .size simple,.Lfe1-simple .ident "GCC: (GNU) 2.95.3 20010315 (release)" The file contains more information than we really require. All of the lines beginning with ‘.’ are directives to guide the assembler and linker. We can generally ignore these. On the other han...
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