{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

MIPS - ABC 1 SoFar We have learnt about how numbers are...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
ABC 1 MIPS Assembly Language
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 So Far…. We have learnt about how numbers are represented in computers We have learnt Integer Representation both positive and negative IEEE 754 Floating Point Representation
Background image of page 2
3 What next? We would like to know what fundamental operations or instructions can a computer execute on these numbers
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Instruction Set Different CPUs implement different sets of instructions. The set of instructions a particular CPU implements is called Instruction Set . Goals of Instruction Set: Must be able to compute anything in a reasonable number of steps Must be implementable
Background image of page 4
5 Instruction Set Architectures Early trend was to add more and more instructions to new CPUs to do elaborate operations RISC (Reduced Instruction Set Computing) philosophy (Cocke IBM, Patterson, Hennessy, 1980s) Keep the instruction set small and simple, makes it easier to build fast hardware. Let software do complicated operations by composing simpler ones.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6 MIPS Architecture MIPS – semiconductor company that built one of the first commercial RISC architectures Used in Sony Playstation, Cisco routers, HP Laser Printers, PDAs, Nintendo, … We will study the MIPS architecture in some detail in this class Why MIPS instead of Intel 80x86? MIPS is simple, elegant. Don’t want to get bogged down in gritty details.
Background image of page 6
7 Below the Program High-level language program (in C) swap (int v[], int k) (int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp;) Assembly language program (for MIPS) swap: sll $2, $5, 2 add $2, $4,$2 lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31 Machine (object) code (for MIPS) 000000 00000 00101 0001000010000000 000000 00100 00010 0001000000100000 . . . C compiler assembler
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
8 Assembly Variables: Registers Unlike HLL like C or Java, assembly language cannot use variables Why not? Keep Hardware Simple Assembly Operands are registers limited number of special locations built directly into the hardware operations can only be performed on these! Benefit: Since registers are directly in hardware, they are very fast
Background image of page 8
9 Assembly Variables: Registers Drawback: Since registers are in hardware, there are a predetermined number of them Solution: MIPS code must be very carefully put together to efficiently use registers 32 registers in MIPS Why just 32? Smaller is faster Can be addressed using smaller number of bits Each MIPS register is 32 bits wide Groups of 32 bits called a word in MIPS
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
10 Assembly Variables: Registers Registers are numbered from 0 to 31 Each register can be referred to by number or name Number references: $0, $1, $2, … $30, $31
Background image of page 10
11 Assembly Variables: Registers By convention, each register also has a name to make it easier to code For now: $16 - $23 $s0 - $s7 (correspond to C variables) $8 - $15 $t0 - $t7 (correspond to temporary variables) Later will explain other 16 register names In general, use names to make your code more readable
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
12 C, Java variables vs. registers In C (and most High Level Languages)
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}