


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to the concept of bits and bytes, explaining why computers use binary representations instead of base 10, and discussing the electronic implementation and memory organization of binary data. It also covers the encoding of byte values and machine words, as well as the representation of integers, pointers, floats, and strings.
Typology: Exams
1 / 34
This page cannot be seen from the preview
Don't miss anything!



























l Binary/Hexadecimal l Byte representations » numbers » characters and strings » Instructions
l Boolean algebra l Expressing in C
class02.ppt 15-213 F’
l Floating point number cannot exactly represent $1.
l 1.5213 X 10^4
l ENIAC (First electronic computer) used 10 vacuum tubes / digit
l Need high precision to encode 10 signal levels on single wire
l Addition, multiplication, etc.
l SRAM, DRAM, disk l Only allocate for regions actually used by program
l Program being executed l Program can clobber its own data, but not that of others
l Base 16 number representation l Use characters ‘0’ to ‘9’ and ‘A’ to ‘F’ l Write FA1D37B 16 in C as 0xFA1D37B » Or 0xfa1d37b
HexDecimalBinary
32-bit Words
Bytes Addr.
64-bit Words
Addr = ??
Addr = ??
Addr = ??
Addr = ??
Addr = ??
Addr = ??
0000
0004
0008
0012
0000
0008
l int 4 4 4 l long int 8 4 4 l char 1 1 1 l short 2 2 2 l float 4 4 4 l double 8 8 8 l long double 8 8 10/ l char * 8 4 4 » Or any other pointer
0x100 0x101 0x102 0x 01 23 45 67
0x100 0x101 0x102 0x 67 45 23 01
Big Endian
Little Endian
Address Instruction Code Assembly Rendition 8048365: 5b pop %ebx 8048366: 81 c3 ab 12 00 00 add $0x12ab,%ebx 804836c: 83 bb 28 00 00 00 00 cmpl $0x0,0x28(%ebx)
int a = 15213; printf("int a = 15213;\n"); show_bytes((pointer) &a, sizeof(int));
int a = 15213; 0x11ffffcb8 0x6d 0x11ffffcb9 0x3b 0x11ffffcba 0x 0x11ffffcbb 0x
Decimal: 15213 Binary: 0011 1011 0110 1101 Hex: 3 B 6 D
Linux/Alpha A
Sun A
Linux/Alpha B
Sun B
Two’s complement representation (Covered next lecture)
Alpha C
Sun C 6D 3B 00 00
Linux C
IEEE Single Precision Floating Point Representation Hex: 4 6 6 D B 4 0 0 Binary: 0100 0110 0110 1101 1011 0100 0000 0000 15213: 1110 1101 1011 01
Not same as integer representation, but consistent across machines
Linux/Alpha F
Sun F
Can see some relation to integer representation, but not obvious
IEEE Single Precision Floating Point Representation Hex: 4 6 6 D B 4 0 0 Binary: 0100 0110 0110 1101 1011 0100 0000 0000 15213: 1110 1101 1011 01
IEEE Single Precision Floating Point Representation Hex: 4 6 6 D B 4 0 0 Binary: 0100 0110 0 110 1101 1011 0100 0000 0000 15213: 1110 1101 1011 01
l Standard 7-bit encoding of character set l Other encodings exist, but uncommon l Character “0” has code 0x » Digit i has code 0x30 + i
l Final character = 0
l Data are single byte quantities
l Except for different conventions of line termination character(s)!
Linux/Alpha S Sun S
Different machines use totally different instructions and encodings
Alpha sum
Sun sum
l Use differing numbers of instructions in other cases
l Same for NT and for Linux l NT / Linux not fully binary compatible
PC sum
l Encode “True” as 1 and “False” as 0