DOC PREVIEW
CMU CS 15213 - Bits, Bytes, and Integers

This preview shows page 1-2-3-4-5-37-38-39-40-41-42-75-76-77-78-79 out of 79 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 79 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Carnegie Mellon Bits Bytes and Integers 15 213 Introduction to Computer Systems 2nd Lecture Aug 26 2010 Instructors Randy Bryant and Dave O Hallaron 1 Carnegie Mellon Today Bits Bytes and Integers Representing information as bits Bit level manipulations Integers Representation unsigned and signed Conversion casting Expanding truncating Addition negation multiplication shifting Summary 2 Carnegie Mellon Binary Representations 0 1 0 3 3V 2 8V 0 5V 0 0V 3 Carnegie Mellon Encoding Byte Values Byte 8 bits Binary 000000002 to 111111112 Decimal 010 to 25510 Hexadecimal 0016 to FF16 Base 16 number representation Use characters 0 to 9 and A to F Write FA1D37B16 in C as 0xFA1D37B 0xfa1d37b al y i m ar c x n He De Bi 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111 4 Carnegie Mellon Byte Oriented Memory Organization 0 0 0 F F F Programs Refer to Virtual Addresses Conceptually very large array of bytes Actually implemented with hierarchy of different memory types System provides address space private to particular process Program being executed Program can clobber its own data but not that of others Compiler Run Time System Control Allocation Where different program objects should be stored All allocation within single virtual address space 5 Carnegie Mellon Machine Words Machine Has Word Size Nominal size of integer valued data Including addresses Most current machines use 32 bits 4 bytes words Limits addresses to 4GB Becoming too small for memory intensive applications High end systems use 64 bits 8 bytes words Potential address space 1 8 X 1019 bytes x86 64 machines support 48 bit addresses 256 Terabytes Machines support multiple data formats Fractions or multiples of word size Always integral number of bytes 6 Carnegie Mellon Word Oriented Memory Organization Addresses Specify Byte Locations Address of first byte in word Addresses of successive words differ 32 bit 64 bit Words Words Addr 0000 by 4 32 bit or 8 64 bit Addr 0004 Addr 0008 Addr 0012 Addr 0000 Addr 0008 Bytes Addr 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 7 Carnegie Mellon Data Representations Typical 32bit Intel IA32 x86 64 char 1 1 1 short 2 2 2 int 4 4 4 long 4 4 8 long long 8 8 8 float 4 4 4 double 8 8 8 long double 8 10 12 10 16 pointer 4 4 8 C Data Type 8 Carnegie Mellon Byte Ordering How should bytes within a multi byte word be ordered in memory Conventions Big Endian Sun PPC Mac Internet Least significant byte has highest address Little Endian x86 Least significant byte has lowest address 9 Carnegie Mellon Byte Ordering Example Big Endian Least significant byte has highest address Little Endian Least significant byte has lowest address Example Variable x has 4 byte representation 0x01234567 Address given by x is 0x100 Big Endian 0x100 0x101 0x102 0x103 01 Little Endian 23 45 67 0x100 0x101 0x102 0x103 67 45 23 01 10 Carnegie Mellon Reading Byte Reversed Listings Disassembly Text representation of binary machine code Generated by program that reads the machine code Example Fragment Address 8048365 8048366 804836c Instruction Code 5b 81 c3 ab 12 00 00 83 bb 28 00 00 00 00 Assembly Rendition pop ebx add 0x12ab ebx cmpl 0x0 0x28 ebx Deciphering Numbers Value Pad to 32 bits Split into bytes Reverse 0x12ab 0x000012ab 00 00 12 ab ab 12 00 00 11 Carnegie Mellon Examining Data Representations Code to Print Byte Representation of Data Casting pointer to unsigned char creates byte array typedef typedef unsigned unsigned char char pointer pointer void void show bytes pointer show bytes pointer start start int int int i int i for for i i 0 0 ii len len i i printf p t0x 2x n start i printf p t0x 2x n start i printf n printf n len len start i start i Printf directives p Print pointer x Print Hexadecimal 12 Carnegie Mellon show bytes Execution Example int int aa 15213 15213 printf int printf int aa 15213 n 15213 n show bytes pointer show bytes pointer a a sizeof int sizeof int Result Linux int int aa 15213 15213 0x11ffffcb8 0x11ffffcb8 0x6d 0x6d 0x11ffffcb9 0x11ffffcb9 0x3b 0x3b 0x11ffffcba 0x11ffffcba 0x00 0x00 0x11ffffcbb 0x11ffffcbb 0x00 0x00 13 Carnegie Mellon Decimal Decimal 15213 15213 Representing Integers Binary Binary Hex Hex int A 15213 IA32 x86 64 6D 3B 00 00 Sun 00 00 3B 6D int B 15213 IA32 x86 64 93 C4 FF FF Sun FF FF C4 93 0011 0011 1011 1011 0110 0110 1101 1101 33 BB 66 D D long int C 15213 IA32 6D 3B 00 00 x86 64 6D 3B 00 00 00 00 00 00 Sun 00 00 3B 6D Two s complement representation Covered later 14 Carnegie Mellon Representing Pointers int int int int BB 15213 15213 P P B B Sun IA32 x86 64 EF D4 0C FF F8 89 FB FF EC 2C BF FF FF 7F 00 00 Different compilers machines assign different locations to objects 15 Carnegie Mellon Representing Strings Strings in C char char S 6 S 6 18243 18243 Represented by array of characters Each character encoded in ASCII format Standard 7 bit encoding of character set Character 0 has code 0x30 Digit i has code 0x30 i String should be null terminated Final character 0 Compatibility Byte ordering not an issue Linux Alpha Sun 31 31 38 38 32 32 34 34 33 33 00 00 16 Carnegie Mellon Today Bits Bytes and Integers Representing information as bits Bit level manipulations Integers Representation unsigned and signed Conversion casting Expanding truncating Addition negation multiplication shifting Summary 17 Carnegie Mellon Boolean Algebra Developed by George Boole in 19th Century Algebraic representation of logic Encode True as 1 and False as 0 And A B 1 when both A 1 and B 1 Not Or A 1 when A 0 A B 1 when either A 1 or B 1 Exclusive Or Xor A B 1 when either A 1 or B 1 but not both 18 Carnegie Mellon Application of Boolean Algebra Applied to Digital Systems by Claude Shannon 1937 MIT Master s Thesis Reason about networks of relay switches Encode closed switch as 1 open switch as 0 A B A A B B A B Connection when A B A B A B 19 Carnegie Mellon General Boolean Algebras Operate on Bit Vectors Operations applied bitwise 01101001 01010101 01000001 01000001 01101001 01101001 01010101 01010101 01111101 00111100 01111101 00111100 01010101 10101010 10101010 All of the Properties of Boolean Algebra Apply 20 Carnegie Mellon Representing Manipulating Sets Representation Width w bit vector represents subsets of 0 w 1 aj 1 if j A 01101001 76543210 0 3 5 6 01010101 76543210 0 2 4 6 Operations Intersection 01000001 0 6 Union 01111101 0 2 3 4 5 6 Symmetric difference 00111100


