Announcements* Hardware:*Logical*View* Hardware:*SemiVLogical*View* Hardware:*Physical*View*

Size: px
Start display at page:

Download "Announcements* Hardware:*Logical*View* Hardware:*SemiVLogical*View* Hardware:*Physical*View*"

Transcription

1 Announcements* Hardware:*Logical*View* On*the*website:*cs.uw.edu/351* Speedometer!** Anonymous*feedback*form* Make*sure*you*are*subscribed*to*the*mailing*list* Lecture*slides*on*the*web*schedule*(these*will*be*linked*1>2*days*prior)* Lab*0,*having*fun?**Make*sure*to*start*earl Discussion*boards* Videos*for*opGonal*reference* *not*exactlthe*same*slides*as*we ll*use* Tips*for*C,*debugging,*etc.* Lecture*content* Office*hours*posted:*if*thedon t*work*for*you,*let*us*know* Anyone*not*yet*enrolled?**If*not,*see*me*right*aCer*class* New*secEon*being*created*for*Th*11:30* *statuned* CPU* Memor Bus* Disks* Net* USB* Etc.* 1* 2* Hardware:*SemiVLogical*View* Hardware:*Physical*View* Graphics* CPU* Memor USB Network* USB I/O* (Bus)* Audio* Storage* I/O* controller* CPU* Memor Storage*connecEons* 3* 4*

2 Hardware:*351*View*(version*0)* Hardware:*351*View*(version*1)*?* instructions Memor ivcache* take*352 instructions this*week Memor CPU* data CPU* registers* data CPU*executes*instrucEons;*memorstores*data* To*execute*an*instrucEon,*the*CPU*must:* fetch*an*instrucgon;* fetch*the*data*used*bthe*instrucgon;*and,*finally,* execute*the*instrucgon*on*the*data which*maresult*in*wrigng*data*back*to*memory.* 5* The*CPU*holds*instrucEons*temporarilin*the*instrucEon*cache* The*CPU*holds*data*temporarilin*a*fixed*number*of*registers* InstrucEon*and*operand*fetching*is*HWVcontrolled* Data*movement*is*programmerVcontrolled* We ll*learn*about*the*instrucgons*the*cpu*executes* * take*352*to*find*out*how*it*executes*them* 6* Hardware:*351*View*(version*1)* How*are*data* CPU* and*instruceons* represented?* ivcache* take*352 registers* instructions data The*CPU*holds*instrucEons*temporarilin*the*instrucEon*cache.* How*does*a* The*CPU*holds*data*temporarilin*a*fixed*number*of*registers.* InstrucEon*fetching*is*HWVcontrolled.* program*find*its* Data*movement*is*programmerVcontrolled.* this*week Memor data*in*memory?* Roadmap* C:* car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembl language:* Machine* code:* Computer* system:* get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp Java:* Car c = new Car(); c.setmiles(100); c.setgals(17); float mpg = c.getmpg(); OS:* Integers*&*floats* Machine*code*&*C* x86*assembl Procedures*&*stacks* Arrays*&*structs* Memor&*caches* Processes* Virtual*memor MemorallocaEon* Java*vs.*C* 7* 8*

3 Memory,*Data,*and*Addressing* RepresenEng*informaEon*as*bits*and*bytes* Organizing*and*addressing*data*in*memor ManipulaEng*data*in*memorusing*C* Boolean*algebra*and*bitVlevel*manipulaEons* ivcache* take*352 instructions this*week Memor How*are*data* CPU* and*instruceons* represented?* registers* data 9* 10* BinarRepresentaEons* Describing*Byte*Values* Base*2*number*representaEon* A*base*2*digit*(0*o*1)*is*called*a*bit.* Represent* *as* * *or** * Binar * *VV** * Byte*8*bits*(binardigits)* Decimal ***************0 10 *VV**255 10* Electronic*implementaEon* Easto*store*with*bi>stable*elements* Reliabltransmi[ed*on*noisand*inaccurate*wires** 3.3V* 2.8V* 0.5V* 0.0V* 0* 1* 0 Hexadecimal****************00 16 *VV**FF 16* Byte*2*hexadecimal*(or* hex *or*base*16)*digits* Base*16*number*representaGon* Use*characters* 0 *to* 9 *and* A *to* F * Write*FA1D37B 16 *in*c** as***0xfa1d37b or***0xfa1d37b More*on*specific*data*types*later 0* 0* 00 1* 1* 00 2* 2* 0010* 3* 3* 0011* 4* 4* 01 5* 5* 01 6* 6* 0110* 7* 7* 0111* 8* 8* 10 9* 9* 10 A* 10* 1010* B* 11* 1011* C* 12* 11 D* 13* 11 E* 14* 1110* F* 15* 1111* 11* 12*

4 ByteVOriented*MemorOrganizaEon* ivcache* take*352 CPU* registers* instructions data this*week Memor How*does*a* program*find*its* data*in*memory?*! Conceptually,*memoris*a*single,*large*arraof*bytes,* each*with*an*unique*address*(index).* The*value*of*each*byte*in*memorcan*be*read*and*wrijen.* Programs*refer*to*bytes*in*memorbtheir*addresses.* Domain*of*possible*addresses*address)space) But*not*all*values*(e.g.,)351)*fit*in*a*single*byte Store*addresses*to* remember *where*other*data*is*in*memory.* How*much*memorcan*we*address*with*1>byte*(8>bit)*addresses?* ManoperaEons*actualluse*mulEVbyte*values.* 13* 14* Machine*Words* WordVOriented*MemorOrganizaEon* fixed*number*of*coneguous*bytes*in*memory,*chosen*bhw* the*largest*unit*of*data*a*machine*instruceon*can*use) word*size*address*size*register*size* Word*size*bounds*the*size*of*the*address)space)and*memory.* word*size*w*bits**=>**2 w *addresses* UnGl*recently,*most*machines*used*32Vbit*(4Vbyte)*words.* PotenGal*address*space:*2 32 *addresses* 2 32 *bytes* 4*10 9 *bytes*4*billion*bytes*4gb* (living*humans*/*addressable*bytes* *1.8)* Became*too*small*for*memory>intensive*applicaGons* Current*x86*systems*use*64Vbit*(8Vbyte)*words.* PotenGal*address*space:*2 64 *addresses* 2 64 *bytes* *1.8*10 19 *bytes*18*billion*billion*bytes*18*eb*(exabytes)* (possible*living*acquaintances*/*addressable*bytes* 2.8)* 15* Addresses*specif* locaeons*of*bytes*in*memor Address*of*word* *address*of*first*byte*in*word* Addresses*of*successive*words** differ*bword*size*(in*bytes):* e.g.,*4*(32>bit)*or*8*(64>bit)* Address*of*word*0,*1,*..*10?* 64>bit* Words*??*??* 32>bit* Words*??*??*??*??* Bytes* Addr.* * 0003* * 0006* 0007* 0008* 0009* 0010* 0011* 0012* 0013* 0014* 0015* 16*

