SPIM is a MIPS R2000/R3000 simulator that can read and execute assembly programs. It has both command-line and graphical user interfaces. Xspim provides the graphical interface and loads programs by clicking buttons. It displays registers, instructions, data and stack. Users can then run the program and view the results.
SPIM is a MIPS R2000/R3000 simulator that can read and execute assembly programs. It has both command-line and graphical user interfaces. Xspim provides the graphical interface and loads programs by clicking buttons. It displays registers, instructions, data and stack. Users can then run the program and view the results.
co-authors: Scola Davide and Maia Nicoletta
Small workshop on Inferno, Limbo and the Dis virtual machine.
Inferno is a new operative system developped for creation and support of network systems and distribuited services.
There are three fundamental programming principles: all resources are files in a hierarchic file system, the network is a unic namespace like a file system hierarchic, it uses Styx that is a standard protocol of comunication for local and remote resources.
Limbo is the programming language for the Inferno OS.
The language is Object Based, you can compile it or interpret it with the Dis virtual machine (like Java virtual machine with a JIT compiler).
Limbo has a native support for: array, string, int, float, tuple (like record), channel (linda-like), and other...
The Limbo's channels are used to comunicate with other processes or with thread.
The Dis virtual machine is an environment for Limbo programs and it has important features: CISC architecture, memory-to-memory, many high level types, just in time compiler, ecc...
In the end of presentation there is a comparison between Dis, Java VM and C# .Net VM.
Continous Delivery e codice di Alta Qualità in PHP. Usare Git , Jenkins e diversi tool per realizzare codice di qualità e per effettuare il deploy in maniera automatica.
Presentazione effettuata al 5 incontro del Palermo PHP User Group al teatro Gregotti
TypeScript, ovvero JavaScript che "non si rompe"BENTOSA
Le slide del seminario introduttivo su TypeScript, il superset di JavaScript di Microsoft. Antonio e Federico ci hanno illustrato le potenzialità di questo linguaggio per scrivere del codice JavaScript con meno errori.
co-authors: Scola Davide and Maia Nicoletta
Small workshop on Inferno, Limbo and the Dis virtual machine.
Inferno is a new operative system developped for creation and support of network systems and distribuited services.
There are three fundamental programming principles: all resources are files in a hierarchic file system, the network is a unic namespace like a file system hierarchic, it uses Styx that is a standard protocol of comunication for local and remote resources.
Limbo is the programming language for the Inferno OS.
The language is Object Based, you can compile it or interpret it with the Dis virtual machine (like Java virtual machine with a JIT compiler).
Limbo has a native support for: array, string, int, float, tuple (like record), channel (linda-like), and other...
The Limbo's channels are used to comunicate with other processes or with thread.
The Dis virtual machine is an environment for Limbo programs and it has important features: CISC architecture, memory-to-memory, many high level types, just in time compiler, ecc...
In the end of presentation there is a comparison between Dis, Java VM and C# .Net VM.
Continous Delivery e codice di Alta Qualità in PHP. Usare Git , Jenkins e diversi tool per realizzare codice di qualità e per effettuare il deploy in maniera automatica.
Presentazione effettuata al 5 incontro del Palermo PHP User Group al teatro Gregotti
TypeScript, ovvero JavaScript che "non si rompe"BENTOSA
Le slide del seminario introduttivo su TypeScript, il superset di JavaScript di Microsoft. Antonio e Federico ci hanno illustrato le potenzialità di questo linguaggio per scrivere del codice JavaScript con meno errori.
1. MIPS & SPIM
MIPS & SPIM
Modulo del Corso di Architettura degli Elaboratori
Nicola Paoletti
Universit` di Camerino
a
Scuola di Scienze e Tecnologie
5 Aprile 2011
AA 2010/2011
2. MIPS & SPIM
Lezioni precedenti
Lezione 1: linguaggio macchina/assembly/alto livello; RISC
vs CISC.
Lezione 2: introduzione al MIPS Instruction Set; registri;
istruzioni aritmetiche e di data transfer.
4. MIPS & SPIM
Codifica istruzioni MIPS
Come traduciamo un’istruzione in linguaggio macchina?
Tre tipi di formati (32 bit):
Formato R-type: per le istruzioni del tipo add, sub, mul, div,
and, or, . . . (R-format: Registry-format)
Formato I-type: per le istruzioni del tipo addi, lw, sw, . . .
(I-format: Immediate-format)
Formato J-type: per le istruzioni di jump (J-format:
Jump-format)
6. MIPS & SPIM
Codifica istruzioni MIPS
Formati di istruzione
R-format
op rs rt rd shamt funct
6 bit 5 bit 5 bit 5 bit 5 bit 6 bit
op: opcode
rs: primo registro sorgente
rt: primo registro sorgente
rd: registro di destinazione
shamt: shift amount; =0 se non si tratta di un’istruzione di
shift
funct: funzione; i campi op e funct identificano la particolare
funzione da eseguire.
7. MIPS & SPIM
Codifica istruzioni MIPS
Formati di istruzione
I-format (1/2)
op rs rt address
6 bit 5 bit 5 bit 16 bit
In questo caso solo opcode identifica l’istruzione mnemonica.
Si hanno 16 bit per indirizzare la memoria fisica.
8. MIPS & SPIM
Codifica istruzioni MIPS
Formati di istruzione
I-format (2/2)
Domanda:
Ricordandoci che la memoria ` indirizzata byte per byte, con 16 bit
e
per specificare l’indirizzo,
qual’` l’intervallo a cui possiamo accedere?
e
9. MIPS & SPIM
Codifica istruzioni MIPS
Formati di istruzione
I-format (2/2)
Domanda:
Ricordandoci che la memoria ` indirizzata byte per byte, con 16 bit
e
per specificare l’indirizzo,
qual’` l’intervallo a cui possiamo accedere?
e
Dato un offset $s, dal byte $s al byte 216 − 1+ $s.
10. MIPS & SPIM
Codifica istruzioni MIPS
Formati di istruzione
J-format
op address
6 bit 26 bit
Address specifica l’indirizzo dell’istruzione a cui saltare.
11. MIPS & SPIM
Codifica istruzioni MIPS
Formati di istruzione
Una vista d’insieme
Type Format(Bits)
R opcode(6) rs(5) rt(5) rd(5) shamt(5) funct(6)
I opcode(6) rs(5) rt(5) immediate(16)
J opcode(6) address(26)
16. MIPS & SPIM
Codifica istruzioni MIPS
R-format
Multiplication
mult
Alto livello: $LO = (($s * $t) << 32)>>32
$HI = ($s * $t)>>32
Assembly: mult $s, $t
Macchina: 0x0 $s $t 0x0 0x0 0x18
Moltiplica il contenuto dei due registri a 32 bit ($s e $t). Il
risultato (64 bit) viene messo in due registri speciali:
$LO: contiene i 32 bit meno significativi del risultato; si
recupera attraverso l’istruzione mflo $s.
$HI: contiene i 32 bit pi` significativi del risultato; si recupera
u
attraverso l’istruzione mfhi $s.
17. MIPS & SPIM
Codifica istruzioni MIPS
R-format
Bitwise and
and
Alto livello: $d = $s & $t
Assembly: and $d, $s, $t
Macchina: 0x0 $s $t $d 0x0 0x24
18. MIPS & SPIM
Codifica istruzioni MIPS
R-format
Bitwise or
or
Alto livello: $d = $s | $t
Assembly: or $d, $s, $t
Macchina: 0x0 $s $t $d 0x0 0x25
22. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Add immediate
addi
Alto livello: $t = $s + C
Assembly: addi $t, $s, C
Macchina: 0x8 $s $t C
23. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Load word (1/2)
lw
Alto livello: $t = MEM[$s + offset]
Assembly: lw $t, offset($s)
Macchina: 0x23 $s $t $s + offset
Attenzione:
La memoria ` indirizzata al singolo byte
e
Le word hanno lunghezza 32 bit = 4 byte
Il valore di $s ` un multiplo di 4.
e
24. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Load word (1/2)
lw
Alto livello: $t = MEM[$s + offset]
Assembly: lw $t, offset($s)
Macchina: 0x23 $s $t $s + offset
Attenzione:
La memoria ` indirizzata al singolo byte
e
Le word hanno lunghezza 32 bit = 4 byte
Il valore di $s ` un multiplo di 4.
e
25. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Load word (1/2)
lw
Alto livello: $t = MEM[$s + offset]
Assembly: lw $t, offset($s)
Macchina: 0x23 $s $t $s + offset
Attenzione:
La memoria ` indirizzata al singolo byte
e
Le word hanno lunghezza 32 bit = 4 byte
Il valore di $s ` un multiplo di 4.
e
26. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Load word (1/2)
lw
Alto livello: $t = MEM[$s + offset]
Assembly: lw $t, offset($s)
Macchina: 0x23 $s $t $s + offset
Attenzione:
La memoria ` indirizzata al singolo byte
e
Le word hanno lunghezza 32 bit = 4 byte
Il valore di $s ` un multiplo di 4.
e
27. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Load word (2/2)
Example
Codice MIPS per caricare in $t la sesta word in memoria, con
offset=0xBAC014
28. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Load word (2/2)
Example
Codice MIPS per caricare in $t la sesta word in memoria, con
offset=0xBAC014
addi $s, $0, 24
lw $t, 0xBAC014($s)
29. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Store word
sw
Alto livello: MEM[$s + offset] = $t
Assembly: sw $t, offset($s)
Macchina: 0x2B $s $t $s + offset
Example
Codice MIPS per scrivere nella settima word in memoria con
offset=0xBAC014 il valore di $t
30. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Store word
sw
Alto livello: MEM[$s + offset] = $t
Assembly: sw $t, offset($s)
Macchina: 0x2B $s $t $s + offset
Example
Codice MIPS per scrivere nella settima word in memoria con
offset=0xBAC014 il valore di $t
addi $s, $0, 28
sw $t, 0xBAC014($s)
31. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Branch on equal
beq
Alto livello: if ($s == $t) goto C
Assembly: beq $s,$t, C
Macchina: 0x4 $s $t C
Example
# se $s1 ` uguale a $s2, li sottraggo; altrimenti li
e
sommo.
beq $s1, $s2, L1
add $t1, $s1, $s2
L1: sub $t1, $s1, $s2
32. MIPS & SPIM
Codifica istruzioni MIPS
I-format
Branch on not equal
bne
Alto livello: if ($s != $t) goto C
Assembly: bne $s,$t, C
Macchina: 0x5 $s $t C
Example
# se $s1 ` diverso a $s2, li sommo; altrimenti li
e
sottraggo.
bne $s1, $s2, L1
sub $t1, $s1, $s2
L1: add $t1, $s1, $s2
34. MIPS & SPIM
Codifica istruzioni MIPS
J-format
Unconditional jump
jump
Alto livello: goto C
Assembly: j C
Macchina: 0x2 C
Example
# goto L1
j L1
...
L1: ...
35. MIPS & SPIM
Codifica istruzioni MIPS
J-format
Esercizi (1/2)
Massimo
Scrivere una procedura MIPS per il possibile codice dell’istruzione
max $v0, $a0, $a1.
36. MIPS & SPIM
Codifica istruzioni MIPS
J-format
Esercizi (1/2)
Massimo
Scrivere una procedura MIPS per il possibile codice dell’istruzione
max $v0, $a0, $a1.
slt $t0, $a0, $a1
beq $t0, $0, L1
addi $v0, $a1, 0
L1: addi $v0, $a0, 0
37. MIPS & SPIM
Codifica istruzioni MIPS
J-format
Esercizi (2/2)
Minimo
Scrivere una procedura MIPS per il possibile codice dell’istruzione
min $v0, $a0, $a1.
38. MIPS & SPIM
Codifica istruzioni MIPS
J-format
Esercizi (2/2)
Minimo
Scrivere una procedura MIPS per il possibile codice dell’istruzione
min $v0, $a0, $a1.
slt $t0, $a0, $a1
beq $t0, $0, L1
addi $v0, $a0, 0
L1: addi $v0, $a1, 0