일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- DATAPATH
- DS
- php
- control
- github
- data structure
- Java
- while
- Algorithm
- Linux
- instruction
- CSS
- system
- computer
- function
- python
- XML
- mysql
- react
- MacOS
- MIPS
- javascript
- architecture
- for
- web
- DB
- Pipelining
- html
- DoM
- Class
- Today
- Total
YYYEJI
[MIPS] Conditional branch Instruction (slt) 본문
BEQ와 BNE로 같다(==)와 다르다(!=)라는 수식을 사용할 수 있지만
작다(<), 크다(>) 등은 어떻게 표현할 수 있을까요 ?
그렇게 MIPS에서 특별하게 만들어진 새로운 instruction이 있습니다.
바로 slt instruction 입니다.
(Set less than)
Ex 1) slt $t0, $s1, $s2 # if $s1<$s2 then $t0 = 1
else $t0 = 0
($s1와 $s2 비교해서 같으면 $t0를 1로 set하고 다르면 $t0를 0으로 clear한다.)
Ex 2) slt rd, rs, rt # rt = (rs<rt) ? 1 : 0
slt - set less than instruction
rd - destination
rs, rt - source
rs와 rt를 비교해서 같으면 1로 set, 다르면 0으로 clear한다.
Set Less Than - R type 일 때
SLT $s1, $s2, $s3 : if ($s2<$s3) $s1 ← 1 else $s1 ← 0
op = 0 | rs = 18 | rt = 19 | rd = 17 | shamt = 0 | func = 42 |
(R-type에서 op code는 항상 0)
Set Less Than immediate - I type 일 때
SLTI $s1, $s2, 100 : if ($s2<100) $s1 ← 1 else $s1 ← 0
op = 10 | rs = 17 | rt = 18 | constant = 100 |
(I-type에서 SLTI instruction은 op code 10)
이 외의도 만들어진 instruction의 set이 있습니다.
① bgt - banch if greater than
② bge - branch if greater thean or equal
③ blt - branch if less than
④ ble - branch if less than or equal
etc.
◡̈
'Computer architectures' 카테고리의 다른 글
[MIPS] Control Instruction (2) | 2022.09.25 |
---|---|
[MIPS] Unconditional Branch Instructions (Jump etc.) (2) | 2022.09.25 |
[MIPS] Conditional branch Instruction (BEQ, BNE) (0) | 2022.09.25 |
[MIPS] Instruction (Load, Store) (0) | 2022.09.25 |
[MIPS] MIPS Instructions 간단하게 살펴보기 (0) | 2022.09.25 |