Ch 3. Arithmetic for computers - (3)

최대 1 분 소요

3. Division

  • Division = ‘adder’ (subtracter) + ‘shifter’ registers
  • Positive Integer에 대해서만 고려
  • Algorithm
      If (partial remainder ≥ divisor) then
          quotient bit = 1;
          remainder = remainder - divisor;
      else
          quotient bit = 0;
      shift down next dividend bit
    
  • Ex)
    스크린샷 2022-10-09 오전 1 03 14
    • 1000 (divisor)
    • 1001010 (dividend)
    • 1001 (quotient)
    • 10 (remainder)

Division: Implementation

스크린샷 2022-10-09 오전 1 05 54

  • Final Version을 활용
  • Dividend
    • 64bits
    • Shift Right
    • Shift Left
    • register Hi
      • Remainder 저장
      • mfhi $t0
      • 32bits
    • register Lo
      • Quotient 저장
      • mflo $t1
      • 32bits

스크린샷 2022-10-09 오전 1 12 51

Division of signed number

  • Quotient
    • Dividend와 Divisor의 sign
      • 같으면 positive
      • 다르면 negative
  • Remainder
    • Dividend와 같은 sign을 가짐
  • Ex)
    • +7 / 2 = 3(Q) 1(R)
    • -7 / 2 = -3(Q) -1(R)
    • +7 / -2 = -3(Q) 1(R)
    • -7 / -2 = 3(Q) -1(R)

카테고리:

업데이트: