3학년 1학기 전공/컴퓨터 구조
                
              [컴퓨터 구조] Lecture 09: Arithmetic for Computers
                시데브
                 2024. 4. 13. 12:57
              
              
            
            경희대학교 김정욱 교수님의 컴퓨터 구조 강의 내용을 기반으로 한 정리글
Arithmetic Operation

-> Integer Result는 value 형태 -> t0에 저장될 값
Addition and Subtraction


Overflow
- MIPS C compiler는 overflow exceptions 제공
 - Signed instructions: add, addi, subtract는 overflow exception 발생시킬 수 있음
 - Unsigned instructions: addu, addiu, subu는 발생 x
 
addu $t0, $t1, $t2 
xor $t3, $t1, $t2	#MSB가 다르면 t3에 음수(MSB 1), 같으면 양수(MSB 00가 저장
slt $t3, $t3, $0	#MSB가 다르면 0보다 작음 -> $t3 = 1
bne $t3, $0, No_overflow	#MSB 다르면 overflow  
xor $t3, $t0, $t1	#result integer와 operand1의 MSB가 다르면
slt $t3, $t3, $0	#t3 = 1이고
bne $t3, t0, overflow	#그러면 overflow
Multiplication


example: mul 2 & 3


Division
- Dividend = Quotient * Divisor + Remainder
 

728x90
    
    
  반응형