c logistics notes
play

C logistics notes avoid referring to answer letters in your - PowerPoint PPT Presentation

C logistics notes avoid referring to answer letters in your comments question order is randomized (for answers autograded as wrong) we will eventually have TAs look at them note on comments: pre-quiz: released Sat, due Tuesday morning


  1. C logistics notes avoid referring to answer letters in your comments question order is randomized — (for answers autograded as wrong) we will eventually have TAs look at them note on comments: pre-quiz: released Sat, due Tuesday morning post-quiz: released Thursday night, due Sat quizzes 1 1 quiz demo 1 present on slide 27) 24 August 2017: slide 27: remove extraneous * from line 4 (was not 24 August 2017: slide 20 (logical operators): add parenthesis of quiz 24 August 2017: slide 3 (a note on next week’s reading): adjust for lack Corrections made in this version not seen in fjrst lecture: Changelog 2

  2. a note on next week’s reading slides and video and audio on website Friday future weeks: TBA Friday this week: 10AM-11AM; 1PM-2PM Wednesday: 2PM-3PM Monday: 1PM-2PM my offjce hours: all offjce hours on course website TA offjce hours should start next week offjce hours 5 anonymous feedback on Collab exists when I don’t mess up recording slides + audio + feedback we’re starting x86-64 assembly 4 let me know if you don’t have one by Monday if you registered this week, likely today ignore typo of Spring for Fall in email body (subject is okay) they should work now lab accounts 3 we will cover next week quiz will avoid assembly syntax issues some important difgerences (described at end of section 3.3) other syntax: “Intel syntax” using AT&T syntax — not what you learned in 2150 6

  3. processors and memory 0xFFFFFFFF 0x00042004 0x04 0x00042005 0x05 0x00042006 0x06 … … 0xFFFFFFFD 0xDE 0xFFFFFFFE 0x45 0x14 0x00042003 8 memory address value 0xFFFFFFFF 0x14 0xFFFFFFFE 0x45 0xFFFFFFFD 0xDE … … 0x00042006 0x03 0x02 0x00042005 0xA0 … 0x00000002 0xFE 0x00000001 0xE0 0x00000000 0xA0 array of bytes (byte = 8 bits) CPU interprets based on how accessed address value 0x00000000 0x00000001 0x00042002 0xE0 0x00000002 0xFE … … 0x00041FFE 0x60 0x00041FFF 0x03 0x00042000 0x00 0x00042001 0x01 0x06 0x05 0x60 0x03 … 0x00041FFE 0x60 0x00041FFF 0x03 0x00042000 0x00 0x00042001 0x01 0x00042002 0x02 0x00042003 0x00042004 0xFE 0x04 0x00042005 0x05 0x00042006 0x06 … … 0xFFFFFFFD 0xDE 0xFFFFFFFE 0x45 0xFFFFFFFF 0x14 … 0x00000002 0x00042004 … 0x04 0x00042003 0x03 0x00042002 0x02 0x00042001 0x01 0x00042000 0x00 0x00041FFF 0x03 0x00041FFE 0x60 … 0xE0 0x00000002 0xFE 0x00000001 0xE0 0x00000000 0xA0 array of bytes (byte = 8 bits) CPU interprets based on how accessed address value 0x00000000 0xA0 0x00000001 … 0x00041FFE processor 0x00 0x06 0x00042005 0x05 0x00042004 0x04 0x00042003 0x03 0x00042002 0x02 0x00042001 0x01 0x00042000 0x00041FFF … 0x03 0x00041FFE 0x60 … … 0x00000002 0xFE 0x00000001 0xE0 0x00000000 0xA0 array of bytes (byte = 8 bits) CPU interprets based on how accessed 0x00042006 … value CPU: next PC: 0x04001 memory memory bus send address + send or get data I/O Bridge to I/O devices keyboard, mouse, wifj, … system bus send address + send or get data (machine code/text/number…) CPU: send PC: 0x04000 MEM: send machine code: pushq %rbp CPU: send I/O request address: 0xf122003 0xDE I/O: send keystoke: “a” Images: Single core Opteron 8xx die: Dg2fer at the German language Wikipedia, via Wikimedia Commons SDRAM by Arnaud 25, via Wikimedia Commons 7 memory address value 0xFFFFFFFF 0x14 0xFFFFFFFE 0x45 0xFFFFFFFD address 0x00000000 0x03 0x00042006 8 memory address value 0xFFFFFFFF 0x14 0xFFFFFFFE 0x45 0xFFFFFFFD 0xDE … … 0x06 0xFFFFFFFF 0x00042005 0x05 0x00042004 0x04 0x00042003 0x03 0x00042002 0x02 0x00042001 0x01 0x00042000 0x00 0x00041FFF 0x14 0x45 0xA0 0x01 0x00000001 0xE0 0x00000002 0xFE … … 0x00041FFE 0x60 0x00041FFF 0x03 0x00042000 0x00 0x00042001 0x00042002 0xFFFFFFFE 0x02 0x00042003 0x03 0x00042004 0x04 0x00042005 0x05 0x00042006 0x06 … … 0xFFFFFFFD 0xDE 8

  4. endianness 0x00041FFF 0x00042003 0x03 0x00042002 0x02 0x00042001 0x01 0x00042000 0x00 0x03 0x00042004 0x00041FFE 0x60 … … 0x00000002 0xFE 0x00000001 0xE0 0x04 0x05 0xA0 value little endian 9 endianness little endian (least signifjcant byte has lowest address) big endian (most signifjcant byte has lowest address) address 0xFFFFFFFF 0x00042005 0x14 0xFFFFFFFE 0x45 0xFFFFFFFD 0xDE … … 0x00042006 0x06 0x00000000 int * x = (int*)0x42000; 50462976 0x00041FFE 0x00042002 0x02 0x00042001 0x01 0x00042000 0x00 0x00041FFF 0x03 0x60 0x00042003 … … 0x00000002 0xFE 0x00000001 0xE0 0x00000000 0xA0 int * x = (int*)0x42000; 0x03 0x04 9 0x14 endianness little endian (least signifjcant byte has lowest address) big endian (most signifjcant byte has lowest address) address value 0xFFFFFFFF 0xFFFFFFFE 0x00042004 0x45 0xFFFFFFFD 0xDE … … 0x00042006 0x06 0x00042005 0x05 0x00010203 66051 0x03020100 … 0x00042001 0x01 0x00042000 0x00 0x00041FFF 0x03 0x00041FFE 0x60 … 0x00042002 0x00000002 0xFE 0x00000001 0xE0 0x00000000 0xA0 int * x = (int*)0x42000; 0x03020100 0x02 0x03 0x00010203 0x45 (least signifjcant byte has lowest address) big endian (most signifjcant byte has lowest address) address value 0xFFFFFFFF 0x14 0xFFFFFFFE 0xFFFFFFFD 0x00042003 0xDE … … 0x00042006 0x06 0x00042005 0x05 0x00042004 0x04 50462976 9 66051 0x03 0x00042003 0x03 0x00042002 0x02 0x00042001 0x01 0x00042000 0x00 0x00041FFF 0x00041FFE 0x00042004 0x60 … … 0x00000002 0xFE 0x00000001 0xE0 0x00000000 0xA0 int * x = (int*)0x42000; 9 0x04 0x05 0xFFFFFFFF endianness little endian (least signifjcant byte has lowest address) big endian (most signifjcant byte has lowest address) 0x00042005 value address 0x14 … 0x06 0xFFFFFFFE 0x00042006 … 0xDE 0xFFFFFFFD 0x45 cout << * x << endl ; cout << * x << endl ; cout << * x << endl ; cout << * x << endl ; 0x03020100 = 50462976 0x03020100 = 50462976 0x00010203 = 66051 0x00010203 = 66051

  5. endianness 0xFFFF 8000 0000 0000 argument 6 … copied from executable fjle “top” has smallest address stack grows down 0x0000 0000 0040 0000 Code + Constants Writable data Heap / other dynamic 0x7F… Stack 0xFFFF FFFF FFFF FFFF … Used by OS program memory (x86-64 Linux) 10 (next thing on stack) local variables callee saved registers return address … argument 7 argument 6 … argument 7 return address “top” has smallest address 0x0000 0000 0040 0000 (next thing on stack) local variables callee saved registers return address … argument 7 argument 6 … copied from executable fjle “top” has smallest address stack grows down Code + Constants callee saved registers Writable data Heap / other dynamic 0x7F… Stack 0xFFFF 8000 0000 0000 0xFFFF FFFF FFFF FFFF Used by OS program memory (x86-64 Linux) 10 (next thing on stack) local variables copied from executable fjle stack grows down little endian … 0x00042001 0x02 0x00042002 0x03 0x00042003 0x04 0x00042004 0x05 0x00042005 0x06 0x00042006 … 0x00042000 0xDE 0xFFFFFFFD 0x45 0xFFFFFFFE 0x14 0xFFFFFFFF value address (most signifjcant byte has lowest address) big endian (least signifjcant byte has lowest address) 0x01 0x00 0x0000 0000 0040 0000 0x00041FFF Code + Constants Writable data Heap / other dynamic 0x7F… Stack 0xFFFF 8000 0000 0000 0xFFFF FFFF FFFF FFFF Used by OS program memory (x86-64 Linux) 9 10 int * x = (int*)0x42000; 0xA0 0x00000000 0xE0 0x00000001 0xFE 0x00000002 … … 0x60 0x00041FFE 0x03 cout << * x << endl ; 0x03020100 = 50462976 0x00010203 = 66051

  6. program memory (x86-64 Linux) x += y Gates / Transistors / Wires / Registers ??? 6 0 03 SIXTEEN Machine code: Y86 add %rbx, %rax Assembly: X86-64 “Higher-level” language: C compilation commands layers of abstraction 10 (next thing on stack) local variables callee saved registers return address 11 compile: argument 7 c+a: … file gcc -o file file.c c+a+l: file.o gcc -c file.c file (executable) gcc -S file.c gcc -o file file.o link: file.o (object fjle) gcc -c file.s assemble: file.s (assembly) Used by OS … argument 6 0x0000 0000 0040 0000 argument 7 argument 6 … copied from executable fjle “top” has smallest address stack grows down Code + Constants return address Writable data Heap / other dynamic 0x7F… Stack 0xFFFF 8000 0000 0000 0xFFFF FFFF FFFF FFFF … … callee saved registers local variables copied from executable fjle “top” has smallest address stack grows down 0x0000 0000 0040 0000 Code + Constants Writable data Heap / other dynamic 0x7F… 12 Stack 0xFFFF 8000 0000 0000 0xFFFF FFFF FFFF FFFF Used by OS program memory (x86-64 Linux) 10 (next thing on stack) ⇒ ⇒ ⇒ ⇒ ⇒

Recommend


More recommend