Computer Science/Computer Architecture

[컴퓨터구조] Lecture 09: Arithmetic for Computers - Part1

kangkyunghyun 2026. 2. 8. 16:22
728x90
반응형

경희대학교 김정욱 교수님의 컴퓨터구조 강의를 기반으로 정리한 글입니다.

Arithmetic Operation

  • Status: Overflow가 일어났는지 아닌지 체크
  • Integer Result: value ($t0 에 저장될 값)

Overflow

Addition

  • 두 부호가 같으면 overflow가 일어날 수 있음
  • 두 부호가 다르면 overflow가 일어날 수 없음

Subtraction

  • 두 부호가 같으면 overflow가 일어날 수 없음
  • 두 부호가 다르면 overflow가 일어날 수 있음

Overflow Detection

  • MIPS C compiler는 overflow exceptions 제공
  • Signed instructions: add, addi, subtract는 overflow exception을 발생시킬 수 있음
  • Unsigned instructions: addu, addiu, subu는 발생 x

Multiplication

  • Product를 0으로 초기화
  • Multiplier LSB가 1이면 Multiplicand를 Product에 추가
  • Multiplier LSB가 0이면 아무 일 X
  • Multiplicand Shift left
  • Multiplier Shift right

bit 수만큼 연산

Division

 

  • Remainder를 Dividend로 초기화
  • Divisor에 앞에부터 채워서 초기화
  • Remainder에서 Divisor를 한 번 빼봄 → 음수면 되돌림, Quotient Shift left 후 LSB에 0 추가 → 양수면 Quotient Shift left 후 LSB에 1 추가
  • Divisor Shift right

bit 수 + 1만큼 연산

728x90
반응형