View Full Document

CMU CS 15213 - Bits, Bytes, and Integers

Documents in this Course
lecture

lecture

14 pages

lecture

lecture

46 pages

Caches

Caches

9 pages

lecture

lecture

39 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

56 pages

lecture

lecture

11 pages

lecture

lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

37 pages

Exam

Exam

16 pages

Lecture

Lecture

10 pages

Lecture

Lecture

43 pages

Lecture

Lecture

8 pages

Lecture

Lecture

8 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

37 pages

Lecture

Lecture

6 pages

Lecture

Lecture

40 pages

coding

coding

2 pages

Exam

Exam

17 pages

Exam

Exam

14 pages

Lecture

Lecture

29 pages

Lecture

Lecture

34 pages

Exam

Exam

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

lecture

lecture

46 pages

Lecture

Lecture

33 pages

Lecture

Lecture

57 pages

Lecture

Lecture

32 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

6 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

18 pages

Exam

Exam

10 pages

Lecture

Lecture

45 pages

Lecture

Lecture

37 pages

Exam

Exam

24 pages

class09

class09

21 pages

class22

class22

37 pages

class20

class20

30 pages

class27

class27

33 pages

class25

class25

21 pages

class04

class04

31 pages

Lecture

Lecture

59 pages

class01a

class01a

