







































































Besser lernen dank der zahlreichen Ressourcen auf Docsity
Heimse Punkte ein, indem du anderen Studierenden hilfst oder erwirb Punkte mit einem Premium-Abo
Prüfungen vorbereiten
Besser lernen dank der zahlreichen Ressourcen auf Docsity
Download-Punkte bekommen.
Heimse Punkte ein, indem du anderen Studierenden hilfst oder erwirb Punkte mit einem Premium-Abo
Community
Finde heraus, welche laut den Docsity-Nutzern die besten Unis deines Landes sind
Kostenlose Leitfäden
Lade unsere Leitfäden mit Lernmethoden, Hilfen zur Angstbewältigung und von Docsity-Tutoren erstellte Tipps zum Verfassen von Haus- und Abschlussarbeiten kostenlos herunter
Einführung in MIPS Programmierung Mit Übungsaufgaben und Zusammenfassende Erklärungen für ein besseres Verständnis der Zusammenhänge
Art: Skripte
1 / 79
Diese Seite wird in der Vorschau nicht angezeigt
Lass dir nichts Wichtiges entgehen!
The MIPS Instruction Set
Stephen A. Edwards and Martha A. Kim
Columbia University
Spring 2012
Instruction Set Architectures MIPS The GCD Algorithm MIPS Registers Types of Instructions Computational Load and Store Jump and Branch Other Instruction Encoding Register-type Immediate-type Jump-type Assembler Pseudoinstructions
Higher-Level Constructs Expressions Conditionals Loops Arrays Strings & Hello World ASCII Subroutines Towers of Hanoi Example Factorial Example Memory Layout Differences in Other ISAs
00010000100001010000000000000111 00000000101001000001000000101010 00010100010000000000000000000011 00000000101001000010100000100011 00000100000000011111111111111100 00000000100001010010000000100011 00000100000000011111111111111010 00000000000001000001000000100001 00000011111000000000000000001000
beq $4, $5, 28 slt $2, $5, $ bne $2, $0, 12 subu $5, $5, $ bgez $0 - subu $4, $4, $ bgez $0 - addu $2, $0, $ jr $
00010000100001010000000000000111 00000000101001000001000000101010 00010100010000000000000000000011 00000000101001000010100000100011 00000100000000011111111111111100 00000000100001010010000000100011 00000100000000011111111111111010 00000000000001000001000000100001 00000011111000000000000000001000
beq $4, $5, 28 slt $2, $5, $ bne $2, $0, 12 subu $5, $5, $ bgez $0 - subu $4, $4, $ bgez $0 - addu $2, $0, $ jr $
gcd: beq $a0, $a1, .L slt $v0, $a1, $a bne $v0, $zero, .L subu $a1, $a1, $a b gcd .L1: subu $a0, $a0, $a b gcd .L2: move $v0, $a j $ra
al · go · rithm
a procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation; broadly : a step-by-step procedure for solving a problem or accomplishing some end especially by a computer
Merriam-Webster
John von Neumann, First Draft of a Report on the EDVAC ,
“Since the device is primarily a computer, it will have to perform the elementary operations of arithmetics most frequently. [...] It is therefore reasonable that it should contain specialized organs for just these operations.
“If the device is to be [...] as nearly as possible all purpose, then a distinction must be made between the specific instructions given for and defining a particular problem, and the general control organs which see to it that these instructions [...] are carried out. The former must be stored in some way [...] the latter are represented by definite operating parts of the device. “Any device which is to carry out long and complicated sequences of operations (specifically of calculations) must have a considerable memory.
Architecture: The interface the hardware presents to the software
Microarchitecture: The detailed implemention of the architecture
M icroprocessor without I nterlocked P ipeline S tages MIPS developed at Stanford by Hennessey et al. MIPS Computer Systems founded 1984. SGI acquired MIPS in 1992; spun it out in 1998 as MIPS Technologies.
Euclid, Elements , 300 BC.
The greatest common divisor of two numbers does not change if the smaller is subtracted from the larger.
Let’s be a little more explicit:
gcd: beq $a0, $a1, .L2 # if a = b, go to exit sgt $v0, $a1, $a0 # Is b > a? bne $v0, $zero, .L1 # Yes, goto .L
subu $a0, $a0, $a1 # Subtract b from a (b < a) b gcd # and repeat
.L1: subu $a1, $a1, $a0 # Subtract a from b (a < b) b gcd # and repeat
.L2: move $v0, $a0 # return a j $ra # Return to caller Operands: Registers, etc.
gcd: beq $a0, $a1, .L2 # if a = b, go to exit sgt $v0, $a1, $a0 # Is b > a? bne $v0, $zero, .L1 # Yes, goto .L
subu $a0, $a0, $a1 # Subtract b from a (b < a) b gcd # and repeat
.L1: subu $a1, $a1, $a0 # Subtract a from b (a < b) b gcd # and repeat
.L2: move $v0, $a0 # return a j $ra # Return to caller Labels
gcd: beq $a0, $a1, .L2 # if a = b, go to exit sgt $v0, $a1, $a0 # Is b > a? bne $v0, $zero, .L1 # Yes, goto .L
subu $a0, $a0, $a1 # Subtract b from a (b < a) b gcd # and repeat
.L1: subu $a1, $a1, $a0 # Subtract a from b (a < b) b gcd # and repeat
.L2: move $v0, $a0 # return a j $ra # Return to caller Arithmetic Instructions
gcd: beq $a0, $a1, .L2 # if a = b, go to exit sgt $v0, $a1, $a0 # Is b > a? bne $v0, $zero, .L1 # Yes, goto .L
subu $a0, $a0, $a1 # Subtract b from a (b < a) b gcd # and repeat
.L1: subu $a1, $a1, $a0 # Subtract a from b (a < b) b gcd # and repeat
.L2: move $v0, $a0 # return a j $ra # Return to caller Control-transfer instructions