일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- XML
- MacOS
- javascript
- php
- web
- html
- computer
- data structure
- DB
- mysql
- for
- control
- python
- react
- Linux
- architecture
- github
- Pipelining
- DoM
- Java
- function
- CSS
- MIPS
- instruction
- DS
- system
- while
- Class
- Algorithm
- DATAPATH
- Today
- Total
YYYEJI
[MIPS] LUI instruction 본문
LUI란?
Load upper immediate instruction의 줄임말로써,
16bits보단 크고 32bits 보단 작은 상수를 어떻게 표현하냐에 대한 대답입니다.
LUI $t0, 255
001111 | 00000 | 01000 | 0000 0000 1111 1111 |
↓
0000 0000 1111 1111 | 0000 0000 0000 0000 |
↑ Upper ↑ ↑ Lower ↑
이렇게 표현됩니다.
예제를 통해 더 자세히 알아봅시다.
Q) What is MIPS assembly code for 32-bit constant "0x003D 0900" into $s0?
↓↓↓ solution ↓↓↓
LUI $t0, 0x003D
ORI $s0, $t0, 0x0900
LUI 수행 없이 ORI를 실행시키면 상수가 덮어씌어 집니다.
그렇기 때문에 0x003D를 먼저 upper에 넣어주고 0x0900을 ori 수행 시켜줘야 됩니다.
그러면 상수가 덮어지지 않고 잘 저장됩니다.
LUI | 003D 0000 | 0000 0000 |
ORI | 0000 0000 | 0000 0900 |
----------------------------------------------------------------------------------------------------------------------
003D 0000 | 0000 0900 |
Sign Extension vs Zero Extension
Sign Extension
✓ Arithmetic에 사용됩니다.
✓ sign bit이 0(positive)이면 upper part를 0으로 채우고,
sign bit이 1(negative)이면 upper part를 1로 채웁니다.
Zero Extension
✓ Logic에 사용됩니다.
✓ upper을 0으로 채웁니다.
◡̈
'Computer architectures' 카테고리의 다른 글
[MIPS] Addressing mode (0) | 2022.10.10 |
---|---|
[MIPS] Pseudo Instructions (0) | 2022.10.10 |
[MIPS] Stored program Concept (0) | 2022.10.10 |
[MIPS] Format instruction identification (0) | 2022.10.10 |
[MIPS] Three MIPS Instruction Format (0) | 2022.10.10 |