SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
MIPS & SPIM




                              MIPS & SPIM
              Modulo del Corso di Architettura degli Elaboratori


                                Nicola Paoletti

                              Universit` di Camerino
                                        a
                           Scuola di Scienze e Tecnologie

                                29 Marzo 2011
                                AA 2010/2011
MIPS & SPIM
  MIPS Instruction Set




Riepilogo




      1   MIPS Instruction Set
           Istruzioni aritmetiche
           Istruzioni di trasferimento
           Esercizi
MIPS & SPIM
  MIPS Instruction Set




Tipi di istruzioni



              Aritmetico-logiche: effettuano operazioni aritmetico-logiche
              tra registri del processore (add, sub, and, or, . . . )
              Trasferimento dati: si occupano di trasferire dati tra la
              memoria e i registri del processore (lw, sw, . . . )
              Controllo e salto: questo tipo di istruzioni sono utilizzate per
              confrontare valori e per effettuare salti a particolari istruzioni
              (beq, bne, . . . )
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Riepilogo




      1   MIPS Instruction Set
           Istruzioni aritmetiche
           Istruzioni di trasferimento
           Esercizi
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Istruzioni aritmetiche


      Esempio
      add a,b,c # a=b+c
      sub a,b,c # a=b-c

      Le istruzioni aritmetiche sono ternarie (per mantenere l’hw
      semplice)

                              OPERATORE op1 op2 op3.
                                         ⇓
                             op1 = op2 OPERATORE op3

      Nota: il carattere # ` utilizzato per i commenti.
                           e
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Istruzioni aritmetiche - Esercizio




      Scrivere la seguente istruzione in linguaggio assembly MIPS
      a = (b+c) - (d-f) +g
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Istruzioni aritmetiche - Esercizio



      Scrivere la seguente istruzione in linguaggio assembly MIPS
      a = (b+c) - (d-f) +g

      Risultato
      add     x,b,c
      sub     y,d,f
      sub     x,x,y
      add     a,x,g
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Registri (1/3)



      Nelle istruzioni aritmetiche:
      Operandi ∼ Registri

      Non confondere variabili e registri:
              Variabili sono infinite
              Registri sono finiti
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Registri (2/3)

                                   32 registri



                     31




                                                       32 bit




                          0

                              $0                 $31
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Registri (3/3)


              Program Counter (PC):
                      Contiene l’indirizzo della prossima istruzione da eseguire
                      Incrementato ad ogni esecuzione di istruzione
                      Controlla il flusso del programma; viene manipolato nelle
                      istruzioni di salto condizionato/incondizionato
              32 registri general purpose:
                      Numerati da 0 a 31 ($0-$31)
                      Hanno anche nomi simbolici (convenzionali)
                      Il registro $0 contiene sempre il valore 0 (forzato via hw)
                      Hanno lunghezza 32 bit (1 word)
                      Supportano solo valori interi; valori decimali gestiti attraverso
                      istruzioni e registri floating-point.
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni aritmetiche


