Homework 3 Computer Architecture

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Phạm Hồng Đăng ITITIU19009

HOMEWORK 3 COMPUTER ARCHITECTURE


1/
• 5ED4 – 07A4 when these values represent unsigned 16-bit hexadecimal numbers:
Since the integers are unsigned, and the first integer is greater than the second, this subtraction can be
obtained directly using hexadecimal subtraction:
5ED4
– 07A4
5730
Because 4 − 4 = 0, 𝐷 − 𝐴 = 3, 𝐸 − 7 = 7, and 5 − 0 = 5.

• 5ED4 – 07A4 when these values represent signed 16-bit hexadecimal numbers stored in sign-
magnitude format:
5ED4 gives VALUE of 0101 1110 1101 0100
07A4 gives VALUE of 0000 0111 1010 0100
Therefore, 5ED4 – 07A4 = 0101 1110 1101 0100 − 0000 0111 1010 0100 = 0101 0111 0011 0000 =
5730

2/
• Calculate the product of the hexadecimal unsigned 6-bit integers 62 and 12
62hex=01100010bin
12hex=00010010bin
Interation Step Multiplier Multiplicand Product
0 Initialize 00010010 0000000001100010 0000000000000000
1 Rightmost bit = 0 00010010 0000000001100010 0000000000000000
Shift 00001001 0000000011000100 0000000000000000
2 Rightmost bit = 1 00001001 0000000011000100 0000000011000100
Shift 00000100 0000000110001000 0000000011000100
3 Rightmost bit = 0 00000100 0000000110001000 0000000011000100
Shift 00000010 0000001100010000 0000000011000100
4 Rightmost bit = 0 00000010 0000001100010000 0000000011000100
Shift 00000001 0000011000100000 0000000011000100
5 Rightmost bit = 1 00000001 0000011000100000 0000011011100100
Shift 00000000 0000110001000000 0000011011100100
6 Rightmost bit = 0 00000000 0000110001000000 0000011011100100
Shift 00000000 0001100010000000 0000011011100100
7 Rightmost bit = 0 00000000 0001100010000000 0000011011100100
Shift 00000000 0011000100000000 0000011011100100
8 Rightmost bit = 0 00000000 0011000100000000 0000011011100100
Shift 00000000 0110001000000000 0000011011100100

So, the result is 0000011011100100bin = 06E4hex

• Calculate 74 divided by 21:


74=111100
21=010001
Step Action Quotient Divisor Remainder
0 Initial Vals 000 000 010 001 000 000 000 000 111 100
1 Rem=Rem–Div 000 000 010 001 000 000 101 111 111 100
Rem<0,R+D,Q<< 000 000 010 001 000 000 000 000 111 100
Rshift Div 000 000 001 000 100 000 000 000 111 100
2 Rem=Rem–Div 000 000 001 000 100 000 111 000 011 100
Rem<0,R+D,Q<< 000 000 001 000 100 000 000 000 111 100
Rshift Div 000 000 000 100 010 000 000 000 111 100
3 Rem=Rem–Div 000 000 000 100 010 000 111 100 101 100
Rem<0,R+D,Q<< 000 000 000 100 010 000 000 000 111 100
Rshift Div 000 000 000 010 001 000 000 000 111 100
4 Rem=Rem–Div 000 000 000 010 001 000 111 110 110 100
Rem<0,R+D,Q<< 000 000 000 010 001 000 000 000 111 100
Rshift Div 000 000 000 001 000 100 000 000 111 100
5 Rem=Rem–Div 000 000 000 001 000 100 111 111 111 000
Rem<0,R+D,Q<< 000 000 000 001 000 100 000 000 111 100
Rshift Div 000 000 000 000 100 010 000 000 111 100
6 Rem=Rem–Div 000 000 000 000 100 010 000 000 011 010
Rem>0,Q<<1 000 001 000 000 100 010 000 000 011 010
Rshift Div 000 001 000 000 010 001 000 000 011 010
7 Rem=Rem–Div 000 001 000 000 010 001 000 000 001 001
Rem>0,Q<<1 000 011 000 000 010 001 000 000 001 001
Rshift Div 000 011 000 000 001 000 000 000 001 001