5 WordVOriented*MemorOrganizaEon* MemorAlignment* Addresses*sEll*specif* locaeons*of*bytes*in*memor Address*of*word* *address*of*first*byte*in*word* Addresses*of*successive*words** differ*bword*size*(in*bytes):* e.g.,*4*(32>bit)*or*8*(64>bit)* Address*of*word*0,*1,*..*10? * Alignment* 64>bit* Words* 00??* 0008*??* 32>bit* Words* 00??* 00??* 0008*??* 0012*??* Bytes* Addr.* * 0003* * 0006* 0007* 0008* 0009* 0010* 0011* 0012* 0013* 0014* 0015* 17* Data*of*size*n)onlstored*at*addresses*a*where*a*mod*n*0* ConvenGon*or*rule,*depending*on*plamorm.* n*is*usualla*power*of*2.* A*32Vbit*(4Vbyte)*wordValigned* view*of*memory:* Each*row*is*a*word*composed*of*4*bytes.* Cells*in*a*row*are*the*word s*bytes.* 0x05* 0x06* 0x07* 0x 0x 0x02* 0x03* More*about*alignment*later*in*the*course.* (note*he addresses)* 0x 18* Addresses*and*Pointers* Addresses*and*Pointers* An*address*is*a*locaEon*in*memor A*pointer*is*a*data*object*that*holds*an*address.* The*value*351*is*stored*at*address*0x04.* *15F 16 *0x 0x An*address*is*a*locaEon*in*memor A*pointer*is*a*data*object*that*holds*an*address.* The*value*351*is*stored*at*address*0x04.* *15F 16 *0x A*pointer*stored*at*address* points*to*address*0x04.* 0x 19* 20*

6 Addresses*and*Pointers* Addresses*and*Pointers* An*address*is*a*locaEon*in*memor An*address*is*a*locaEon*in*memor A*pointer*is*a*data*object*that*holds*an*address.* A*pointer*is*a*data*object*that*holds*an*address.* The*value*351*is*stored*at*address*0x04.* *15F 16 *0x A*pointer*stored*at*address* points*to*address*0x04.* A*pointer*to*a*pointer** is*stored*at*address*0x24.* 1C* 0x The*value*351*is*stored*at*address*0x04.* *15F 16 *0x A*pointer*stored*at*address* points*to*address*0x04.* A*pointer*to*a*pointer** is*stored*at*address*0x24.* The*value*12*is*stored* at*address*0x14.* Is*it*a*pointer?* 0C* 1C* 0x 21* 22* Data*RepresentaEons* Byte*Ordering* Sizes*of*data*types*(in*bytes)* Java*Data*Type *C*Data*Type *Typical*32>bit *x86>64* boolean *bool *1 *1* byte *char *1 *1* char * *2 *2* short *short*int *2 *2* int *int *4 *4* float *float *4 *4* *long*int *4 *8* double *double *8 *8* long *long*long *8 *8* * *long*double *8 *16* (reference) *pointer** *4 *8* How*should*bytes*within*a*word*be*ordered*in*memory?* Example:*Store*the*4Vbyte*word*0xa1*b2*c3*d4.* In*what*order*will*the*bytes*be*stored?* ConvenEons!* Big>endian,*Li[le>endian* Based*on*Gulliver s)travels:*tribes*cut*eggs*on*different*sides*(big,*li[le)* 23* 24*

7 Byte*Ordering* Byte*Ordering*Example* BigVEndian*(PowerPC,*SPARC,*The*Internet)* Least*significant*byte*has*highest*address* LijleVEndian*(x86)* Least*significant*byte*has*lowest*address* Example* Variable*has*4>byte*representaGon*0xa1b2c3d4* Address*of*variable*is*0x1 Big*Endian* Lijle*Endian* 0x1 0x1 0x102* 0x103* a1* b2* 23* 45* c3* d4* 67* 0x1 0x1 0x102* 0x103* d4* 67* 45* c3* b2* 23* a1* higher*addresses* lower*addresses* int x = 12345; // long int = word long int y = 12345; IA32,*x86V64* 39* 30* SPARC* 30* 39* IA32* 39* 30* Decimal:! 12345! Binary: Hex: x86v64* 39* 30* 32Vbit* SPARC* 30* 39* 64Vbit* SPARC* 30* 39* 25* 26* Reading*ByteVReversed*LisEngs* Disassembl Take*binarmachine*code*and*generate*an*assemblcode*version.* Does*the*reverse*of*the*assembler.* Example*instrucEon*in*memor* add*value*0x12ab*to*register* ebx *(a)special)loca7on)in)cpu s)memory)) Address!Instruction Code!Assembly Rendition! : 81 c3 ab add $0x12ab,%ebx Reading*ByteVReversed*LisEngs* Disassembl Take*binarmachine*code*and*generate*an*assemblcode*version.* Does*the*reverse*of*the*assembler.* Example*instrucEon*in*memor* add*value*0x12ab*to*register* ebx *(a)special)loca7on)in)cpu s)memory)) Address!Instruction Code!Assembly Rendition! : 81 c3 ab add $0x12ab,%ebx Deciphering*numbers* Value:* Pad*to*32*bits:* Split*into*bytes:* Reverse*(lijleVendian):* *0x12ab* *0x000012ab* *12*ab* *ab*12* 28*

8 Addresses*and*Pointers*in*C* int* ptr;! int x = 5;! int y = 2;! ptr = &x;! Dereference)ptr. ) y = 1 + *ptr;! Declares*a*variable,*ptr,*that*is*a* pointer*to*(i.e.,*holds*the*address*of)* an*int*in*memory.* Declares*two*variables,*and*y,*that*hold*ints,* and*sets*them*to*5*and*2,*respecgvely.* Sets*ptr*to*the*address*of*x.* Now,* ptr)points)to)x. ) What*is****(&y)***?* Sets*to*1*plus*the*value*at*the*address*held*bptr.*** Because*ptr*points*to*x,*this*is*to*y=1+x;! 29* A*variable*is*represented*ba*memorlocaEon.* IniEally,*it*mahold*anvalue.* //*is*at*locagon*0x04,*is*at*0x18.* A7* 32* 29* F3* EE* EE* EE* EE* FA* CE* CA* FE* 26* 10* FF* F4* 96* 42* 17* 34* 0x 30* A*variable*is*represented*ba*memorlocaEon.* IniEally,*it*mahold*anvalue.* //*is*at*locagon*0x04,*is*at*0x18.* 29* F3* 0x LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x 31* 32*

