The Compilation Process - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

The Compilation Process

Description:

The Compilation Process – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 7
Provided by: stude687
Category:

less

Transcript and Presenter's Notes

Title: The Compilation Process


1
The Compilation Process
.o
1110
Precompiler
Assembler
Compiler
Linker
.s
.c
.o
Straight substitution of signs
1010
0110
.o
08048fac ltmaingt 8048fac 55
push ebp 8048fad 89 e5 mov
esp,ebp 8048faf 83 ec 1c sub
0x1c,esp 8048fb2 57 push
edi 8048fb3 56 push esi
8048fb4 53 push ebx
8048fb5 8b 75 08 mov
0x8(ebp),esi 8048fb8 8b 5d 0c mov
0xc(ebp),ebx 8048fbb c7 45 f8 00 00 00 00
movl 0x0,0xfffffff8(ebp) 8048fc2 c7 45 f4
01 00 00 00 movl 0x1,0xfffffff4(ebp)
8048fc9 83 c4 f8 add
0xfffffff8,esp 8048fcc 68 7c 8e 04 08
push 0x8048e7c 8048fd1 6a 0b
push 0xb 8048fd3 e8 00 f7 ff ff call
80486d8 lt_init0x70gt 8048fd8 83 c4 f8
add 0xfffffff8,esp 8048fdb 68 4c 8e 04
08 push 0x8048e4c
1010 1110 0110
Final Executable Binary File
2
Making Code More Modular
  • include ltstdlib.hgt
  • include ltstdio.hgt
  • define MAX_WORD_LEN 30
  • void print_menu (void)
  • int insert (char array, int numwords, char
    buf)
  • int print_to_file (char array, int numwords,
    char file)
  • int
  • main (int argc, char argv)
  • ...
  • void
  • print_menu (void)
  • ...

Precompile info
Create a header file for each
Prototypes
Main Function
Leave in main .c file
Place each in its own .c file
Additional Functions
3
Making Code More Modular
labx.c
print.h
include ltstdlib.hgt include ltstdio.hgt include
print.h include insert.h define
MAX_WORD_LEN 30 int main (int argc, char
argv) ...
void print_menu (void) int print_to_file (char
array, int numwords, char file)
insert.h
int insert (char array, int numwords, char
buf)
print.c
  • void
  • print_menu (void)
  • ...
  • int print_to_file (char array, int numwords,
    char file)
  • ...

insert.c
int insert (char array, int numwords, char
buf) ...
4
Putting the Modules Together
labx.c
labx.o
print.c
print.o
insert.o
insert.c
LINKER
a.out
5
Confused??? Enter Makefiles
  • Located in the directory of your code
  • Must be named Makefile
  • Syntax
  • CommentsPut anything here
  • MacrosCC gccCFLAGS -Wall O pedantic o
    LabX.exe
  • FILES labx.c print.c insert.c
  • ---------------------------------------------(C
    C) (CFLAGS) (FILES)
  • Translates to
  • gcc Wall O2 pedantic o LabX.exe labx.c
    print.c insert.c

6
Syntax cont.
  • Statements
  • name dependency1 dependency2
  • lttabgt command1
  • lttabgt command2
  • lttabgt
  • all is the default statement (run when just
    make is typed at the command line)
  • cleanup cleans up when there is an error
  • make ltnamegt
  • will explicitly run the statement name
Write a Comment
User Comments (0)
About PowerShow.com