1. Multiplication
n-bit * m-bit = n+m bits
multiplicand(피승수) * multiplier(승수) = product(곱)
- multiplier digit 1: multiplicand 복사해서 적절한 위치에 배치
- multiplier digit 0: 적절한 위치에 0 배치
32bit * 32bit -> 64bit
mult $r, $s : r과 s를 곱하고, 그 결과를 HI and LO에 넣기
HI는 상위 32비트, LO는 하위 32비트
mfhi $d : move from hi -> to $d
mflo $d : move from low -> to $d
• Steps
1. Initial Values
2. - 1이면, Prod(곱) = Prod + Mcand(피승수)
- 0이면, No Operation
3. Shift Left Multiplicand(피승수, for proper place)
4. Shift Right Multiplier(승수, 맨 오른쪽 자리만 보면 되도록)
2. Floating Point(부동 소수점)
significand가 1이상 10미만 이면 정규화 O
S(1) / Exponent(8, 지수) / Fraction(23, 소수)
x = (-1)^s * (1+Fractions)*2^(Exponent-Bias)
S: sign bit (1이면 음수, 0이면 음수 아님)
Exponent: 실제 exponent + Bias(127)
Exponents 00000000, 11111111은 예약되어 있음
Smallest value: Exponent가 00000001
-> 실제 expo는 1-127 = -126 (더 작으면 언더플로우)
-> ±1.0 * 2^(-126)
Largest value: Exponent가 11111110
-> 실제 expo는 254-127 = 127 (더 크면 오버플로우)
-> ±2.0 * 2^(127)
Floating-Point Addition
1. exponent(지수) 큰 수 기준으로 같게 맞추기
2. significand 더하기
3. 결과값 정규화, exponent에 대한 over/underflow 체크
4. 필요하면 반올림, 재정규화