엔지니어가 되고 싶은 공돌이

05. Logical Operation and Branch 본문

Computer Science/Computer Architecture

05. Logical Operation and Branch

Geca 2025. 4. 24. 15:47

 

5. 1. Logical Operation Instructions

 

Logical Operations MIPS Instructions
Shift Left sll
Shift Right srl
AND and, andi
OR or, ori
NOT nor

 

 

- sll $t2, $s0, 4

0 0 16 10 4 0

 

 

- not 대신 nor을 쓰는 이유는 3개의 Operand형식을 유지하기 위해서이고,

 

  not은 1개의 Operand를 0으로 바꾸면 됩니다.

 


5. 2. Branch Instructions

 

- beq register1, register2, L1

 

  register1과 register2의 값이 같으면 L1으로 가라는 뜻.

 

- bne register1, register2, L2

 

  register1과 register2의 값이 같지 않으면 L2로 가라는 뜻.

 

- beq와 bne를 Conditional Branch라고 부릅니다.

 

 

- Conditional Branch와는 다르게, j Exit를 사용하면,

 

  무조건 해당 Layer로 가는데 이러한 명령어를 Unconditional Branch라고 부릅니다.

 

 

- slt $t0, $s3, $s4

 

  $s3 < $s4 이면 $t0를 1로, 아니면 0으로 하라는 명령어.

 

- sltu(unsigned), slti(constant)도 존재합니다.


'Computer Science > Computer Architecture' 카테고리의 다른 글

07. Compiler  (0) 2025.04.25
06. Procedure and Jumping  (0) 2025.04.24
04. Instruction Format  (0) 2025.04.23
03. Instructions - Load and Store  (0) 2025.04.22
02. Instructions - MIPS Assembly Language and Registers  (0) 2025.04.21
Comments