일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- php
- Pipelining
- MacOS
- mysql
- architecture
- DoM
- react
- DB
- system
- web
- CSS
- javascript
- python
- DS
- control
- instruction
- XML
- Java
- Class
- data structure
- DATAPATH
- while
- github
- computer
- function
- MIPS
- html
- Algorithm
- Linux
- for
- Today
- Total
YYYEJI
[MIPS] Three MIPS Instruction Format 본문
MIPS에는 3개의 instruction format이 있습니다.
① R type - 6field
② I type - 4field
③ J type - 2 field
Instruction format을 살펴보기 전에 용어부터 살펴봅시다.
R type에서는
✓ op - operation code (opcode)
✓ rs - first source operand
✓ rt - second source operand
✓ rd - destination operand
✓ shamt - shift amount
✓ funct - funcion code
I type에서는
✓ op - operation code (opcode)
✓ rs - source operand
✓ rt - destination operand
다음으로는 binary code를 보고 machine이 어떻게 코드를 분석하는지 보겠습니다.
✓ op code를 보고 instruction의 format을 파악합니다.
opcode가 0이면 R type, 아니면 I-type
✓ R-type이면 function code를 보고 instruction을 파악하고,
rs, rt, rd 를 보고 source와 destination을 파악합니다.
✓ I-type이면 opcode를 보고 instruction을 파악하고,
rs, rt, constant를 보고 파악합니다.
✓ J-type은 opcode가 2 또는 3 입니다.
① R type
✓ R type의 opcode는 항상 0
✓ opcode로 r type임을 확인하고 function code로 instruction을 파악하기
op (6bits) | rs (5bits) | rt (5bits) | rd (5bits) | shamt (5bits) | funct (6bits) |
↑↑↑ R type instruction format ↑↑↑
EX) add $t0, $s1, $s2
0 | 17 | 18 | 8 | 0 | 32 |
000000 | 10001 | 10010 | 01000 | 00000 | 100000 |
Binary: 000000 10001 10010 01000 00000 100000
Hexadecimal: 0x02324020
Decimal에서 binary로 바꾸고 binary에서 hexadecimal로 바꿉니다.
② I type
✓ opcode가 0이 아니면 i or j type
✓ opcode의 number을 보고 i인지 j인지 파악하기
✓ function code를 보고 instruction을 파악하기
op (6bits) | rs (5bits) | rt (5bits) | constant or address (16bits) |
↑↑↑ I type instruction format ↑↑↑
Ex) LW $s0, 32($s1)
35 | 17 | 16 | 32 (constant) |
Binary: 100011 01001 01000 0000 0000 0010 0000
Binary: 100011 01001 01000 0000 0000 00 10 0000
Hexadecimal: 0x8D280020
Ex) SW $s0, 12($s1)
43 | 17 | 16 | 12 (constant) |
Binary: 101011 01001 01000 0000 0000 0000 1100
Binary: 101011 01001 01000 0000 0000 0000 1100
Hexadecimal: 0xAD2000C
Ex) ADDI $s0, $s1, 4
8 | 17 | 16 | 4 (constant) |
Binary: 000100 01001 01000 0000 0000 0000 0100
Binary: 000100 01001 01000 0000 0000 0000 0100
Hexadecimal: 0x11280004
③ J type
✓ opcode가 0이 아니면 i or j type
✓ opcode가 2이면 j type
op (4bits) | jump address (word address) |
◡̈
'Computer architectures' 카테고리의 다른 글
[MIPS] Stored program Concept (0) | 2022.10.10 |
---|---|
[MIPS] Format instruction identification (0) | 2022.10.10 |
[MIPS] MIPS Instruction Summary (0) | 2022.10.10 |
[MacOS] MIPS assembly language 알아보기 (0) | 2022.10.08 |
[MacOS] QtSpim 사용하기 (0) | 2022.10.07 |