Computer Engineering Department. Computer Arithmetic Lecture 8. Number Representation. Binary numbers (base 2) - integers 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 . . . in decimal from 0 to 2 n -1 for n bits.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 . . .
in decimal from 0 to 2n-1 for n bits
0 ten is in MIPS
0000 0000 0000 0000 0000 0000 0000 0000two
Bit 31 (most significant bit) Bit 3 Bit 0
Thus the largest (unsigned) number is
1111 1111 1111 1111 1111 1111 1111 1111two or
4,294,967,295 ten = 232 -1
CA&O Lecture 8 By Engr. Umbreen sabir
conventions define the relationships between bits and numbers
1111 1111 1111 1111 1111 1111 1111 1111two is
-1ten
is 1000 0000 0000 0000 0000 0000 0000 0000two
to 231-1 (2,147,483,647)
CA&O Lecture 8 By Engr. Umbreen sabir
0000 0000 0000 0000 0000 0000 0000 0011two = 3ten
1111 1111 1111 1111 1111 1111 1111 1101two = -3ten
0000 0000 0000 0000 0000 0000 0000 0000two = 3ten -3ten = 0
CA&O Lecture 8 By Engr. Umbreen sabir
1111 1111 1111 1111 1111 1110 0000 1100two
0000 0000 0000 0000 0000 0001 1111 0011two
1
0000 0000 0000 0000 0000 0001 1111 0100two
(x31 -231)+(x30 230)+…+(x1 21)+(x0 20)
128 + 127 + 126 + 125 + 124 + 122 = =256+128+64+32+16+4=500
CA&O Lecture 8 By Engr. Umbreen sabir
CA&O Lecture 8 By Engr. Umbreen sabir
0 rs rt rd 0 42
Sign bit 31 magnitude bits
Sign bit
10 rs rt constant
11 constant
More instructionsCA&O Lecture 8 By Engr. Umbreen sabir
25
20
15
5
0
R-type:
op
Rs
Rt
Rd
funct
I-Type:
op
Rs
Rt
MIPS Arithmetic and Logic InstructionsImmed 16
INST op funct
ADDI 001000 xx
addiu 001001 xx
SLTI 001010 xx
sltiu 001011 xx
ANDI 001100 xx
ORI 001101 xx
XORI 001110 xx
LUI 001111 xx
INST op funct
ADD 000000 100000
addu 000000 100001
SUB 000000 100010
subu 000000 100011
AND 000000 100100
OR 000000 100101
XOR 000000 100110
NOR 000000 100111
INST op funct
000000 101000
000000 101001
SLT 000000 101010
sltu 000000 101011
000000 101100
CA&O Lecture 8 By Engr. Umbreen sabir
00… 00100 (410)
+00… 00100 (410)
00… 01000 (810)
00… 00100 (410)
- 00… 00011 (310)
00… 00100 (410) + 11… 11101(-310)00… 00001 (110)
CA&O Lecture 8 By Engr. Umbreen sabir
CA&O Lecture 8 By Engr. Umbreen sabir
because unsigned numbers are used for addresses
CA&O Lecture 8 By Engr. Umbreen sabir
CA&O Lecture 8 By Engr. Umbreen sabir
addu $t2, $t3, $t4
sltu $t2, $t2, $t4
addu $t2, $t3, $t4
sltu $t2, $t2, $t3
CA&O Lecture 8 By Engr. Umbreen sabir
addu $t3, $t5, $t7 (least signif. 32 bits)
sltu $t2, $t3, $t5 #$t2 holds 0s
addu $t2, $t2, $t4
addu $t2, $t2, $t6
addu $t3, $t5, $t7 (least signif. 32 bits)
sltu $t2, $t3, $t5 #$t2 holds 0s
add $t2, $t2, $t4
add $t2, $t2, $t6 (or add $t2, $t4, $t6)
CA&O Lecture 8 By Engr. Umbreen sabir
a•b
a+b
Arithmetic Logic Unit (ALU)CA&O Lecture 8 By Engr. Umbreen sabir
a
+
Sum
b
carry_out
1-bit Binary AdderSum = Σminterms = a’b’c + a’bc’ + ab’c’ +a’bc’
carry_out = ab+ac+bc
CA&O Lecture 8 By Engr. Umbreen sabir
operation
a • b
a &b, a|b, a+b, 0
3
1-bit Binary AdderCA&O Lecture 8 By Engr. Umbreen sabir
Subtraction is same as
adding negative b thus
Binvert goes Hi,
and CarryIn is 1
Less
Set
Overflow
detection
Overflow
This is the MSB ALU Cell
CA&O Lecture 8 By Engr. Umbreen sabir
O
O
Bininvert
Operation
CarryIn
Modifying the ALU for sltSet
Overflow
CA&O Lecture 8 By Engr. Umbreen sabir
Operation
Modifying the ALU for beqOutput Zero goes Hi for equality
CA&O Lecture 8 By Engr. Umbreen sabir