chapter 6 instruction set architecture 12/7/2015 1
TRANSCRIPT
![Page 1: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/1.jpg)
CHAPTER 6
Instruction Set Architecture
04/21/23
1
![Page 2: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/2.jpg)
Topics for Discussion
Instruction set architecture Stored program computer Interface between software and hardware Instructions Design principles Instructions, registers, and memory Simple instructions types and formats
04/21/23
2
![Page 3: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/3.jpg)
Where do you go from here (CSE241): Computer Organization
Is the study of major components of a modern digital computer, their organization and assembly, and the architecture and inner workings of these components.
It also deals with design principles for a good performance.
04/21/23
3
![Page 4: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/4.jpg)
Mother Board
Contains packages of integrated circuit chips (IC chips) including a processor, cache (several), memory (DRAM), connections for IO devices (networks, disks)
04/21/23
4
![Page 5: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/5.jpg)
Central Processing Unit (CPU)
Example: Intel 80386 80486PentiumMain components of a CPU are datapath and
control unitDatapath is the component of the processor that
performs (arithmetic) operationsControl is the component of the processor that
commands the datapath, memory , IO device according to instruction of the program
Cache provides but fast memory that acts as a buffer for slower /larger memory outside the chip.
04/21/23
5
![Page 6: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/6.jpg)
Instruction set Architecture
An important abstraction between hardware and software.
Lets discuss this concept.Computer operation is historically called an
instruction.Instructions stored similar to data in a
memory give rise to an important foundational concept called the stored program computer.
Lets look at MIPS: Microprocessor without Interlocked Pipelined Stages
04/21/23
6
![Page 7: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/7.jpg)
C to MIPS instruction
Design principle 1: simplicity favors regularityIn the above example: all instructions have 3 operands
04/21/23
7
![Page 8: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/8.jpg)
Register set
Where do the data get stored in the CPU?Named locations called registers? How
many? Typical small compared to memory sizes.
Registers: MIPS-32 has 32 register Denoted by s0, s1, etc. $s0, $s5Temporary registers are denoted by $t0, $t1
04/21/23
8
![Page 9: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/9.jpg)
C to MIPS instruction (Take 2 with registers)
Design principle 2: Smaller is fasterMemory available as registers is 32 in number
04/21/23
9
![Page 10: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/10.jpg)
Memory Operations
Data and instructions are stored in memory outside the CPU.
Data is loaded from memory and stored in memory.
Load word (lw)Store word (sw)32 resgiters230 words or 232 addressable locations or
bytes
04/21/23
10
![Page 11: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/11.jpg)
C language to Memory instructions
Base register concept: base register is $s3 and Offset of 32 for 8 words and offset of 48 for 12 words
04/21/23
11
![Page 12: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/12.jpg)
Instruction Types
add and sublw and swNow lets see how we can deal with a constant value
data.Consider C language statement: x = x +4Too complex:lw $t0, AddrConst($s1)add $s3,$s3,$t0Instead how about: addi $s3,$s3,4
Design principle 3: Make the common case fast. Example “addi” instead of add an constant from memory.
04/21/23
12
![Page 13: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/13.jpg)
Instruction format –R type
Can we use the same format for addi and add? Then we will Have only 11 bit constant
04/21/23
13
![Page 14: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/14.jpg)
Instruction format – I type
Design principle 4: good design demands good compromise;Keep instruction length same needing different formats ; I and R type areexamples
04/21/23
14
![Page 15: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/15.jpg)
Logical operations
Shift left Example: sll $t2,$so,4 Reg t2 = $so << 4
Shift right Example: srl $t2,$so,4 Reg t2 = $so >> 4
Bit-wise AND Example: and $t0,$t1, $t2 Reg t0 = reg t1 & reg t2
Bit-wise OR Example: or $t0,$t1,$t2 Reg $t0 = $t1 | $t2
![Page 16: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/16.jpg)
Instructions for Selection (if..else)
If (i == j) then f = g + h; else f = g – h; bne $s3,$s4, else add $s0,$s1,$s2 j doneelse: sub $s0,$s1,$s2done:
![Page 17: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/17.jpg)
Instructions for Iteration (while)
while (save[i] == k) i = i + 1;Let i be in reg $s3Let k be in reg $s5Let $t1 have the address of Save array elementLoop: sll $t1,$s3,2 add $t1,$t1$s6 lw $t0,0($t1) bne $t0,$s5,Exit addi $s3,$s3,1 j Loop
![Page 18: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/18.jpg)
Compiling C procedures
int leaf_example (int g, int h, int i, int j){ int f; f = (g + h) – (i + j); return f;}
How do you pass the parameters? How does compiler transport the parameters?
![Page 19: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/19.jpg)
Passing Parameters/arguments
Special registers for arguments: a0, a1, a2, a3Save temp register on the stackPerform operations And return valueRestore values stored on the stackJump back to return address
![Page 20: CHAPTER 6 Instruction Set Architecture 12/7/2015 1](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf7d1a28abf838c84b1d/html5/thumbnails/20.jpg)
Summary
MIPS operandsMIPS memoryMIPS Assembly languageMIPS instructions type and formatsAnd of course, the four design principles.
04/21/23
20