FONDAMENTI DI INFORMATICA
Prof. PIER LUCA MONTESSORO Università degli Studi di Udine
Architettura e funzionamento del
calcolatore
Modello di calcolatore
• Si farà uso di un modello semplificato di elaboratore di tipo RISC (Reduced Instruction Set Computer)
• Per esso vengono nel seguito definiti:
– architettura
– linguaggio macchina/linguaggio assembly
Architettura del processore
Address bus CPU
Control Unit Arithmetic and Logic Unit PC
IR R0
R1 R15
Memoria Dispositivi di I/O 0000
0001 0002 0003 0004 0005 0006 0007
. . . . . .
Data bus Control bus SP
flags
16 fili
3 fili 16 fili
Caratteristiche del processore
• Parallelismo: 16 bit
• 16 registri general purpose da 16 bit
• 3 registri special purpose non direttamente indirizzabili dalle istruzioni
Program Counter (PC) Instruction Register (IR) Stack Pointer (SP)
• flag:
Z (zero) N (negative)
C (carry: Cn) V (overflow: Cn-1 Cn)
Caratteristiche del processore
• Isolated I/O: 16 bit per gli indirizzi di I/O
• Macchina “load & store”:
– le uniche istruzioni che possono accedere alla
memoria sono quelle che trasferiscono i dati da e verso i registri
– tutte le altre operazioni operano soltanto sui registri
• Nell’accesso alla memoria l’indirizzo può essere
espresso in tre modi (“modi di indirizzamento”)
Modi di indirizzamento
• Operando immediato
– la parola che segue l’istruzione contiene il dato (e quindi l’indirizzo del dato è contenuto nel PC)
• Indirizzo assoluto
– la parola che segue l’istruzione (indirizzo nel PC) contiene l’indirizzo del dato
• Indirizzo in registro
– l’indirizzo del dato è contenuto nel registro
specificato dal codice dell’istruzione
Unità di controllo
sequential logic circuits
instruction register clock
status signals from processor
control
signals to processor ... instruction
decoder
Unità aritmetico-logica
combinational circuits
and
data registers control
signals from control unit
...
status signals to control unit
flags
Il control bus
R/W
La CU lo pone a 1 per le operazioni di lettura, a 0 per le operazioni di scrittura
M/IO
La CU lo pone a 1 per le operazioni di lettura o scrittura in memoria, a 0 per le operazioni di lettura o scrittura su dispositivi di input/output
W/B
La CU lo pone a 1 per le operazioni di lettura/scrittura di 1 word, a 0 per le operazioni di lettura/scrittura di 1 byte
Memoria RAM
0000 0001 0002 0003 0004 0005 0006 0007
. . .
Address bus
Data Control bus
bus
address decoder
. . .
R/W, M/IO, W/B
Dispositivi di I/O
Address bus
Data Control bus
bus
address decoder
Indirizzo del monitor 0000
Indirizzo della tastiera 0001
R/W, M/IO, W/B
CPU
Control Unit Arithmetic and Logic Unit PC
IR R0
R1 R15
Memoria Dispositivi di I/O
00 10 CF 36
0000 0001 0002 0003 0004 0005 0006 0007
. . . . . .
SP flags
Instruction fetch (I)
Address bus Data bus Control bus
0003
0003
M/IO = 1 (memory), R/W = 1 (read) W/B = 1 (word)
CPU
Control Unit Arithmetic and Logic Unit PC
1000 IR R0
R1 R15
Memoria Dispositivi di I/O
00 10 CF 36
0000 0001 0002 0003 0004 0005 0006 0007
. . . . . .
SP flags
Instruction fetch (II)
Address bus
. . .
Data bus Control bus
1000
increment
0005
Operand fetch - op. immediato (I)
Address bus
. . .
Data bus CPU
Control Unit Arithmetic and Logic Unit PC
1000 IR R0
R1 R15
Memoria Dispositivi di I/O
00 10 CF 36
0000 0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
Control bus
0005
0005
. . .
M/IO = 1 (memory), R/W = 1 (read) W/B = 1 (word)
Operand fetch - op. immediato (II)
CPU
Control Unit Arithmetic and Logic Unit PC
1000 IR 36CF R0 R1 R15
Memoria Dispositivi di I/O
00 10 CF 36
0000 0001 0002 0003 0004 0005 0006 0007
. . . . . .
SP
flags . . .
increment
0007
Address bus Data bus Control bus
36CF
CPU
Control Unit Arithmetic and Logic Unit PC
2000 IR R0
R1 R15
Memoria Dispositivi di I/O
A8 51 00 20 00 00
0000 0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
0005
M/IO = 1 (memory), R/W = 1 (read) W/B = 1 (word)
Operand fetch - ind. assoluto (I)
Address bus
. . .
Data bus Control bus
0005
Operand fetch - ind. assoluto (II)
Address bus
. . .
Data bus Control bus CPU
Control Unit Arithmetic and Logic Unit PC
2000 IR R0
R1 R15
Memoria Dispositivi di I/O 0000
0001 0002 0003 0004 0005 0006 0007
. . . . . .
SP flags
A8 51 00 20 00 00
. . .
increment
0007
0000 0000
M/IO = 1 (memory), R/W = 1 (read) W/B = 1 (word)
Operand fetch - ind. assoluto (III)
Address bus Data bus Control bus CPU
Control Unit Arithmetic and Logic Unit PC
2000 IR 51A8 R0 R1 R15
Memoria Dispositivi di I/O
A8 51 00 20 00 00
0000 0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
0007
. . .
51A8
Operand fetch - ind. in registro (I)
Address bus Data bus Control bus CPU
Control Unit Arithmetic and Logic Unit PC
3001 IR R0
0006 R1 R15
Memoria Dispositivi di I/O
97 22
0000 0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
M/IO = 1 (memory), R/W = 1 (read) W/B = 1 (word)
CPU
Control Unit Arithmetic and Logic Unit PC
3001 IR 2297 R0
0006 R1 R15
Memoria Dispositivi di I/O
97 22
0000 0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
Operand fetch - ind. in registro (II)
Address bus
. . .
Data bus Control bus
2297
Memory store - ind. assoluto (I)
Address bus CPU
Control Unit Arithmetic and Logic Unit PC
2260 IR 3003 R0 R1 R15
Memoria Dispositivi di I/O
00 22 00 00
0000 0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
0005
. . .
M/IO = 1 (memory), R/W = 1 (read) W/B = 1 (word)
Data bus Control bus
0005
CPU
Control Unit Arithmetic and Logic Unit PC
2200 IR 3003 R0 R1 R15
Memoria Dispositivi di I/O 0000
0001 0002 0003 0004 0005 0006 0007
. . . . . .
SP flags
00 20 00 00
. . .
increment
M/IO = 1 (memory), R/W = 0 (write) W/B = 1 (word)
0007
. . .
Memory store - ind. assoluto (II)
Address bus Data bus Control bus
0000 0000
CPU
Control Unit Arithmetic and Logic Unit PC
2200 IR 3003 R0 R1 R15
Memoria Dispositivi di I/O 0000
0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
03 30 00 22 00 00 0007
Memory store - ind. assoluto (III)
Address bus
. . .
Data bus Control bus
3003
Memory store - ind. in registro (I)
Address bus Data bus CPU
Control Unit Arithmetic and Logic Unit PC
3201 IR 2297 R0
0006 R1 R15
Memoria Dispositivi di I/O 0000
0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
M/IO = 1 (memory), R/W = 0 (write) W/B = 1 (word)
. . .
Control bus
. . .
Memory store - ind. in registro (II)
CPU
Control Unit Arithmetic and Logic Unit PC
3201 IR 2297 R0
0006 R1 R15
Memoria Dispositivi di I/O
22
0000 0001 0002 0003 0004 0005 0006 0007
. . .
SP flags
97
Address bus
. . .
Data bus Control bus
2297