This is a summary of Computer Systems: A Programmer's Perspective Chapter 3: Machine-Level Representation of Programs by Randal E. Bryant and David R. O’Hallaron.
Computer Systems: A Programmer's Perspective Chapter 2
All for this textbook (2)
Written for
Universiteit van Amsterdam (UvA)
Beta-Gamma
Computer Systems (5082COSY6Y)
All documents for this subject (1)
1
review
By: hasanjamal • 2 year ago
Seller
Follow
cilevanmarken
Reviews received
Content preview
Computer Systems: a Programmer’s
Perspective
Randal E. Bryant en David R. O’Hallaron
Chapter 3 – Machine-Level Representation of
Programs
Computers execute machine code, sequence of bytes encoding the low-level operations that
manipulate data, manage memory, read and write data on storage devices, and communicate over
networks. A compiler generates machine code through a series of stages, based on the rules of the
programming language, the instruction set of the target machine, and the conventions followed by
the operating system. The GCC C compiler generates its output in the form of assembly code, a
textual representation of the machine code giving the individual instructions of the program. GCC
then invokes both an assembler and a linker to generate the executable machine code from the
assembly code.
When programming in a high-level language such as C, we are shielded from the detailed machine-
level implementation of our program. In contrast, when writing programs in assembly code, a
programmer must specify the low-level instructions the program uses to carry out a computation.
Working on high is level is most of the time more productive and reliable. Type checking provided by
a compiler helps detect many program errors and makes sure we reference and manipulate data in
consistent ways. A program written in a high-level language can be compiled and executed on a
number of different machines, whereas assembly code is highly machine specific.
Still, it is important to know a bit of assembly code. By reading assembly code, we can understand
the optimization capabilities of the computer and analyze the underlying inefficiencies in the code.
Sometimes the high-level language hides information about the run-time behavior of a program. This
information can be seen on machine-code level and can be used to prevent attacks on programs.
To understand assembly language, we'll need to understand the transformations typical compilers
make in converting the constructs of C into machine code. Optimizing compilers can rearrange
execution order of C code, eliminate unneeded computations, replace slow operations with faster
ones, and even change recursive computations into iterative ones. It is a form of reverse engineering
– trying to understand the process by which a system was created by studying the system and
working backward. To understand assembly language, just the general principles will not suffice:
you'll need the details as well.
Assembly language is rather peculiar, because it was made by two rivals (Intel and AMD) and only
makes sense when viewed from a historical perspective.
3.1 - A Historical Perspective
The Intel processor line x86 started with one of the first single-chip 16-bit microprocessors. Since
then, it has been improved and improved again. To see a list of all Intel processors from the first to
now, read page 195 – 196.
Each successive processor has been designed to be backward compatible- able to run code compiled
for any other version. Due to this, there are many strange artifacts in the instruction set due to this
evolutionary heritage. The most recent processor from Intel is Intel64, the 64-bit extension to IA32
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller cilevanmarken. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.23. You're not tied to anything after your purchase.