Result:
Quotient = 000 011 = 3
Remainder = 001 001 = 11
74/21 3 remainder 9

3/

• 0×0C000000 represent if it is a two’s complement integer: 201326592


• 0×0C000000 represent if it is an unsigned integer: 201326592
• 0×0C000000 is placed into the Instruction Register, MIPS instruction will be executed: jal
0x00000000
• IEEE 754 standard:
+ 0×0C000000:
Convert to binary: 0×0C000000 = 0000 1100 0000 0000 0000 0000 0000 0000
sign is positive
exp = 0×18 = 24 -127 = -103
there is a hidden 1
mantissa = 0
answer = 1.0×2-103
+ 0x172E783A:
Convert to binary: 0x172E783A = 00010111001011100111100000111010
S=0
Exp = 00101110 = 4610
Frac = 01011100111100000111010
answer = (-1)s.(1+frac).2exp-127 =1,01011100111100000111010x2-81
+ 0x0A34848F:
Convert to binary: 0x0A34848F = 1010001101001000010010001111
S=1
Exp = 01000110 = 7010
Frac = 1001000010010001111
answer = (-1)s.(1+frac).2exp-127 = -1,1001000010010001111x2-57
4/
• single precision fomat:
o 63.25x100 =111111.01x20
normalize, move binary point 5 to the left
1.1111101x25
sign =positive, exp =127+5=132
Final bit pattern: 0 1000 0100 1111 1010 0000 0000 0000 000
= 0100 0010 0111 1101 0000 0000 0000 0000 = 0x427D0000
o 30.5438x10^5
Sign = positive
Exp = 148
Final bit pattern: 01001010001110100110110010110000 = 0x4A3A6CD0
o 43.374x10–4
Sign = positive
Exp = 119
Final bit pattern: 00111011100011100010000011000000 = 0x3B8E20C0
• double precision format:
o 63.25x100 = 111111.01x20
normalize, move binary point 5 to the left
1.1111101x25
sign = positive, exp = 1023+5=1028
Final bit pattern:
0 100 0000 0100 1111 1010 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
= 0x404FA00000000000
o 30.5438x10^5
Sign = positive
Exp = 1044
Final bit pattern:
0100000101000111010011011001011000000000000000000000000000000000
= 0x41474D9600000000
o 43.374x10^–4
Sign = positive
Exp = 1015
Final bit pattern:
0011111101110001110001000001011111110010011001010000110011001010
= 0x3F71C417F2650CCA

5/
• 2.6125x101 + 4.150390625x101
2.6125x101 = 26.125 = 11010.001 = 1.1010001000x24
4.150390625x101 = .4150390625 = .011010100111 = 1.1010100111x2-2
Shift binary point 6 to the left to align exponents,
GR
1.1010001000 00
1.0000011010 10 0111 (Guard 5 1, Round 5 0, Sticky 5 1)
1.1010100010 10
In this case the extra bit (G,R,S) is more than half of the least signifi cant bit (0).
Thus, the value is rounded up.
1.1010100011x24 = 11010.100011x20 = 26.546875 = 2.6546875x101

• -8.0546875 x -1.79931640625x10-1
-8.0546875 = -1.0000000111x23
-1.79931640625x101 = -1.0111000010x2-3
Exp: -3 + 3 = 0, 0 + 16 = 16 (10000)
Signs: both negative, result positive Fraction:
1.0000000111
x 1.0111000010
00000000000
10000000111
00000000000
00000000000
00000000000
00000000000
10000000111
10000000111
10000000111
00000000000
10000000111
1.01110011000001001110

1.0111001100 00 01001110
Guard = 0,
Round = 0,
Sticky = 1:NoRnd
1.0111001100x20 = 0100000111001100 (1.0111001100 = 1.44921875)
-8.0546875 x .179931640625 = 1.4492931365966796875

You might also like