9 LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x3CD02700;* 33* lijle*endian!* 0x LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x3CD02700;* +*3;* //*Get*value*at*y,*add*3,*put*it*in*x.* 34* 03* 0x LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x3CD02700;* +*3;** //*Get*value*at*y,*add*3,*put*it*in*x.* int**z* 35* 03* 0x z* LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x3CD02700;* +*3;** //*Get*value*at*y,*add*3,*put*it*in*x.* int**z*&+*3;* //*Get*address*of*y,*add*???,*put*it*in*z.* 36* 03* 0x z*

10 LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x3CD02700;* +*3;* //*Get*value*at*y,*add*3,*put*it*in*x.* int**z*&+*3;* //*Get*address*of*y,*add*12,*put*it*in*z.* 37* 03* 0x z* 24* Pointer*arithmeGc*is*scaled*bsize*of*target*type.) Pointer*arithmeEc* can*be*dangerous.) LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x3CD02700;* +*3;** //*Get*value*at*y,*add*3,*put*it*in*x.* int**z*&+*3;* //*Get*address*of*y,*add*12,*put*it*in*z.* *z*y;* //*What*does*this*do?* 38* 03* 0x z* 24* LeCVhandVside*rightVhandVside;* LHS*must*evaluate*to*a*memorloca7on.* RHS*must*evaluate*to*a*value.*(could*be*an*address!)* Store*RHS*value*at*LHS*locaGon.* 0;* 0x3CD02700;* +*3;*** //*Get*value*at*y,*add*3,*put*it*in*x.* int**z*&+*3;* //*Get*address*of*y,*add*12,*put*it*in*z.* *z*y;* //*Get*value*of*y,*put*it*at*the*address*stored*in*z.* 39* 03* 0x z* 24* The*target*of*a*pointer*is* also*a*memorlocagon.) 40* 0x element*type* name* number*of* elements*