14 pages

class12

class12

45 pages

class29

class29

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

6 pages

class03

class03

34 pages

lecture

lecture

42 pages

Lecture

Lecture

40 pages

Lecture

Lecture

47 pages

Exam

Exam

19 pages

R06-B

R06-B

25 pages

class17

class17

37 pages

class25

class25

31 pages

Lecture

Lecture

15 pages

final-f06

final-f06

17 pages

Lecture

Lecture

9 pages

lecture

lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

22 pages

class11

class11

45 pages

lecture

lecture

50 pages

Linking

Linking

37 pages

Lecture

Lecture

64 pages

Integers

Integers

40 pages

Exam

Exam

11 pages

Lecture

Lecture

37 pages

Lecture

Lecture

44 pages

Lecture

Lecture

37 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

45 pages

Final

Final

25 pages

lecture

lecture

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

16 pages

Final

Final

17 pages

Lecture

Lecture

8 pages

Exam

Exam

11 pages

Lecture

Lecture

47 pages

Lecture

Lecture

9 pages

lecture

lecture

39 pages

Exam

Exam

11 pages

lecture

lecture

41 pages

lecture

lecture

37 pages

Lecture

Lecture

59 pages

Lecture

Lecture

45 pages

Exam 1

Exam 1

18 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

30 pages

Lecture

Lecture

9 pages

Lecture

Lecture

9 pages

Lecture

Lecture

15 pages

Lecture

Lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

4 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

65 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Lecture

Lecture

8 pages

Lecture

Lecture

34 pages

Lecture

Lecture

8 pages

Exam

Exam

13 pages

Lecture

Lecture

43 pages

Lecture

Lecture

9 pages

Lecture

Lecture

12 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

43 pages

Lecture

Lecture

7 pages

Lecture

Lecture

45 pages

Lecture

Lecture

24 pages

Lecture

Lecture

47 pages

Lecture

Lecture

12 pages

Lecture

Lecture

20 pages

Lecture

Lecture

9 pages

Exam

Exam

11 pages

Lecture

Lecture

52 pages

Lecture

Lecture

20 pages

Exam

Exam

11 pages

Lecture

Lecture

35 pages

Lecture

Lecture

47 pages

Lecture

Lecture

18 pages

Lecture

Lecture

30 pages

Lecture

Lecture

59 pages

Lecture

Lecture

37 pages

Lecture

Lecture

22 pages

Lecture

Lecture

35 pages

Exam

Exam

23 pages

Lecture

Lecture

9 pages

Lecture

Lecture

22 pages

class12

class12

32 pages

Lecture

Lecture

8 pages

Lecture

Lecture

39 pages

Lecture

Lecture

44 pages

Lecture

Lecture

38 pages

Lecture

Lecture

69 pages

Lecture

Lecture

41 pages

Lecture

Lecture

12 pages

Lecture

Lecture

52 pages

Lecture

Lecture

59 pages

Lecture

Lecture

39 pages

Lecture

Lecture

83 pages

Lecture

Lecture

59 pages

class01b

class01b

17 pages

Exam

Exam

21 pages

class07

class07

47 pages

Lecture

Lecture

11 pages

Odyssey

Odyssey

18 pages

multicore

multicore

66 pages

Lecture

Lecture

6 pages

lecture

lecture

41 pages

lecture

lecture

55 pages

lecture

lecture

52 pages

lecture

lecture

33 pages

lecture

lecture

46 pages

lecture

lecture

55 pages

lecture

lecture

17 pages

lecture

lecture

49 pages

Exam

Exam

17 pages

lecture

lecture

56 pages

Exam 2

Exam 2

16 pages

Exam 2

Exam 2

16 pages

Notes

Notes

37 pages

Lecture

Lecture

