Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- MIPS
- DoM
- instruction
- for
- web
- Pipelining
- javascript
- Linux
- architecture
- XML
- html
- github
- CSS
- system
- php
- Java
- mysql
- control
- DB
- MacOS
- python
- function
- data structure
- react
- DATAPATH
- DS
- while
- computer
- Algorithm
- Class
Archives
- Today
- Total
YYYEJI
[MIPS] Instruction (Load, Store) 본문
728x90
① Load
Memory → Register
Ex) LW $s1, 8($s0) # $s1 ← Memory[$s0 + 8]
② Store
Register → Memory
Ex) SW $s1, 12($s0) # Memory[$s0 + 12] ← $s1
C code를 assembly code로 바꾸는 예제를 살펴보겠습니다.
C code
A[8] = a + A[8]
Assembly code
# A[0]의 주소가 $s3에 있다고 가정
# a의 값은 $s2에 있다고 가정
lw $t0, 32($s3)
# A[8]은 array의 8번째 이면서 4bytes씩 할당되어 있기 때문에 4*8위치에 있는 $s3가 됩니다.
# $t0 ← A[8]
add $t0, $s2, $t0
# $t0 ← $s0 + $t0
sw $t0, 32($s3)
# A[8] ← $t0
◡̈
'Computer architectures' 카테고리의 다른 글
[MIPS] Conditional branch Instruction (slt) (0) | 2022.09.25 |
---|---|
[MIPS] Conditional branch Instruction (BEQ, BNE) (0) | 2022.09.25 |
[MIPS] MIPS Instructions 간단하게 살펴보기 (0) | 2022.09.25 |
[MIPS] Design Principles (0) | 2022.09.24 |
[MIPS] Register Model - 2 (2) | 2022.09.24 |