In Computer/컴퓨터구조

[컴퓨터구조] Arithmetic Operations | 산술 연산

팽이리 2023. 3. 23. 00:01

Arithmetic Operations | 산술 연산

덧셈과 뺄셈 - three operands(3개의 피연산자)

  • 2개의 source(소스)와 하나의 destination(목적지)이다.
add a, b, c # a get b + c //a = b + c

모든 Arithmetic Operations(산술 연산)은 다음과 같은 형태를 지닌다.

설계 원칙 1: Simplicity favors regularity.

간결성(simplicity)는 규칙성(regularity)을 선호한다.

  • 규칙성(regularity)을 이용하여 간결하게 만든다.
  • 간결성(simplicity)을 통해 더 낮은 비용으로 더 높은 성능을 제공한다.
    • 간결하게 만들어야 저렴한 가격의 기계에서도 높은 성능을 이끌어낼 수 있음.

 

Arithmetic Example

  • C Code:
f = (g + h) - (i + j);
  • Compiled MIPS code:
add t0, g, h   # temp t0 = g + h;
add t1, i, j   # temp t1 = i + j;
sub f, t0, t1   # f = t0 - t1;