Professional Documents
Culture Documents
Exercici Teo.2.1.1
b)
MOV R1, [A] ; Carrega el contingut de la variable A en el registre R1
MOV R2, V ; Carrega l’adreça simbòlica V en el registre R2
MOV [R2+12], R1 ; Carrega el contingut de R1 en V[3]
Solució: V[3]=A
c)
MOV R1, 8 ; Carrega el valor 8 en el registre R1
MOV R3, [V+R1] ; Carrega l’element V[2] en el registre R3
MOV [A], R3 ; Carrega R3 en A
Solució: A=V[2]
Exercici Teo.2.1.2
a)
MOV R0, [i]
MOV R1, [partial_sum]
b)
Plantejament en C:
1 / 3
Estructura de Computadors E-Teo.2
Exercici Teo.2.2
b)
Bk per a k=0..10
Adreça Assemblador 0 1 2 3 4 5 6 7 8 9 10
000010F8h MOV R0, [A] 10 10 20 20 00 00 00
000010FFh CMP R0, [B] 26 10 20 00 02 00 00
00001106h JLE L
abel_1 44 60 08 00
0000110Ah DEC R0 25 10
0000110Ch JMP Label_2 40 00 1D 11 00 00
00001112h ADD [B], 4 20 20 00 02 00 00 00 04 00 00 00
0000111Dh MUL [B], R0 22 20 00 02 00 00 10
00001124h MOV [A], R0 10 20 20 00 00 00 10
c)
Adreça 0 1 2 3 4 5 6 7 8 9 A B C D E F
(Hexa)
13F2x 10 12 00 01 00 00 00 26 20 30 2A 00 00 00 01 00
13F3x 00 00 41 60 13 00 20 12 20 30 2A 00 00 25 20 30
13F4x 2A 00 00 40 00 27 3F 01 00 10 20 00 01 00 00 12
Bk per a k=0..10
Adreça Assemblador 0 1 2 3 4 5 6 7 8 9 10
00013F20h MOV R2, 1 10 12 00 01 00 00 00
00013F32h JE label1 41 60 13 00
2 / 3
Estructura de Computadors E-Teo.2
Exercici Teo.2.3
JMP loop
Fase Micro-operacions
(MAR=0001000Ch) ← (PC=0001000Ch), read ; Carreguem a MAR el contingut de PC
(MBR=000100030040h) ← Memòria ; Llegir instrucció
1
(PC=00010012h) ← (PC=0001000Ch) + 6 ; Incrementar PC
(IR=000100030040h) ← (MBR=000100030040h) ; Carregar instrucció al IR
2 (No cal fer res, ho tenim en la instrucció)
3 (PC=00010003h) ← (IR(Adreça)=00010003h)
MOV R3,4
Fase Micro-operacions
(MAR=00010012h) ← (PC=00010012h), read ; Carreguem a MAR el contingut de PC
1
(MBR=00000004001310h) ← Memòria ; Llegir instrucció
(PC=00010019h) ← (PC=0001012Ch) + 7 ; Incrementar PC
(IR=00000004001310h) ← (MBR=00000004001310h) ; Carregar instrucció al IR
2 (No cal fer res, ho tenim en la instrucció)
3 R3 ← IR (valor immediat, és a dir 00000004h)
MOV [100+R3], R1
Fase Micro-operacions
(MAR=0001000Ch) ← (PC=0001000Ch), read ; Carreguem a MAR el contingut de PC
1
(MBR=000100030040h) ← Memòria ; Llegir instrucció
(PC=00010012h) ← (PC=0001000Ch) + 6 ; Incrementar PC
(IR=000100030040h) ← (MBR=000100030040h) ; Carregar instrucció al IR
(MAR=00000068h) ← 00000064h + 00000004h, read
; És a dir, MAR ← IR (adreça operand) + Contingut de IR (R3), read
2
(MBR=11000000645310h) ← Memòria
MBR ← R1
3 MAR ← 00000068h, write ; 100 + R3
Memòria ← MBR
3 / 3