0% found this document useful (0 votes)
144 views2 pages

Describe The Steps That Transform A Program Written in A High Level Language Such As C Into A Repres

A C program is first compiled by a preprocessor that expands macros. It is then compiled into assembly code by parsing the C code and applying optimizations. The assembly code is assembled into binary machine code. A linker then fixes addresses so external library functions can be called. Finally, a loader dumps the binary into memory and executes it.

Uploaded by

Gaurav Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views2 pages

Describe The Steps That Transform A Program Written in A High Level Language Such As C Into A Repres

A C program is first compiled by a preprocessor that expands macros. It is then compiled into assembly code by parsing the C code and applying optimizations. The assembly code is assembled into binary machine code. A linker then fixes addresses so external library functions can be called. Finally, a loader dumps the binary into memory and executes it.

Uploaded by

Gaurav Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Describe the steps that transform a program written in a high-level language

such as C into a representation that is directly executed by a computer processor

Answer:

The following image taken from wiki depicts the steps that transform a program
written in a high-level language such as C into a representation that is directly
executed by a computer processor

A C program is often compiled by gcc. It goes through many transformations


before being executed in hardware. First of all, A text editor is used ot create a
source file, which contains a program in high-level programming language. Then a
preprocessor is used to expand the macros present in the source code. It is a
relatively simple task in C, but can be quite complicated in languages like lisp.
During this phase, the body of the macro replaces every occurence of its name in
hte program's source code. We can invoke gcc's preprocessor via a command
such as gcc -E f0.c -o f1.c

This study source was downloaded by 100000820737951 from CourseHero.com on 02-24-2022 05:48:55 GMT -06:00

https://www.coursehero.com/file/54446643/Describe-the-steps-that-transform-a-program-written-in-a-high-level-language-such-as-C-into-a-repres/
In the next step, source proram ins converted to assembly code. This step is called
compilation. The parsing of the C program is performed in this step. This step
contains the most complex translation step that the program will experiemnt
during its life cycle. The compler also applies code optimizations during this step.

The next step in the compilation chain consists in the translation of the assembly
language to binary code. Though the assembly code is readable by humans, the
binary program can be too. But there are not many who are up to this task these
days.It contains sequences of zeros and ones that the hardware processor
recognizes.

In the next step, the object file or binary program is changed so that the address
of functions defined ina n exernal library is visible. A special software, the linker
can find the address of functions in these libraries, thus fixing the blank addresses
in the object file. Different operating systems use different linkers.

The last step is the responsibility of a program called loader. The loader dumps an
image of the program into memory and runs it

This study source was downloaded by 100000820737951 from CourseHero.com on 02-24-2022 05:48:55 GMT -06:00

https://www.coursehero.com/file/54446643/Describe-the-steps-that-transform-a-program-written-in-a-high-level-language-such-as-C-into-a-repres/
Powered by TCPDF (www.tcpdf.org)

You might also like