Lecture 2 Number Representations 1 Number Representations Decimal
Lecture 2 Number Representations 1
Number Representations Ø Decimal 8547 = 8*103 + 5*102 + 4*101 + 7*100 Ø Common form V(D) = dn-1*10 n-1 + dn-2*10 n-2 + … + d 0*100 Ø Binary V(B) = bn-1*2 n-1 + bn-2*2 n-2 + … + b 0*20 2
Number Representations Binary to Decimal (1101)2 = 1*23 + 1*22 + 0*21 + 1*20 = 8+4+0+1 = 13 Ø Decimal to Binary Ø 2 13 2 6 1 2 3 0 2 1 1 0 1 LSB 13 = (1101)2 MSB 3
Number Representations Ø Octal (������ 8) l l l ������������ 0 ��� 7 ���� Octal digit ������� 3 bits ������� Binary number ������� Octal number ���������� Binary number ���� 3 ����������� LSB (least significant bit) Ø Example (1010111)2 = 101 010 111 = (5327)8 4
Number Representations Ø Hexadecimal (������ 16) l l ��������� 0 ��� 9 ��������� A ��� F ���� Hexadecimal ���������� 4 bits ������� Binary number ������� Hexadecimal ���������� Binary number ���� 4 ����������� LSB (least significant bit) Example (AF 25)16 = (1010 1111 0010 0101)2 5
Sign-and-magnitude Ø Sign-and-magnitude l l l ��� Binary number ������������ Decimal number ��� extra bit ������������ Extra bit �������� MSB ������������ MSB = 0 ; number is positive Ø MSB = 1 ; number is negative Ø Example Extra bit 1101 = -5 0101 = +5 Ø 6
’ 1 s complement Ø 1’s complement l l ����� negative ������������ complement �������� bit ������� MSB ���� Example 0101 = +5 1010 = -5 7
’ 2 s complement Ø 2’s complement l l ����� negative ������������ 1’s complement Example 0101 = +5 1’s complement = 1010 2’s complement = 1010 + 1 1011 = -5 8
’ 1 s complement Ø 1’s complement ����������� comparing circuit 1’s complement Ø Example 5+ -2 3 0101 + Carry bit 1101 10010 1 0011 10
’ 2 s complement Ø ����������� 2’s complement ����� comparing circuit ��������� carry bit ���������� Ø Example 5+ -2 3 0101 + 1110 10011 ignore ������� 0011 = 3 11
Arithmetic Overflow Ø Arithmetic overflow ��������������������� bit �������� overflow Ø ����� Processor ������� Overflow = Cn-1 Cn (C ��� carry bit 12
Arithmetic Overflow Ø Example c 4 c 3 c 2 c 1 7+ 2 9 0111 + 0010 1001 C 3 = 1 C 3 C 4 = 1 C 4 = 0 Overflow occurs 13
Arithmetic Overflow Ø Example c 4 c 3 c 2 c 1 -7 + 2 -5 1001 + 0010 1011 C 3 = 0 C 4 = 0 C 3 C 4 = 0 No Overflow 14
Memory locations & addresses 32 bit is 4 bytes 16
Memory locations & addresses (a) A signed integer (b) Four characters Example of encoded information in a 32 -bit word 17
Memory locations & addresses 1 byte = 8 bits Ø 1 word = 16 to 64 bits, ������ 32 bits Ø ������� byte-addressable ������ address �� Memory, ��� �byte �� 1 word ������ Memory address space Ø ����� 1 word �� 4 byte �������� word ��������� 0, 4, 8 , 16…… , 18 Ø
Big endian & Little endian (a) Big-endian assignment (b) Little-endian assignment 19
Big endian & Little endian Ø Big-endian : lower byte address �������� most significant byte (left most of the word( Ø Little-endian : higher byte address �������� most significant byte 20
Memory Operations Ø Load l Read or fetch data from a memory to a processor Ø Store l Write data from processor back to a memory 21
- Slides: 21