11 41* 0x a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* 42* 0x a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* a[6]*0xbad;* a[v1]*0xbad;* check:* 43* 0x p* a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* Pointers:* {* a[6]*0xbad;* a[v1]*0xbad;* check:* int**p;* p*a;* p*&a[0];* 44* 0x p* a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* Pointers:* {* a[6]*0xbad;* a[v1]*0xbad;* check:* int**p;* p*a;* p*&a[0];* *p*0xa;*

12 45* 0A* 0x p* a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* Pointers:* {* a[6]*0xbad;* a[v1]*0xbad;* check:* int**p;* p*a;* p*&a[0];* *p*0xa;* 46* 0A* 0x p* a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* Pointers:* {* a[6]*0xbad;* a[v1]*0xbad;* check:* int**p;* p*a;* p*&a[0];* *p*0xa;* p[1]*0xb;* array)indexing)=)address)arithme8c) Both*are*scaled*bthe*size*of*the*type.* 47* 0A* 0x p* a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* Pointers:* {* a[6]*0xbad;* a[v1]*0xbad;* check:* int**p;* p*a;* p*&a[0];* *p*0xa;* p[1]*0xb;* array)indexing)=)address)arithme8c) Both*are*scaled*bthe*size*of*the*type.* 48* 0A* 0x p* a[0]* a[1]* a[5]* a[0]*0x015f;* a[5]*a[0];* Pointers:* {* a[6]*0xbad;* a[v1]*0xbad;* check:* int**p;* p*a;* p*&a[0];* *p*0xa;* {* p[1]*0xb;* *(p*+*1)*0xb;*

13 a[0]*0x015f;* a[5]*a[0];* a[6]*0xbad;* check:* a[v1]*0xbad;* Pointers:* int**p;* p*a;* {* p*&a[0];* *p*0xa;* p[1]*0xb;* {**(p*+*1)*0xb;* p*p*+*2;* array)indexing)=)address)arithme8c) Both*are*scaled*bthe*size*of*the*type.* 0x 0A* a[0]* a[1]* a[5]* p* a[0]*0x015f;* a[5]*a[0];* a[6]*0xbad;* check:* a[v1]*0xbad;* Pointers:* int**p;* p*a;* {* p*&a[0];* *p*0xa;* p[1]*0xb;* {**(p*+*1)*0xb;* p*p*+*2;* array)indexing)=)address)arithme8c) Both*are*scaled*bthe*size*of*the*type.* 0x 0A* a[0]* a[1]* a[5]* 0C* p* 49* 50* a[0]*0x015f;* a[5]*a[0];* a[6]*0xbad;* check:* a[v1]*0xbad;* Pointers:* int**p;* p*a;* {* p*&a[0];* *p*0xa;* p[1]*0xb;* {**(p*+*1)*0xb;* p*p*+*2;* array)indexing)=)address)arithme8c) Both*are*scaled*bthe*size*of*the*type.* *p*a[1]*+*1;* 0x 0A* a[0]* a[1]* 0C* a[5]* 0C* p* 51* RepresenEng*strings* A*CVstyle*string*is*represented*ban*arraof*bytes*(char).* Elements*are*one>byte*ASCII*codes*for*each*character.* ASCII*American*Standard*Code*for*InformaGon*Interchange* 32 space P 96 ` 112 p 33! A 81 Q 97 a 113 q B 82 R 98 b 114 r 35 # C 83 S 99 c 115 s 36 $ D 84 T 100 d 116 t 37 % E 85 U 101 e 117 u 38 & F 86 V 102 f 118 v G 87 W 103 g 119 w 40 ( H 88 X 104 h 120 x 41 ) I 89 Y 105 I 121 y 42 * 58 : 74 J 90 Z 106 j 122 z ; 75 K 91 [ 107 k 123 { 44, 60 < 76 L 92 \ 108 l = 77 M 93 ] 109 m 125 } > 78 N 94 ^ 110 n 126 ~ 47 / 63? 79 O 95 _ 111 o 127 del 52*

14 NullVterminated*Strings* H a r r y P o t t e r \0 For*example,* HarrPojer *can*be*stored*as*a*13vbyte*array.* Whdo*we*put*a*0,*or*null*zero,*at*the*end*of*the*string?* Note*the*special*symbol:*string[12]*'\0';* How*do*we*compute*the*string*length?* Endianness*and*Strings* C*(char*1*byte)* Java*(char*2*bytes)* char s[6] = "12345"; String?* s = "123"; (not*all*of*the*string*representagon*is*shown)* IA32,*x86V64* SPARC* IA32,*x86V64* SPARC* 31* 31* 31* 32* 32* 31* 33* 33* 32* 34* 34* 32* 35* 35* 33* 33* Byte*ordering*(endianness)*is*not*an*issue*for*1Vbyte*values.* Arrays*are*not*values;*elements*are*values;*chars*are*single*bytes.* Unicode*characters* *up*to*4*bytes/character* ASCII*codes*sGll*work*(just*add*leading*zeros).* Unicode*can*support*the*mancharacters*in*all*languages*in*the*world.* Java*and*C*have*libraries*for*Unicode*(Java*commonluses*2*bytes/char)* 53* 54* Examining*Data*RepresentaEons* show_bytes*execueon*example* Code*to*print*byte*representaEon*of*data* Andata*type*can*be*treated*as*a*byte)arrabcasEng*it*to*char C*has*unchecked*casts.**<<*DANGER*>>* typedef char byte; // size of char == 1 byte void show_bytes(byte* start, int len) { int i; for (i = 0; i < len; i++) printf("%p\t0x%.2x\n", start+i, *(start+i)); printf("\n"); } void show_int (int x) { show_bytes( (byte *) &x, sizeof(int)); } prindireceves:* *%p *Print*pointer* *\t *Tab* *%x *Print*value*as*he *\n *New*line* 55* int a = 12345; // represented as 0x printf("int a = 12345;\n"); show_int(a); // show_bytes((pointer) &a, sizeof(int)); Result (Linux):! int a = 12345; 0x11ffffcb8 0x39 0x11ffffcb9 0x30 0x11ffffcba 0x00 0x11ffffcbb 0x00 56*

15 Boolean*Algebra* General*Boolean*Algebras* Developed*bGeorge*Boole*in*19th*Centur 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* Operate*on*bit*vectors* OperaGons*applied*bitwise* **** &* ** *** * ** *** ^* ** All*of*the*properEes*of*Boolean*algebra*appl *** ^* ** ~* ** * How*does*this*relate*to*set*operaEons?* 57* 58* RepresenEng*&*ManipulaEng*Sets* BitVLevel*OperaEons*in*C* RepresentaEon* A*w>bit*vector*represents*subsets*of*{0,*,*w 1}* a j *1*iff*j** *A) {*0,*3,*5,*6*}* {*0,*2,*4,*6*}* OperaEons* &* *IntersecGon * {*0,*6*}* ** *Union * {*0,*2,*3,*4,*5,*6*}* ^ *Symmetric*difference * {*2,*3,*4,*5*}* ~ *Complement * {*1,*3,*5,*7*}* &*** ***^***~* Applto*an integral *data*type* long,**int,**short,**char, unsigned View*arguments*as*bit*vectors* Examples*(char*data*type)* ~0x41 --> 0xBE ~ > ~0x00 --> 0xFF ~ > x69 & 0x55 --> 0x & > x69 0x55 --> 0x7D > * Some*bitVtwiddling*puzzles*in*Lab*1* 59* 60*

16 Contrast:*Logic*OperaEons*in*C* Contrast*to*logical*operators* &&***** *****!* 0*is* False * Anything*nonzero*is* True * Always*return*0*or*1* EarlterminaGon****a.k.a.***short>circuit*evaluaGon* Examples*(char*data*type)*!0x41 --> 0x00!0x00 --> 0x01!!0x41 --> 0x01 0x69 && 0x55 --> 0x01 0x69 0x55 --> 0x01 p && *p++ (avoids*null*pointer*access,*null*pointer*0x000000)* 61*

Hardware: Logical View

Hardware: Logical View Hardware: Logical View CPU Memory Bus Disks Net USB Etc. 1 Hardware: Physical View USB I/O controller Storage connections CPU Memory 2 Hardware: 351 View (version 0) instructions? Memory CPU data CPU executes

More information

CSE351: Memory, Data, & Addressing I

CSE351: Memory, Data, & Addressing I CSE351: Memory, Data, & Addressing I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis http://xkcd.com/138/

More information

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra Expressing

More information

Memory, Data, & Addressing I

Memory, Data, & Addressing I Memory, Data, & Addressing I CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/953/

More information

ICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2

ICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2 ICS 2008 Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2 Data Representations Sizes of C Objects (in Bytes) C Data Type Compaq Alpha Typical 32-bit Intel IA32 int 4 4 4 long int 8 4 4

More information

Bits and Bytes January 13, 2005

Bits and Bytes January 13, 2005 15-213 The Class That Gives CMU Its Zip! Topics Bits and Bytes January 13, 25 Why bits? Representing information as bits Binary / Hexadecimal Byte representations» Numbers» Characters and strings» Instructions

More information

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10? Where Have We Been? Class Introduction Great Realities of Computing Int s are not Integers, Float s are not Reals You must know assembly Memory Matters Performance! Asymptotic Complexity It s more than

More information

University*of*Washington*

University*of*Washington* Roadmap* C:* car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly* language:* Machine* code:* Computer* system:* get_mpg: pushq movq... popq ret %rbp %rsp,

More information

Data III & Integers I

Data III & Integers I Data III & Integers I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Everyone has VM

More information

Data III & Integers I

Data III & Integers I Data III & Integers I CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun

More information

Memory, Data, & Addressing II CSE 351 Spring

Memory, Data, & Addressing II CSE 351 Spring Memory, Data, & Addressing II CSE 351 Spring 2018 http://xkcd.com/138/ Review Questions 1) If the word size of a machine is 64-bits, which of the following is usually true? (pick all that apply) a) 64

More information

Lecture 5-6: Bits, Bytes, and Integers

Lecture 5-6: Bits, Bytes, and Integers CSCI-UA.0201-003 Computer Systems Organization Lecture 5-6: Bits, Bytes, and Integers Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Slides adapted from: Jinyang Li Bryant and O Hallaron

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

Data III & Integers I

Data III & Integers I Data III & Integers I CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie

More information

Structs and Alignment CSE 351 Spring

Structs and Alignment CSE 351 Spring Structs and Alignment CSE 351 Spring 2018 http://xkcd.com/1168/ Administrivia Homework 3 due Wednesday Lab 3 released, due next week Lab 2 and midterm will be graded this week [in that order] 2 Roadmap

More information

Bits, Bytes, and Integers Part 2

Bits, Bytes, and Integers Part 2 Bits, Bytes, and Integers Part 2 15-213: Introduction to Computer Systems 3 rd Lecture, Jan. 23, 2018 Instructors: Franz Franchetti, Seth Copen Goldstein, Brian Railing 1 First Assignment: Data Lab Due:

More information

L14: Structs and Alignment. Structs and Alignment. CSE 351 Spring Instructor: Ruth Anderson

L14: Structs and Alignment. Structs and Alignment. CSE 351 Spring Instructor: Ruth Anderson Structs and Alignment CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Lab 2 due TONIGHT

More information

Bits, Bytes, and Integers August 26, 2009

Bits, Bytes, and Integers August 26, 2009 15-213 The Class That Gives CMU Its Zip! Bits, Bytes, and Integers August 26, 2009 Topics Representing information as bits Bit-level manipulations Boolean algebra Expressing in C Representations of Integers

More information

Java and C CSE 351 Spring

Java and C CSE 351 Spring Java and C CSE 351 Spring 2018 https://xkcd.com/801/ Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

University*of*Washington*

University*of*Washington* Roadmap C: car c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

Memory, Data, & Addressing II

Memory, Data, & Addressing II Memory, Data, & Addressing II CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson

More information

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics! Why bits?! Representing information as bits " Binary/Hexadecimal " Byte representations» numbers» characters and strings» Instructions! Bit-level manipulations " Boolean

More information

Bits and Bytes: Data Presentation Mohamed Zahran (aka Z)

Bits and Bytes: Data Presentation Mohamed Zahran (aka Z) CSCI-UA.0201 Computer Systems Organization Bits and Bytes: Data Presentation Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted and modified from: Clark Barrett Jinyang

More information

Building an Executable

Building an Executable Building an Executable CSE 351 Summer 2018 Instructor: Justin Hsia Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan http://xkcd.com/1790/ Administrivia Lab 2 due Monday (7/16) Homework 3 due

More information

University of Washington

University of Washington Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq %rbp movq %rsp, %rbp... popq %rbp

More information

Structs & Alignment. CSE 351 Autumn Instructor: Justin Hsia

Structs & Alignment. CSE 351 Autumn Instructor: Justin Hsia Structs & Alignment CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie

More information

Java and C. CSE 351 Autumn 2018

Java and C. CSE 351 Autumn 2018 Java and C CSE 351 Autumn 2018 Instructor: Teaching Assistants: Justin Hsia Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie Tian Teagan

More information

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra

More information

University*of*Washington*

University*of*Washington* Roadmap* C:* car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly* language:* Machine* code:* Computer* system:* get_mpg: pushq movq... popq %rbp %rsp,

More information

Arrays. CSE 351 Autumn Instructor: Justin Hsia

Arrays. CSE 351 Autumn Instructor: Justin Hsia rrays CSE 351 utumn 2017 Instructor: Justin Hsia Teaching ssistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/1270/ dministrivia

More information

x86 Programming I CSE 351 Winter

x86 Programming I CSE 351 Winter x86 Programming I CSE 351 Winter 2017 http://xkcd.com/409/ Administrivia Lab 2 released! Da bomb! Go to section! No Luis OH Later this week 2 Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals

More information

Java and C I. CSE 351 Spring Instructor: Ruth Anderson

Java and C I. CSE 351 Spring Instructor: Ruth Anderson Java and C I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Homework 5 Due TONIGHT Wed

More information

Executables & Arrays. CSE 351 Autumn Instructor: Justin Hsia

Executables & Arrays. CSE 351 Autumn Instructor: Justin Hsia Executables & rrays CSE 351 utumn 2018 Instructor: Justin Hsia Teaching ssistants: kshat ggarwal n Wang ndrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie Tian Teagan

More information

Virtual Memory I. CSE 351 Spring Instructor: Ruth Anderson

Virtual Memory I. CSE 351 Spring Instructor: Ruth Anderson Virtual Memory I CSE 35 Spring 27 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Midterms Graded If you did

More information

Byte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Byte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Byte Ordering Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Memory Model Physical memory DRAM chips can read/write 4, 8, 16 bits DRAM modules

More information

Java and C II. CSE 351 Spring Instructor: Ruth Anderson

Java and C II. CSE 351 Spring Instructor: Ruth Anderson Java and C II CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Lab 5 Due TONIGHT! Fri 6/2

More information

Computer Organization: A Programmer's Perspective

Computer Organization: A Programmer's Perspective A Programmer's Perspective Bits, Bytes, Nibbles, Words and Strings Gal A. Kaminka galk@cs.biu.ac.il Topics Why bits? Why 0/1? Basic terms: Bits, Bytes, Nibbles, Words Representing information as bits Characters

More information

Topics of this Slideset. CS429: Computer Organization and Architecture. It s Bits All the Way Down. Why Binary? Why Not Decimal?

Topics of this Slideset. CS429: Computer Organization and Architecture. It s Bits All the Way Down. Why Binary? Why Not Decimal? Topics of this Slideset CS429: Computer Organization and Architecture There are 10 kinds of people in the world: those who understand binary, and those who don t! Dr. Bill Young Department of Computer

More information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 11, 2017 at 08:58 CS429 Slideset 2: 1 Topics of this Slideset

More information

Bits, Bytes, and Integers

Bits, Bytes, and Integers Bits, Bytes, and Integers with contributions from Dr. Bin Ren, College of William & Mary 1 Bits, Bytes, and Integers Representing information as bits Bit-level manipulations Integers Representation: unsigned

More information

Byte Ordering. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Byte Ordering. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Byte Ordering Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE2030: Introduction to Computer Systems, Spring 2018, Jinkyu Jeong (jinkyu@skku.edu)

More information

Arrays. CSE 351 Autumn Instructor: Justin Hsia

Arrays. CSE 351 Autumn Instructor: Justin Hsia rrays CSE 351 utumn 2016 Instructor: Justin Hsia Teaching ssistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun http://xkcd.com/1513/

More information

We made it! Java: Assembly language: OS: Machine code: Computer system:

We made it! Java: Assembly language: OS: Machine code: Computer system: We made it! C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp 0111010000011000

More information

Memory Allocation I. CSE 351 Autumn Instructor: Justin Hsia

Memory Allocation I. CSE 351 Autumn Instructor: Justin Hsia Memory Allocation I CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan Administrivia

More information

Structs and Alignment

Structs and Alignment Structs and Alignment CSE 410 Winter 2017 Instructor: Justin Hsia Teaching Assistants: Kathryn Chan, Kevin Bi, Ryan Wong, Waylon Huang, Xinyu Sui Self Driving Cars Will Make Organ Shortages Even Worse

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

Virtual Memory I. CSE 351 Winter Instructor: Mark Wyse

Virtual Memory I. CSE 351 Winter Instructor: Mark Wyse http://rebrn.com/re/bad-chrome-6282/ Virtual Memory I CSE 35 Winter 28 Instructor: Mark Wyse Teaching Assistants: Kevin Bi Parker DeWilde Emily Furst Sarah House Waylon Huang Vinny Palaniappan Administrative

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp 0111010000011000

More information

Cache Example, System Control Flow

Cache Example, System Control Flow Cache Example, System Control Flow CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu

More information

Structs and Alignment

Structs and Alignment Structs and Alignment CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun

More information

x86 Programming I CSE 351 Autumn 2016 Instructor: Justin Hsia

x86 Programming I CSE 351 Autumn 2016 Instructor: Justin Hsia x86 Programming I CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun http://xkcd.com/409/

More information

Assembly Programming IV

Assembly Programming IV Assembly Programming IV CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis 1 Administrivia Homework 2 due

More information

Computer Systems CSE 410 Autumn Memory Organiza:on and Caches

Computer Systems CSE 410 Autumn Memory Organiza:on and Caches Computer Systems CSE 410 Autumn 2013 10 Memory Organiza:on and Caches 06 April 2012 Memory Organiza?on 1 Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c);

More information

University*of*Washington*

University*of*Washington* Roadmap C: car c = malloc(sizeof(car)); c->miles = 1; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp

More information

Roadmap. The Interface CSE351 Winter Frac3onal Binary Numbers. Today s Topics. Floa3ng- Point Numbers. What is ?

Roadmap. The Interface CSE351 Winter Frac3onal Binary Numbers. Today s Topics. Floa3ng- Point Numbers. What is ? The Hardware/So@ware Interface CSE351 Winter 013 Floa3ng- Point Numbers Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine

More information

x86-64 Programming III & The Stack

x86-64 Programming III & The Stack x86-64 Programming III & The Stack CSE 351 Winter 2018 Instructor: Mark Wyse Teaching Assistants: Kevin Bi Parker DeWilde Emily Furst Sarah House Waylon Huang Vinny Palaniappan http://xkcd.com/1652/ Administrative

More information

Do not turn the page until 5:10.

Do not turn the page until 5:10. University of Washington Computer Science & Engineering Autumn 2017 Instructor: Justin Hsia 2017-10-30 Last Name: First Name: Perfect Perry Student ID Number: 1234567 Name of person to your Left Right

More information

Bits, Bytes and Integers

Bits, Bytes and Integers Bits, Bytes and Integers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran

More information

Floating Point II, x86 64 Intro

Floating Point II, x86 64 Intro Floating Point II, x86 64 Intro CSE 351 Autumn 2018 Instructor: Teaching Assistants: Justin Hsia Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson

More information

Do not turn the page until 5:10.

Do not turn the page until 5:10. University of Washington Computer Science & Engineering Autumn 2017 Instructor: Justin Hsia 2017-10-30 Last Name: First Name: Student ID Number: Name of person to your Left Right All work is my own. I

More information

CS140 Lecture 08: Data Representation: Bits and Ints. John Magee 13 February 2017

CS140 Lecture 08: Data Representation: Bits and Ints. John Magee 13 February 2017 CS140 Lecture 08: Data Representation: Bits and Ints John Magee 13 February 2017 Material From Computer Systems: A Programmer's Perspective, 3/E (CS:APP3e) Randal E. Bryant and David R. O'Hallaron, Carnegie

More information

Memory Allocation I. CSE 351 Autumn Instructor: Justin Hsia

Memory Allocation I. CSE 351 Autumn Instructor: Justin Hsia Memory Allocation I CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun Adapted

More information

CS 33. Data Representation, Part 1. CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CS 33. Data Representation, Part 1. CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. CS 33 Data Representation, Part 1 CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Number Representation Hindu-Arabic numerals developed by Hindus starting in

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = ; c->gals = 7; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp Java: Car c = new

More information

The Hardware/Software Interface CSE351 Spring 2015

The Hardware/Software Interface CSE351 Spring 2015 The Hardware/Software Interface CSE351 Spring 2015 Lecture 26 Instructor: Katelin Bailey Teaching Assistants: Kaleo Brandt, Dylan Johnson, Luke Nelson, Alfian Rizqi, Kritin Vij, David Wong, and Shan Yang

More information

BITS, BYTES, AND INTEGERS

BITS, BYTES, AND INTEGERS BITS, BYTES, AND INTEGERS CS 045 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition ORIGINS

More information

The Hardware/Software Interface CSE351 Spring 2015

The Hardware/Software Interface CSE351 Spring 2015 The Hardware/Software Interface CSE351 Spring 2015 Lecture 6 Instructor: Katelin Bailey Teaching Assistants: Kaleo Brandt, Dylan Johnson, Luke Nelson, Alfian Rizqi, Kritin Vij, David Wong, and Shan Yang

More information

Systems Programming and Computer Architecture ( )

Systems Programming and Computer Architecture ( ) Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-0061-00) Timothy Roscoe Herbstsemester 2016 1 1: Introduction Systems Programming and Computer

More information

The Hardware/Software Interface CSE351 Spring 2015

The Hardware/Software Interface CSE351 Spring 2015 The Hardware/Software Interface CSE351 Spring 2015 Instructor: Katelin Bailey Teaching Assistants: Kaleo Brandt, Dylan Johnson, Luke Nelson, Alfian Rizqi, Kritin Vij, David Wong, and Shan Yang Who are

More information

Caches Spring 2016 May 4: Caches 1

Caches Spring 2016 May 4: Caches 1 May 4: Caches 1 Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret

More information

1 Number Representation(10 points)

1 Number Representation(10 points) Name: Sp15 Midterm Q1 1 Number Representation(10 points) 1 NUMBER REPRESENTATION(10 POINTS) Let x=0xe and y=0x7 be integers stored on a machine with a word size of 4bits. Show your work with the following

More information

Systems Programming and Computer Architecture ( )

Systems Programming and Computer Architecture ( ) (252-0061-00) Timothy Roscoe Herbstsemester 2013 Systems Group Department of Computer Science ETH Zürich 1 1: Introduction 252-0061-00, Herbstsemester 2013 Timothy Roscoe 2 This course covers in depth

More information

x86-64 Programming III

x86-64 Programming III x86-64 Programming III CSE 351 Summer 2018 Instructor: Justin Hsia Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan http://xkcd.com/1652/ Administrivia Homework 2 due Wednesday (7/11) Lab

More information

Cache Wrap Up, System Control Flow

Cache Wrap Up, System Control Flow Cache Wrap Up, System Control Flow CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Boolean Algebra Developed by

More information

Virtual Memory I. CSE 351 Autumn Instructor: Justin Hsia

Virtual Memory I. CSE 351 Autumn Instructor: Justin Hsia Virtual Memory I CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie Tian

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp 0111010000011000

More information

Assembly Programming IV

Assembly Programming IV Assembly Programming IV CSE 410 Winter 2017 Instructor: Justin Hsia Teaching Assistants: Kathryn Chan, Kevin Bi, Ryan Wong, Waylon Huang, Xinyu Sui The Data That Turned the World Upside Down The company

More information

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition Carnegie Mellon 1 Bits, Bytes and Integers Part 1 15-213/18-213/15-513: Introduction to Computer Systems 2 nd Lecture, Aug. 31, 2017 Today s Instructor: Randy Bryant 2 Announcements Recitations are on

More information

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up

More information

x86-64 Programming I CSE 351 Summer 2018 Instructor: Justin Hsia Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan

x86-64 Programming I CSE 351 Summer 2018 Instructor: Justin Hsia Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan x86-64 Programming I CSE 351 Summer 2018 Instructor: Justin Hsia Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan http://www.smbc-comics.com/?id=2999 Administrivia Lab 1b due on Thursday (7/5)

More information

Processes, Virtual Memory I

Processes, Virtual Memory I Processes, Virtual Memory I CSE 351 Summer 2018 Instructor: Justin Hsia Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan http://rebrn.com/re/bad-chrome-1162082/ Administrivia Homework 4 due

More information

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19 Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte

More information

Floating Point II, x86 64 Intro

Floating Point II, x86 64 Intro Floating Point II, x86 64 Intro CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan

More information

Computer Systems CEN591(502) Fall 2011

Computer Systems CEN591(502) Fall 2011 Computer Systems CEN591(502) Fall 2011 Sandeep K. S. Gupta Arizona State University 4 th lecture Data representation in computer systems (Slides adapted from CSAPP book) Announcements Programming assignment

More information

x86-64 Assembly CSE 351 Winter 2018 Instructor: Mark Wyse

x86-64 Assembly CSE 351 Winter 2018 Instructor: Mark Wyse x86-64 Assembly CSE 351 Winter 2018 Instructor: Mark Wyse Teaching Assistants: Kevin Bi Parker DeWilde Emily Furst Sarah House Waylon Huang Vinny Palaniappan http://xkcd.com/409/ Administrivia Lab 1 due

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides

More information

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) Systems Software & Architecture Lab. Seoul National University Integers Spring 2019 4190.308: Computer Architecture Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) 2 A

More information

The Hardware/Software Interface CSE351 Spring 2015

The Hardware/Software Interface CSE351 Spring 2015 The Hardware/Software Interface CSE351 Spring 2015 Lecture 7 Instructor: Katelin Bailey Teaching Assistants: Kaleo Brandt, Dylan Johnson, Luke Nelson, Alfian Rizqi, Kritin Vij, David Wong, and Shan Yang

More information

Assembly Programming I

Assembly Programming I Assembly Programming I CSE 410 Winter 2017 Instructor: Justin Hsia Teaching Assistants: Kathryn Chan, Kevin Bi, Ryan Wong, Waylon Huang, Xinyu Sui Heartbeat could be used as a password to access electronic

More information

CSCI2467: Systems Programming Concepts

CSCI2467: Systems Programming Concepts CSCI2467: Systems Programming Concepts Slideset 2: Information as Data (CS:APP Chap. 2) Instructor: M. Toups Spring 2018 Course updates datalab out today! - due after Mardi gras... - do not wait until

More information

Representation of Information

Representation of Information Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept

More information

Machine Programming. CSE 351 Autumn Instructor: Justin Hsia

Machine Programming. CSE 351 Autumn Instructor: Justin Hsia Machine Programming CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun http://www.smbc

More information

Foundations of Computer Systems

Foundations of Computer Systems 18-600 Foundations of Computer Systems Lecture 3: Bits, Bytes, and Integers September 6, 2017 Required Reading Assignment: Chapter 2 of CS:APP (3 rd edition) by Randy Bryant & Dave O Hallaron Assignments

More information

The Hardware/Software Interface CSE351 Spring 2013 (spring has sprung!)

The Hardware/Software Interface CSE351 Spring 2013 (spring has sprung!) The Hardware/Software Interface CSE351 Spring 2013 (spring has sprung!) Instructor: Luis Ceze Teaching Assistants: Katelin Bailey, Jeremy Lee, Jake Sanders, Rachel Sobel 1 Who is Luis? PhD in architecture,

More information

Survey. Motivation 29.5 / 40 class is required

Survey. Motivation 29.5 / 40 class is required Survey Motivation 29.5 / 40 class is required Concerns 6 / 40 not good at examination That s why we have 3 examinations 6 / 40 this class sounds difficult 8 / 40 understand the instructor Want class to

More information

CS356: Discussion #8 Buffer-Overflow Attacks. Marco Paolieri

CS356: Discussion #8 Buffer-Overflow Attacks. Marco Paolieri CS356: Discussion #8 Buffer-Overflow Attacks Marco Paolieri (paolieri@usc.edu) Previous Example #include void unreachable() { printf("impossible.\n"); void hello() { char buffer[6]; scanf("%s",

More information

C and Programming Basics

C and Programming Basics Announcements Assignment 1 Will be posted on Wednesday, Jan. 9 Due Wednesday, Jan. 16 Piazza Please sign up if you haven t already https://piazza.com/sfu.ca/spring2019/cmpt125 Lecture notes Posted just

More information

Do not turn the page until 5:10.

Do not turn the page until 5:10. University of Washington Computer Science & Engineering Autumn 2018 Instructor: Justin Hsia 2018-10-29 Last Name: First Name: Perfect Perry Student ID Number: 1234567 Name of person to your Left Right

More information