![Page 1: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/1.jpg)
Σελ. 1Δρ. Πέτρος Παναγή
Introduction intoMIPS Assembly Language
Dr. Petros Panayi
From Appendix Aof
Computer Organization and Design
![Page 2: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/2.jpg)
Σελ. 2Δρ. Πέτρος Παναγή
MIPS Arithmetic - Registers
![Page 3: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/3.jpg)
Σελ. 3Δρ. Πέτρος Παναγή
MIPS Arithmetic – Instruction Format
pseudoinstructions, appear as real instructions in assembly language programs. The hardware, however, knows nothing about pseudoinstructions, so the assembler translates them into equivalent sequences of actual machine instructions.
![Page 4: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/4.jpg)
Σελ. 4Δρ. Πέτρος Παναγή
Program sample#############################################################################Program Name : Read three integers from the user and check there status#Programmer : Petros Panayi Stud. ID:000000#Date Last Modif.: 7 Sep 2006############################################################################## Comments: This program requests three integers from the user and # prints on the console if they are positive, negative or zero#############################################################################
.data # data segmentquestion: .asciiz "Please enter an Integer value:"confimation_msg: .asciiz "Your values are "comma: .asciiz ", "##############################################################################
.text # text segment
.globl mainmain:
# διάβασε τρεις ακεραίους στο $t0, $t1 και $t2la $a0, question # Μήνυμα για είσοδο ακεραίου
li $v0, 4 # κώδικας συστήματος για τύπωση συμβολοσειράς...
# 7. Έξοδοςli $v0, 10 # Κλίση συστήματος εξόδου(exit system call)syscall
![Page 5: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/5.jpg)
Σελ. 5Δρ. Πέτρος Παναγή
PCSPIM System Calls = Operating-System-like services
$v0
![Page 6: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/6.jpg)
Σελ. 6Δρ. Πέτρος Παναγή
MIPS Arithmetic – Addition
![Page 7: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/7.jpg)
Σελ. 7Δρ. Πέτρος Παναγή
MIPS Arithmetic – Logic Operations
![Page 8: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/8.jpg)
Σελ. 8Δρ. Πέτρος Παναγή
MIPS Arithmetic – Multiplication
![Page 9: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/9.jpg)
Σελ. 9Δρ. Πέτρος Παναγή
MIPS Arithmetic - Division
![Page 10: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/10.jpg)
Σελ. 10Δρ. Πέτρος Παναγή
MIPS Shifting
![Page 11: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/11.jpg)
Σελ. 11Δρ. Πέτρος Παναγή
MIPS Loading Data
![Page 12: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/12.jpg)
Σελ. 12Δρ. Πέτρος Παναγή
MIPS Loading Data
![Page 13: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/13.jpg)
Σελ. 13Δρ. Πέτρος Παναγή
MIPS Moving Data Between Registers
![Page 14: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/14.jpg)
Σελ. 14Δρ. Πέτρος Παναγή
MIPS - Memory OrganizationBytes are nice, but most data items use larger "words"For MIPS, a word is 32 bits or 4 bytes.
232 bytes with byte addresses from 0 to 232-1230 words with byte addresses 0, 4, 8, ... 232-4Words are aligned
i.e., what are the least 2 significant bits of a word address?
048
12...
32 bits of data
32 bits of data
32 bits of data
32 bits of data
Registers hold 32 bits of data
![Page 15: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/15.jpg)
Σελ. 15Δρ. Πέτρος Παναγή
MIPS Branching
![Page 16: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/16.jpg)
Σελ. 16Δρ. Πέτρος Παναγή
MIPS Branching
![Page 17: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/17.jpg)
Σελ. 17Δρ. Πέτρος Παναγή
MIPS Jump
PC = target*4 or target <<2
The last two are used mainly in procedures call
![Page 18: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/18.jpg)
Σελ. 18Δρ. Πέτρος Παναγή
Άσκηση 1:
• Γράψετε ένα απλό πρόγραμμα που να διαβάζει από το πληκτρολόγιο ένα ακέραιο αριθμό Ν και να εκτυπώνει στην οθόνη το όνομα σας Ν φορές.
![Page 19: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/19.jpg)
Σελ. 19Δρ. Πέτρος Παναγή
MIPS - Procedures
![Page 20: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/20.jpg)
Σελ. 20Δρ. Πέτρος Παναγή
MIPS – Loop Example 1/2
![Page 21: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/21.jpg)
Σελ. 21Δρ. Πέτρος Παναγή
MIPS – Loop Example 2/2
![Page 22: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/22.jpg)
Σελ. 22Δρ. Πέτρος Παναγή
MIPS - Procedures
![Page 23: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/23.jpg)
Σελ. 23Δρ. Πέτρος Παναγή
MIPS - ProceduresThe stack frame consists of the memory between the frame pointer ($fp), which points to the first word of the frame, and the stack pointer ($sp), which points to the last word of the frame. The stackgrows down from higher memory addresses, so the frame pointer points above the stack pointer.The executing procedure uses the frame pointer to quicklyaccess values in its stack frame.
![Page 24: Introduction into MIPS Assembly Language Dr. Petros Panayi ... · MIPS Arithmetic – Instruction Format pseudoinstructions, appear as real instructions in assembly language programs](https://reader030.vdocuments.site/reader030/viewer/2022040712/5e1769259b8a7664db36123b/html5/thumbnails/24.jpg)
Σελ. 24Δρ. Πέτρος Παναγή
MIPS Arithmetic