



Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!




The world numbering system Western (Hindu-Arabic system) is
decimal and positional.
An electrical switch has two states : on and off (or open and
closed). The same concept stands for the binary system , based on the
digits 0 and 1.
Algorithm for finding the binary representation of a positive integer:
quotient by 2 and record the remainder;
from right to left in the order they were recorded.
A bit corresponds to a single digit; 8 bits form a byte. A word is an aggregation of bytes used for
memory cells.
Sum in binary : for multiple digit numbers, we perform
partial sums between bits with the same weight,
propagating the possible carriers.
Subtraction in binary : for multiple digit numbers, we
perform partial subtractions between bits with the same
weight, propagating the possible borrows.
The term overflow indicates the error that occurs, in an automatic
calculation system, when the result of an operation can’t be
represented with the same code and number of bits the operands. It’s a
dynamic condition , since it only exist because of an operation.
Issues with ranges of binary values and overflows are relevant , since all computers represent
data on a limited number of bits. Some languages “expose” these problems, others “hide” them
using internal mechanism. For example, in the C language, integers
are usually on 32 bits, the maximum positive number that can be
represented is 2
31
precision , there can’t be an overflow between integers.
The octal system : it has base 8, it’s useful to write binary numbers
in a compact form. Since 8 is 2
3
, every group of 3 bits becomes an
octal digit. Digits = {0, 1, 2, 3, 4, 5, 6, 7}
The hexadecimal system : it has base 16, useful to write binary numbers in
compact form. Digits = {0, …, 9, A, B, C, D, E, F}.
A number can be positive or negative. It’s therefore easy to represent the sign in binary. The
simplest solution isn’t always the best:
for negative. N-1 for the absolute value (also called magnitude). It’s
simpler to understand, but impractical in operations.
called complement, can be defined as:
N
- 1 ) – A
Also, there’s one practical rule: the one’s complement of a binary number A can be
obtained by complementing (or inverting) all its bits.
defined as:
N
- A = 𝑨
It’s possible to represent negative numbers using two’s complement by:
o Considering all numbers with MSB = 0 as positives, with a value equal to their
normal binary representation (A);
o Considering all number with MSB = 1 as negatives, with a value equal to - 1
multiplied by their two’s complement (- 1 × 𝑨
Equivalently, in a two’s complement number of N bits the MSB has a negative weight
N- 1
), while the rest of the bits have a positive weight according to their position.
There are two practical rules :
o Two’s complement of a binary number A can be obtained by adding one to its
one’s complement;
o The two’s complement of a binary number is obtained starting from the LSB ,
copying all the bits up to the first “ 1 ” (included) and complementing the
remaining bits.
To convert a decimal number to 2 ’s complement, if it’s positive than the same rule as
“plain binary” is used; if it’s negative: first convert the absolute value in binary, then
compute the 1 ’s complement by inverting each bit.
Two’s complement representation is the most adopted in today’s processors, since it
simplifies the circuit implementation of the basic arithmetic operations. It’s also
possible to apply the “standard” binary arithmetic rules to all the bits composing the
number. Addition and subtraction can be done directly , without “special cases”
depending on the sign of the operands. Subtraction of A and B can also be obtained by
summing A with the two’s complement of B (A + 𝐵
If the two operands have different signs , overflow can never occur. If the two operands
have the same sign, there’s overflow when the result has opposite sign.
For representing real numbers there are two options:
part. It reserves a pre-defined number of bits to integer and fractional part (fixed
precision). All the bits of the fractional part have weight 2
.
operations;
sequencing, error checking etc.);
However, it has limit capacity to store data and/or
instructions, pretty much the bare minimum necessary to
carry out the operations. For efficiency reasons a part of
memory is “ hosted ” in the microprocessor. The
microprocessor is made by three different components :
the CPU, the interfaces and the “local” memory (cache).
The CPU is made by a control unit and an operational unit
(datapath).
The operational unit performs all the required processing
(arithmetic, logical, etc.). It’s composed of:
calculations (arithmetic, logical, comparisons) on
integers;
There is a noticeable difference in execution time between ALU and FPU, the ratio
depends on the specific processor, but an FPU is usually 5 - 50 times slower than an ALU
operator;
or instructions. Each transfer between processor and memory really happens between
memory and registers. There is a limited number of registers that the CPU can handle
at the same time (usually 8-128);
information about the result of the last operation performed. They’re used to implement
some conditional instructions. Examples of important flags:
o Zero , reports whether the result of the previous operation is zero or not;
o Sign , indicates the sign of the result of the previous operation;
o Overflow , indicates whether the result of the previous operation has incurred an
overflow.
The control unit is the heart of the processor: it’s based on the
instructions contained in the program being executed and on
the state of all units , it decides the operations to be performed
and issues the related commands to the other units.
The control unit is formed of:
cell containing the next instruction to be executed;
to be executed;
commands for the other units (ALU, FPU, etc.).
While executing an information there are three phases :
IR ← M [PC] : first, it copies the instruction stored in the
main memory (M) at the address pointed by the Program
Counter (PC) into the Instruction Register (IR).
PC ← PC + 1 : then, it increments the Program Counter by
one, so its point to the next instruction in memory for the
following cycle.
The control unit’s decoder reads the bit pattern in IR and translates it into specific
signal/commands that tell the hardware what operation to perform.
Activates the hardware functional blocks (such as ALU, registers, etc.) required to
carry out the decoded operation.
Now that the fundamental blocks of a CPU are
covered, it’s possible to evaluate which
operations are to be considered elementary →
Each processor contains a timing element, a
clock , that generates a common time
reference for all the elements that make up the processing system.
T = clock period (the second as unit)
F = clock frequency = 1/T (the Hertz as unit)
A machine cycle is the time interval in which an elementary operation is performed. It’s an
integer number of clock period. Executing an instruction requires an integer number of clock
cycles, which varies depending on the type of instruction.
The memory stores the data and instructions needed by the computer to operate. It’s
necessary for intrinsic storage and efficiency reasons. The memory has four main
characteristics :
unit. Each memory cell is associated with a numeric address to uniquely identify it.
all the cells, accessible with a single instruction and a multiple of the byte.
possible and retain information indefinitely. However, such a memory doesn’t exist (yet):
fast memories exist, but they are quite volatile ; all the non-volatile memories cost
relatively little but are also relatively slow.
To optimize average access time and average cost , memory is organized into levels:
o Closer to the processor, there’re the faster, more expensive memories (also
volatile, for technological reasons);
How to connect n units (CPU with memories and various
Input/Output controllers) efficiently? A single connection line is
used to connect all components, so each component is physically
hooked to this line. This line is called bus.
There are advantages and disadvantages to the bus:
devices very easy, and it’s standardized , allowing communication on different devices.
any time, and the processor overload , so the CPU acts like a master on the bus,
controlling its usage.
The characteristics of a bus: transporting only one piece of data at a time; the frequency is
equal to the number of data transported per second; the width is the number of bits composing
a single datum.
A single bus is divided into three sub-buses , called:
memory cell;
determines the maximum number of addressable memory cells;
differentiate a read transaction from a write transaction.
The maximum internal memory ( max mem ) = 2
|Abus|
× |Dbus| bit
The external memory (for example, the disk) doesn’t depend on
Abus because it’s considered as a peripheral (input and/or
output). Its quantity depends on the I/O bus, so where peripherals
are connected.
Operating systems manage the machine’s hardware and software resources, providing basic
services to application software. Their goals are to:
Typical modules and service of an operating system: process management; main memory
management; secondary memory management; I/O device management; file management
and file systems; implementation of protection mechanism; network and distributed systems
management.