Computer Systems: A Programmer's Perspective Chapter 3
All for this textbook (2)
Written for
Universiteit van Amsterdam (UvA)
Artificial Intelligence
Computer Systems (5082COSY6Y)
All documents for this subject (1)
Seller
Follow
cilevanmarken
Reviews received
Content preview
Computer Systems: a Programmer’s
Perspective
Randal E. Bryant en David R. O’Hallaron
Chapter 2 – Representing and Manipulating
Information
In the real world, base-10 is used in decimal notation and is based on the ten fingers we have. Base-2
(binary, so 0 or 1) works better for machines that store and process information. In computer
systems there are three important representations of numbers:
Unsigned encodings
are based on traditional binary notation and represents numbers greater than or equal to 0.
Two-complement encodings
are the most common way to represent signed integer (numbers that may be either positive or
negative).
Floating-point encodings
are a base-2 version of scientific notation for representing real numbers.
Computer representations use a limited number of bits to encode a number, which is why some
operations can overflow when results are too large to be represented. This is why some
computations won't return the expected result. With floating-point arithmetic, the product of
positive numbers will always be positive and numbers that are too large will yield the special value
+∞.
Integer representations can encode a comparatively small range of values, but do so precisely, while
floating-point representations can encode a wide range of values, but only approximately
2.1 - Information Storage
So, we've learned that machine-level programs views memory as a very large array of bytes, known
as the virtual memory. Every byte in the memory has a unique identifying number, called the
address. The set of all possible addresses is referred to as the virtual address space. This virtual space
is just a conceptual image: the actual implementation uses a combination of DRAM (see chapter 1),
flash memory, disk storage, special hardware and OS software to provide the program with a
monolithic byte array.
The compiler and run-time system divide this memory space into multiple parts to store the different
program objects, for instance program data, instructions and control information. There are multiple
mechanisms that allocate and manage the software for various parts of the program, all in the virtual
address space. A C compiler associates a data type program objects. However, the actual machine-
level program treats every program object as a block of bytes and the program itself as a sequence of
bites.
2.1.1 - Hexadecimal Notation
Hexadecimal numbers are written in base-16 and consist of the number 1 to 9 and the letters A to F.
A byte in hexadecimal notation can range from 00 16 to FF16. Hexadecimal number can be recognized
by the '0x' notation in front of them.
1
, 2.1.2 - Data Sizes
Every computer has a word size, that indicates the standard size of pointer data. This word size
determines the maximum size of the virtual address. A machine with a w-bit word size has a virtual
addresses that can range from 0 to 2w - 1. The program can access up to 2w bytes. Past years there
has been a shift from 32-bit word sizes to 64 bit word sizes, because the virtual address space is
larger with 64 bit word size (32: 4 GB, 64: 16 exabytes (EB)). Programs that are compiled for 32 bit
machines can also be run on most 64 bit machines by using 'gcc -m32 file.c'. 64 bit programs can only
be run on 64 bit machines.
There are multiple data formats with different lengths and different ways of encoding data, as seen
below.
Integer data can either be signed (able to present negative, zero and positive values) or unsigned
(only positive values and zero). Data type char represents a single byte can store a single character or
an integer. The data types short, int and long have different sizes and store integers. The data types
float and double have different sizes and store floating-point number. Most of the data types encode
signed values. Char is a bit weird in this: char can be both signed as unsigned, so pay attention to
that!
2.1.3 - Addressing and Byte Ordering
Programs that span multiple bytes have an address. The bytes of the program are stored in a specific
order. Mukti-byte objects are stored in a contiguous sequence of bytes, where the address of the
smallest byte is the address of the whole sequence. For example, int x is 4 bytes and has address
0x100. The 4 bytes of the whole int would be stored in locations 0x100, 0x101, 0x102 en 0x103. Every
location can store 1 byte.
There are two ways in which a multi-byte object can be stored:
2
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.18. You're not tied to anything after your purchase.