Class 1.1 Computer Architecture. ISA. Numeration systemsx
Download
Report
Transcript Class 1.1 Computer Architecture. ISA. Numeration systemsx
Why to use the assembly and why we need this course at all?
How tens of programs work on one or couple of processors of your PC?
It’s organized by the Operating System.
Operating systems behavior cannot be understood without knowledge of
computer structure and the assembly language.
• PCB, context switch, threads, stack, heap, dynamic linking
Assembly language advantages versus High level languages
• The primary reason to program in assembly language is that the speed
or size of a program is critically important.
• A hybrid approach, in which most of a program is written in a highlevel language and time-critical sections are written in assembly
language, builds on the strengths of both languages
• Cases when no high-level language or compiler is available on a
particular computer
• Ability to exploit specialized instructions, for example, string copy or
pattern-matching instructions.
Human writes
the code
During the course we have to
• The•abstraction
go throughof
allthe
thedifferent
levels parts of computer hardware / software allows us
to create
different
of Representation / Interpretation.
• learn
each ofLevels
them separately
learn the
translation
from oneeach
to another
• This• makes
easier
to understand
part separately and get the whole picture
• Finally
we’llallput
together the learned material and get the final picture of
putting
together
components.
computer organization.
Instruction Set Architecture
• Basic job of a CPU: execute lots of instructions.
• Instructions are the primitive operations that the CPU
may execute.
• Different CPUs implement different sets of
instructions. The set of instructions a particular CPU
implements defines the Instruction Set Architecture
(ISA).
• Examples: Intel x86 (Pentium 4), Apple/IBM/Motorola
PowerPC, MIPS, Sun Sparc, ...
Computer architecture
The architecture of a computer is a
logical description of its components
+ its basic operations (ISA).
Machine Instruction
Memory Address
(Basic Operation of
Processor)
In pure assembly language one assembly
language statement corresponds to one
basic operation of the processor.
Assembly Language
statement
Set of Assembly Language statements (instructions) fully defines the operational part of architecture
Assembly Language
Instruction Set for
Sun Sparc platform
Assembly Language
Instruction Set for
MIPS platform
Assembly Language
Instruction Set for
Intel x86 platform
The architecture defined by the instruction set of assembly language we call ISA – Instruction Set
Architecture. We see 3 different ISA listed above.
High and Low level languages
C Program
C++ Program
Assembly Program
Sun Sparc
Java Program
C#, .net Program
Assembly Program
MIPS
Assembly Program
Intel x86
In assembly language the program is written totally in terms of the processor.
The assembly program of one processor cannot run on the processor of other
architecture (platform).
Programs in high level languages such as C or Pascal are (mostly)
independent of the processor they run on.
Programs in Java are totally independent of the processor (because they run on
special environment – Java Virtual Machine, Java Application Server, TomCat
server – implemented on different platforms to understand the same Java
language for different architectures).
Numeration systems
Review
One plus one always equals to two,
no matter how you symbolize one, one and two.
Just Lions:
Roman numbers
Decimal numbers
Binary numbers
Hexadecimal numbers
I
1
1
1
+
+
+
+
I
1
1
1
=
=
=
=
II
2
10
2
Doing binary correct operations in the computer we are sure that the
translated result to decimal also is correct.
Numeration systems
Numeration Systems
Non Positional systems:
Roman numbers
IV, VII
The I everywhere is “one” in this system.
I
Positional (radix) systems:
o Decimal number system
o Binary number system
o Hexadecimal number system
The general form of positional numbers is:
n
Number = ∑
Integer Part
i = -k
di x Ri
Fractional Part
dn ... d2 d1 d0 . d –1 d –2 d –3 ... d –k
R – The base or radix of numerical system.
A radix R number system requires R different symbols to represent the digits
(d) from 0 to R -1.
i – weight of digit or position.
Numeration systems
Decimal Numeration System
(Human use ten fingers on both hands for calculation)
R = 10
d – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
1+1+1+1+1 + 1+1+1+1+1 + 1+1
------------------------------------------
= 12
----10
10
12
Decimal 12 means:
12 = (1 x 10) + (2 x 1)
12 = 10 + 2
hundreds’ place
tens’ place
ones’ place
Decimal 1206 means:
1206 = 1000 + 200 + 0 + 6
1206 = (1 x 1000) + (2 x 100) + (0 x 10) + (6 x 1)
1206 = (1 x 103) + (2 x 102) + (0 x 101) + (6 x 100)
Numeration systems
Binary (two based) Numeration System
(The human who used this kind of system has a single hand with only one finger on it)
R=2
1+1
--------
+
1 = 112
d – 0, 1
102
= 210
102
= 210
---
bits (two based digits)
112
= 310
Fours’ place Twos’ place
Ones’ place
110102 = (1 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (0 x 20)
110102 = (1 x 16) + (1 x 8) + (0 x 4) + (1 x 2) + (0 x 1)
110102 = 16 + 8 +0 + 2 + 0 = 2610
The base is needed to distinguish
different numeration systems
Most Significant Bit
Least Significant Bit
Binary system in computers
Why we use binary system in computers ?
Easy to represent two cipher states 0,1 electronically (a simple flip-flop is the
basic device which stores the binary bit and consists of several semiconductors).
Needs simple hardware and simple procedures for calculations (all mathematical
operations could be done by simple shift, invert, add operations)
1. Bits. Bit Patterns. Bit Grouping
Binary numeration also lends itself well to the storage and retrieval of numerical
information on magnetic media (magnetized – 1, demagnetized –0) or optical
disks (laser burned pit –1, not burned – 0).
Bit patterns
A bit can be 0 or 1. With one bit there are two possible patterns.
How many patterns can be formed with two
bits? Here is a complete list:
00
01
10
11
Looks like 4 patterns.
How many patterns can be formed with three
bits? Let's list them:
000
001
010
011
100
101
110
111
Looks like 8 patterns.
Number of possible patterns of N bits = 2N
Many calculations involving bit patterns use the following familiar fact of arithmetic. (Although the
fact is familiar, confusion is even more familiar. Be sure you know this fact.)
2(N+M) = 2N × 2M
Bit grouping
BIT GROUPINGS
Bit
- 1 bit (0,1)
Nibble
- 4 bits
Byte
- 8 bits
Half word
- 16 bits for MIPS 32
Word
- 32 bits for MIPS 32
Double word
- 64 bits for MIPS 32
- 16, 32, 64 bits depended on a system
MIPS 32 architecture - word, half word and double word representation.
Half
Half
Half
Word
Half
Word
Double
Hexadecimal (sixteen based) Numeration System
serves as a "shorthand" comfortable method of denoting a number represented in binary form
R = 16
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
1 0000
1 0001
1 0010
1 0011
1 0100
d – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Hexadecimal
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
11
12
13
14
The binary number
1011 0111 1000 01012
the hexadecimal
equivalent
B
7
8
5
16
the decimal value
3
2
1
0
(11 x 16 ) + (7 x 16 ) + (8 x 16 ) + (5 x 16 )
(11 x 4096) + (7 x 256) + (8 x 16) + (5 x 1)
45056 + 1792 + 128 + 5 = 46981
Conversion Example From Decimal to Binary
Convert the decimal 54.4062510 to binary:
Repeated division for the integer portion:
Repeated multiplication for the fractional portion:
54
0.40625 x 2 = 0.8125 Integer portion of product = 0
--- = 27.0 Remainder = 0
2
0.8125 x 2 = 1.625 Integer portion of product = 1
27
0.625 x 2 = 1.25 Integer portion of product = 1
--- = 13.5 Remainder = 1 (0.5 x 2)
2
0.25 x 2 = 0.5 Integer portion of product = 0
0.5 x 2 = 1.0 Integer portion of product = 1
13
--- = 6.5 Remainder = 1 (0.5 x 2)
2
PARTIAL ANSWER: 0.4062510 = 0.011012
6
COMPLETE ANSWER:
--- = 3.0 Remainder = 0
2
5410 + 0.4062510 = 54.4062510
3
1101102 + 0.011012 = 110110.011012
--- = 1.5 Remainder = 1 (0.5 x 2)
2
1
--- = 0.5 Remainder = 1 (0.5 x 2)
2
PARTIAL ANSWER: 5410 = 1101102