Registri - Convenzioni

              $at ($1), $k0 ($26), $k1 ($27) sono riservati all’assembler e
              dal sistema operativo
              $v0 ($2) $v1 ($3) sono usati per restituire i valori delle
              funzioni
              $a0 - $a3 ($4 - $7) sono usati per passare alle procedure i
              primi 4 parametri (restanti attraverso lo stack)
              $t0 - $t9 ($8 - $15, $24, $25) sono registri salvati dal
              chiamate, e servono a memorizzare valori temporanei
              $s0 - $s7 ($16 - $23) sono registri salvati dal chiamato, e sono
              duraturi (costanti)
              $ra ($31) contiene l’indirizzo di ritorno da una procedura
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Riepilogo




      1   MIPS Instruction Set
           Istruzioni aritmetiche
           Istruzioni di trasferimento
           Esercizi
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Istruzioni di trasferimento (1/4)



      Si occupano di trasferire dati dalla memoria fisica ai registri (load),
      e viceversa (store).


                                       Formato:
                            OPERATORE $registro indirizzo memoria
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Istruzioni di trasferimento (2/4)


      Example
      lw $t0, num1
      # carica la parola (load word) puntata da num1 in $t0
      sw $t0, num1
      # salva la parola (store word) in $t0 all’indirizzo
      num1
      li $v0, 4
      # carica la costante 4 in $v0 (load immediate)
      la $a0, num1
      # carica l’indirizzo (load address) num1 in $a0
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Istruzioni di trasferimento (3/4)




      Esercizio
      Procedura MIPS per memorizzare una word da num1 a num2,
      lasciando una copia in $t0
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Istruzioni di trasferimento (3/4)



      Esercizio
      Procedura MIPS per memorizzare una word da num1 a num2,
      lasciando una copia in $t0

      Risultato
      lw $t0, num1
      sw $t0, num2
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Istruzioni di trasferimento (4/4)
              La memoria fisica ` indirizzata in byte
                                 e
              Pu` essere vista come un vettore
                 o
              Le istruzioni aritmetiche richiedono che gli operandi siano
              memorizzati nei registri

      Example
      lw $s1, C($s2)
      # carica in $s1 i 32 bit (parola) all’indirizzo di
      memoria $s2 + C ($s1 := mem[$s2 + C])
      sw $s1, C’($s2)
      # salva la parola in $s1 all’indirizzo $s2 + C’
      (mem[$s2 + C’] := $s1
      Ci sono anche istruzioni per caricare/salvare double word, half
      word e singoli byte.
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


lw vs la



      Notare la          differenza tra lw e la
      Se Num1            sta alla locazione 0x10001000 e contiene 0xfffffffe (-2)
      la $a0,            Num1 # carica 0x10001000, mentre
      lw $a0,            Num1 # carica 0xfffffffe

      la si riferisce allindirizzo di Num1, mentre lw si riferisce al valore di
      Num1
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Esempio




Supponiamo di voler caricare in $s1
la sesta parola nella memoria fisica
(A[6])...
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Esempio


                                      27
                                      26
                                           word 6
                                      25
                                      24
Supponiamo di voler caricare in $s1
la sesta parola nella memoria fisica
(A[6])...
                                      3
                                       2
                                           word 0
                                       1
                                       0
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Esempio


                                      27
                                      26
Supponiamo di voler caricare in $s1        word 6
                                      25
la sesta parola nella memoria fisica
(A[6])...                             24

Soluzione
lw $s1, 24($s2) # $s2 punta
all’indirizzo del primo byte          3
in memoria - offset                     2
                                           word 0
                                       1
                                       0
MIPS & SPIM
  MIPS Instruction Set
    Istruzioni di trasferimento


Little endian & Big Endian

        Come sono memorizzati i valori nella memoria fisica? In che
        ordine?
                Little Endian: a partire dai byte meno significativi
                Big Endian: a partire dai byte pi` significativi
                                                 u
                         Registro
                         Little Endian



                     A    B        C     D                Intel x86 utilizza Little Endian
                                                          Power Architecture, ARM e
                          Big Endian
                                                          SPARC utillizzano Big Endian
                         Memoria
                                                          I processori MIPS sono in
    A      B        C     D         A    B       C    D
                                                          grado di operare con
    3      2         1    0          0   1       2    3
                                                          entrambi
         Little Endian                   Big Endian
MIPS & SPIM
  MIPS Instruction Set
    Esercizi


Riepilogo




      1   MIPS Instruction Set
           Istruzioni aritmetiche
           Istruzioni di trasferimento
           Esercizi
MIPS & SPIM
  MIPS Instruction Set
    Esercizi




      Esercizio1
      Scrivere la procedura MIPS per calcolare:

                               (x + 5 − y ) · 35
                                      3
      x e y vanno caricate dalla memoria; moltiplicazione: mul a,b,c;
      divisione: div a,b,c.

      Esercizio2
      Scrivere in assembly la seguente procedura:

                               A[4] = b + A[i]

      offset di A → $s1; b → $s2; i → $s3

Weitere ähnliche Inhalte

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Lezione2 - Mips & Spim Unicam

  • 1. MIPS & SPIM MIPS & SPIM Modulo del Corso di Architettura degli Elaboratori Nicola Paoletti Universit` di Camerino a Scuola di Scienze e Tecnologie 29 Marzo 2011 AA 2010/2011
  • 2. MIPS & SPIM MIPS Instruction Set Riepilogo 1 MIPS Instruction Set Istruzioni aritmetiche Istruzioni di trasferimento Esercizi
  • 3. MIPS & SPIM MIPS Instruction Set Tipi di istruzioni Aritmetico-logiche: effettuano operazioni aritmetico-logiche tra registri del processore (add, sub, and, or, . . . ) Trasferimento dati: si occupano di trasferire dati tra la memoria e i registri del processore (lw, sw, . . . ) Controllo e salto: questo tipo di istruzioni sono utilizzate per confrontare valori e per effettuare salti a particolari istruzioni (beq, bne, . . . )
  • 4. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Riepilogo 1 MIPS Instruction Set Istruzioni aritmetiche Istruzioni di trasferimento Esercizi
  • 5. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Istruzioni aritmetiche Esempio add a,b,c # a=b+c sub a,b,c # a=b-c Le istruzioni aritmetiche sono ternarie (per mantenere l’hw semplice) OPERATORE op1 op2 op3. ⇓ op1 = op2 OPERATORE op3 Nota: il carattere # ` utilizzato per i commenti. e
  • 6. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Istruzioni aritmetiche - Esercizio Scrivere la seguente istruzione in linguaggio assembly MIPS a = (b+c) - (d-f) +g
  • 7. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Istruzioni aritmetiche - Esercizio Scrivere la seguente istruzione in linguaggio assembly MIPS a = (b+c) - (d-f) +g Risultato add x,b,c sub y,d,f sub x,x,y add a,x,g
  • 8. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Registri (1/3) Nelle istruzioni aritmetiche: Operandi ∼ Registri Non confondere variabili e registri: Variabili sono infinite Registri sono finiti
  • 9. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Registri (2/3) 32 registri 31 32 bit 0 $0 $31
  • 10. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Registri (3/3) Program Counter (PC): Contiene l’indirizzo della prossima istruzione da eseguire Incrementato ad ogni esecuzione di istruzione Controlla il flusso del programma; viene manipolato nelle istruzioni di salto condizionato/incondizionato 32 registri general purpose: Numerati da 0 a 31 ($0-$31) Hanno anche nomi simbolici (convenzionali) Il registro $0 contiene sempre il valore 0 (forzato via hw) Hanno lunghezza 32 bit (1 word) Supportano solo valori interi; valori decimali gestiti attraverso istruzioni e registri floating-point.
  • 11. MIPS & SPIM MIPS Instruction Set Istruzioni aritmetiche Registri - Convenzioni $at ($1), $k0 ($26), $k1 ($27) sono riservati all’assembler e dal sistema operativo $v0 ($2) $v1 ($3) sono usati per restituire i valori delle funzioni $a0 - $a3 ($4 - $7) sono usati per passare alle procedure i primi 4 parametri (restanti attraverso lo stack) $t0 - $t9 ($8 - $15, $24, $25) sono registri salvati dal chiamate, e servono a memorizzare valori temporanei $s0 - $s7 ($16 - $23) sono registri salvati dal chiamato, e sono duraturi (costanti) $ra ($31) contiene l’indirizzo di ritorno da una procedura
  • 12. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Riepilogo 1 MIPS Instruction Set Istruzioni aritmetiche Istruzioni di trasferimento Esercizi
  • 13. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Istruzioni di trasferimento (1/4) Si occupano di trasferire dati dalla memoria fisica ai registri (load), e viceversa (store). Formato: OPERATORE $registro indirizzo memoria
  • 14. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Istruzioni di trasferimento (2/4) Example lw $t0, num1 # carica la parola (load word) puntata da num1 in $t0 sw $t0, num1 # salva la parola (store word) in $t0 all’indirizzo num1 li $v0, 4 # carica la costante 4 in $v0 (load immediate) la $a0, num1 # carica l’indirizzo (load address) num1 in $a0
  • 15. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Istruzioni di trasferimento (3/4) Esercizio Procedura MIPS per memorizzare una word da num1 a num2, lasciando una copia in $t0
  • 16. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Istruzioni di trasferimento (3/4) Esercizio Procedura MIPS per memorizzare una word da num1 a num2, lasciando una copia in $t0 Risultato lw $t0, num1 sw $t0, num2
  • 17. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Istruzioni di trasferimento (4/4) La memoria fisica ` indirizzata in byte e Pu` essere vista come un vettore o Le istruzioni aritmetiche richiedono che gli operandi siano memorizzati nei registri Example lw $s1, C($s2) # carica in $s1 i 32 bit (parola) all’indirizzo di memoria $s2 + C ($s1 := mem[$s2 + C]) sw $s1, C’($s2) # salva la parola in $s1 all’indirizzo $s2 + C’ (mem[$s2 + C’] := $s1 Ci sono anche istruzioni per caricare/salvare double word, half word e singoli byte.
  • 18. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento lw vs la Notare la differenza tra lw e la Se Num1 sta alla locazione 0x10001000 e contiene 0xfffffffe (-2) la $a0, Num1 # carica 0x10001000, mentre lw $a0, Num1 # carica 0xfffffffe la si riferisce allindirizzo di Num1, mentre lw si riferisce al valore di Num1
  • 19. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Esempio Supponiamo di voler caricare in $s1 la sesta parola nella memoria fisica (A[6])...
  • 20. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Esempio 27 26 word 6 25 24 Supponiamo di voler caricare in $s1 la sesta parola nella memoria fisica (A[6])... 3 2 word 0 1 0
  • 21. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Esempio 27 26 Supponiamo di voler caricare in $s1 word 6 25 la sesta parola nella memoria fisica (A[6])... 24 Soluzione lw $s1, 24($s2) # $s2 punta all’indirizzo del primo byte 3 in memoria - offset 2 word 0 1 0
  • 22. MIPS & SPIM MIPS Instruction Set Istruzioni di trasferimento Little endian & Big Endian Come sono memorizzati i valori nella memoria fisica? In che ordine? Little Endian: a partire dai byte meno significativi Big Endian: a partire dai byte pi` significativi u Registro Little Endian A B C D Intel x86 utilizza Little Endian Power Architecture, ARM e Big Endian SPARC utillizzano Big Endian Memoria I processori MIPS sono in A B C D A B C D grado di operare con 3 2 1 0 0 1 2 3 entrambi Little Endian Big Endian
  • 23. MIPS & SPIM MIPS Instruction Set Esercizi Riepilogo 1 MIPS Instruction Set Istruzioni aritmetiche Istruzioni di trasferimento Esercizi
  • 24. MIPS & SPIM MIPS Instruction Set Esercizi Esercizio1 Scrivere la procedura MIPS per calcolare: (x + 5 − y ) · 35 3 x e y vanno caricate dalla memoria; moltiplicazione: mul a,b,c; divisione: div a,b,c. Esercizio2 Scrivere in assembly la seguente procedura: A[4] = b + A[i] offset di A → $s1; b → $s2; i → $s3