40 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Exam

Exam

13 pages

Lecture

Lecture

32 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

29 pages

Lecture

Lecture

59 pages

Lecture

Lecture

41 pages

Lecture

Lecture

50 pages

Exam

Exam

17 pages

Lecture

Lecture

29 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

33 pages

lecture

lecture

10 pages

Lecture

Lecture

27 pages

Lecture

Lecture

29 pages

Lecture

Lecture

39 pages

Lecture

Lecture

9 pages

Lecture

Lecture

29 pages

Lecture

Lecture

8 pages

Lecture

Lecture

43 pages

Lecture

Lecture

43 pages

Lecture

Lecture

75 pages

Lecture

Lecture

55 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lecture

Lecture

35 pages

lecture

lecture

36 pages

Exam

Exam

33 pages

lecture

lecture

56 pages

lecture

lecture

64 pages

lecture

lecture

8 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

36 pages

lecture

lecture

56 pages

lecture

lecture

75 pages

lecture

lecture

36 pages

Lecture

Lecture

50 pages

Lecture

Lecture

45 pages

Lecture

Lecture

13 pages

Exam

Exam

23 pages

Lecture

Lecture

10 pages

Lecture

Lecture

48 pages

Lecture

Lecture

83 pages

lecture

lecture

57 pages

Lecture

Lecture

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

33 pages

lecture

lecture

54 pages

Lecture

Lecture

30 pages

Exam

Exam

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

40 pages

Exam

Exam

17 pages

Lecture

Lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

44 pages

Lecture

Lecture

34 pages

Lecture

Lecture

24 pages

Lecture

Lecture

29 pages

class12

class12

43 pages

lecture

lecture

43 pages

class22

class22

22 pages

R06-B

R06-B

25 pages

class01b

class01b

19 pages

lecture

lecture

29 pages

lab1

lab1

8 pages

Caches

Caches

36 pages

lecture

lecture

55 pages

Lecture,

Lecture,

37 pages

Integers

Integers

40 pages

Linking

Linking

38 pages

lecture

lecture

45 pages

Lecture

Lecture

61 pages

Linking

Linking

33 pages

lecture

lecture

40 pages

lecture

lecture

40 pages

Lecture

Lecture

32 pages

lecture

lecture

48 pages

lecture

lecture

44 pages

Exam

Exam

11 pages

Lecture

Lecture

31 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

40 pages

Exam

Exam

12 pages

Lecture

Lecture

42 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

Lecture

Lecture

13 pages

Lecture

Lecture

35 pages

Lecture

Lecture

20 pages

Final

Final

19 pages

Lecture

Lecture

33 pages

Lecture

Lecture

50 pages

Lecture

Lecture

33 pages

Lecture

Lecture

27 pages

Lecture

Lecture

6 pages

Exam

Exam

15 pages

Lecture

Lecture

24 pages

Lecture

Lecture

23 pages

Lecture

Lecture

43 pages

Lecture

Lecture

32 pages

Lecture

Lecture

52 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

15 pages

lecture

lecture

21 pages

Lecture

Lecture

58 pages

Lecture

Lecture

49 pages

Lecture

Lecture

36 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

33 pages

Exam

Exam

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

10 pages

Lecture

Lecture

25 pages

Lecture

Lecture

31 pages

Lecture

Lecture

24 pages

Lecture

Lecture

34 pages

Lecture

Lecture

50 pages

lecture

lecture

35 pages

Lecture

Lecture

11 pages

Lecture

Lecture

39 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

exam1-f05

exam1-f05

11 pages

Lecture

Lecture

4 pages

Lecture

Lecture

17 pages

Exam

Exam

17 pages

malloc()

malloc()

12 pages

Lecture

Lecture

57 pages

Lecture

Lecture

30 pages

Lecture

Lecture

30 pages

Lecture

Lecture

47 pages

Lecture

Lecture

33 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lectures

Lectures

33 pages

Lecture

Lecture

36 pages

lecture

lecture

33 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Load more
Download Bits, Bytes, and Integers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Bits, Bytes, and Integers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Bits, Bytes, and Integers and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?