{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 2

# Complement 01000001 01111101 00111100 10101010 memory

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: w_int (int x) { show_bytes( (char *) &x, sizeof(int)); } Memory prins direcJves: %p Print pointer \t Tab %x Print value as hex \n New line 42 University of Washington show_bytes ExecuJon Example int a = 12345; // represented as 0x00003039 printf("int a = 12345;\n"); show_int(a); // show_bytes((pointer) &a, sizeof(int)); Result (Linux):! int a = 12345; 0x11ffffcb8 0x11ffffcb9 0x11ffffcba 0x11ffffcbb 0x39 0x30 0x00 0x00 Memory 43 University of Washington Memory, Data, and Addressing           Preliminaries RepresenJng informaJon as bits and bytes Organizing and addressing data in memory ManipulaJng data in memory using C Boolean algebra and bit ­level manipulaJons Memory 44 University of Washington Boolean Algebra   Developed by George Boole in 19th Century   Algebraic representaGon of logic   Encode “True” as 1 and “False” as 0   AND: A&B = 1 when both A is 1 and B is 1   OR: A|B = 1 when either A is 1 or B is 1   XOR: A^B = 1 when either A is 1 or B is 1, but not both   NOT: ~A = 1 when A is 0 and vice ­versa   DeMorgan’s Law: ~(A | B) = ~A & ~B &01 000 101 |01 001 111 ^01 001 110 Memory ~ 01 10 45 University of Washin...
View Full Document

{[ snackBarMessage ]}