CS-220 Spring 2018 Final Exam Version Practice May 10, Name:
|
|
- Shon Jefferson
- 5 years ago
- Views:
Transcription
1 CS-220 Spring 2018 Final Exam Version Practice May 10, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : One of the advantages of using the make command is that if the Makefile is written correctly, make guarantees that all of the pre-requisite steps in a build process are completed before executing a final step. (b) T F : The UNIX command./mypgm <test.txt >msgs.txt connects the standard input stream to file test.txt, and connects the standard error stream to msgs.txt. (c) T F : In an assignment statement, C will convert the value of the expression on the right hand side of the equals sign to the type of the left hand side, even if this causes the value of the expression to change. (d) T F : One of the most powerful concepts of the C programming language is the ability to treat a complex function as a simple abstract mechanism which reads arguments, and returns a value. (e) T F : When you invoke a C function, the values of the argument expressions are copied to the parameters of the function. (f) T F : An if/else statement is an example of sequential control flow in the C language. (g) T F : The same bits in memory are always interpreted to be the same value, no matter what type is associated with those bits. (h) T F : It is important that an older version of an ISA support everyting in a newer version of the same ISA so that new software can be run on both old and new hardware. (i) T F : In X86-64, the stack grows by making the value in the %rsp register smaller, which moves the push/pop end of the stack towards a lower address in memory. (j) T F : One of the disadvantages of a direct map cache is that it is difficult to find a victim cache line when there is a cache miss. For the following questions, check the best answer. 2. (5 points) A typedef statement is useful in C for all of the following except: Making it clear to the programmer that a parameter to a function is a special kind of (for instance) integer. Simplifying the declaration of variables of a complicated type. Modifying the behavior of the C operators such as + or *. Enable library code to change the type of a class of variables with a single edit and recompile. Hiding the details of a complicated type to allow a programmer to deal with that type as an abstraction. Page 1 of 10
2 3. (5 points) What will get printed by the following code snippet? int x ; int sum=0; for ( x=0;x<10;x++) { int x= 2; sum +=x ; p r i n t f ( x=%d sum=%d\n, x, sum ) ; x=11 sum=52 Compiler Error x=-2 sum=-20 x=10 sum=-20 x=-2 sum=52 4. (5 points) If a floating point number is represented by the bits 0x f, then the floating point value of that number is: Less than -2 to the -127 Greater than -2 to the -127, but less than 0 Zero Greater than zero, but less than 2 to the Greater than 2 to the (5 points) The assignment on line 13 of Listing 1 on page 7 is implement by instructions at what range of offsets in Listing 2 on page 8? (Hint, a question mark has an ASCII code of 0x3f.) a-72e c 76f-773 None of the above 6. (5 points) The for statement on line 27 of Listing 1 on page 7 is implement by instructions at which ranges of offsets in Listing 3 on page 8? Check all that apply. (Hint, a lowercase a has an ASCII code of 0x61, and z has a code of 0x7a.) 7ba-7be 7c5-7c9 7cb-7cf 7fe c None of the above 7. (5 points) In Listing 4 on page 9, the countletters function creates its own stack frame in instructions at 814 and 815, but does not subtract from %rsp to create extra room for local variables, even though it uses memory at locations like -0x18(%rbp) and -0x1c(%rbp). Check all of the reasons below why this is valid. The operating system and all other processes are not allowed to change memory in the red zone. Data in the heap (obtained by malloc) cannot overlap with the stack area in memory. The topletter function never pushes or pops on the stack. The countletters function does not call any lower level functions. It is a leaf function, and therefore no function creates a stack frame below countletter s stack frame. If this were not valid, it would cause a segmentation violation, and the compiler never allows code to be generated that would cause a segmentation violation. None of the above Page 2 of 10
3 8. (5 points) Figure 1 on page 10 is a snapshot of the stack memory when running the code in Listing 1 on page 7. Using this stack information and the x86 assembler code in Listing 2 on page 8, Listing 3 on page 8 and Listing 4 on page 9, check all of the true statements below. The current stack frame contains a single eight byte word that points to its caller s %rbp. By looking at the address at %rbp+8, we can find the return address for the current function. The caller of the current function is the main function. The caller of the current function is the topletter function. The call to the current function was generated from line 28 in Listing 1 on page 7. The call to the current function was generated from line 30 in Listing 1 on page (5 points) Check all of the true statements below that represent benefits of using cache memory. Computers with caches are cheaper than computers without caches. Computers with caches are faster that computers without caches because the cache almost always supplies data to the ALU at high speed. Caches make understanding how the insides of a computer work much simpler. Caches allow an abstract view of memory as a large indexable array of bytes, even though the concrete implementation of memory is more complicated. Even though caches almost always make computers run much faster, there are some programs that cause a low cache hit rate, and run very slowly on a computer with cache. There is only one way to implement cache - using the set bits in an address to index into a single cache line. 10. (5 points) An ELF executable file is used to load binary data into memory. Check all the true statements below about which sections of an ELF executable file are loaded into memory. The.code section which contains the man-readable X86 assembler code for the program. The.text section, which contains the binary machine instructions to execute. The.wodata section which contains all the variables in the program that can be written, but not read from memory. The.data section which contains initial values for all initialize global variables in the program. The.scope section which contains information about the scope of each variable in the code. The.rodata section which contains program data that cannot change, such as constants and literal data. Page 3 of 10
4 Answer the following questions by filling in the blanks. 11. (5 points) What is does the following code snippet print to stdout? int mat [ 2 ] [ 3 ] [ 4 ] ; int s l i c e ; int row ; int c o l ; for ( s l i c e =0; s l i c e <2; s l i c e ++) { for ( row=0;row <3;row++) { for ( c o l =0; col <4; c o l++) { mat [ s l i c e ] [ row ] [ c o l ] = s l i c e 20 + row 5 + c o l ; p r i n t f ( mat [ 1 ] [ 2 ] [ 3 ] = % d\n, mat [ 1 ] [ 2 ] [ 3 ] ) ; 12. Given the following snippet of code: int i ; for ( i =0; i <100; i ++) { i f (0== i %2) continue ; i f (0== i %4) p r i n t f ( You won $100! \ n ) ; i f ( i >15) break ; p r i n t f ( The f i n a l value o f i i s %d\n, i ) ; (a) (2 points) Will the code snippet above print out You won $100!? (b) (3 points) The code snippet above will print out The final value of i is 13. (5 points) If the program in Listing 1 on page 7 is compiled int maxletter, and invoked as./maxletter testing good letters, what will get printed to stdout? 14. (5 points) Given the C program in Listing 1 on page 7, which the compiler translated to X86 assembler code in Listing 3 on page 8, and given the stack data from this program in figure 1 on page 10, what is the value of the maxusage variable in the stack frame associated with the topletter function? Page 4 of 10
5 15. And finally, an exercise in writing and reading code. Consider the following program: #include <s t d i o. h> #include <s t d l i b. h> #include <s t r i n g. h> #include <time. h> char randchar ( ) ; int main ( int argc, char argv ) { t i m e t t ; srand ( ( unsigned ) time(&t ) ) ; int n=a t o i ( argv [ 1 ] ) ; int cn =1; char c ; while (EOF!=( c=getchar ( ) ) ) { int i ; for ( i =0; i<cn ; i ++) putchar ( i ==0?c : randchar ( ) ) ; cn++; i f ( cn>n ) cn =1; return 0 ; char randchar ( ) { char l t r s []= abcdefghijklmnopqrstuvwxyz ; return l t r s [ rand ()% s t r l e n ( l t r s ) ] ; If this code is compiled as executable file encode, then the command echo "This is a test"./encode 3... would (possibly) write the following string to stdout... Thbilps jidgs rajx tceuyste (a) (25 points) Write a C program (including the main function) which takes a single number as the command line argument, and decodes the encoded result as specified by the encode function above. For instance, the command... echo "This is a test"./encode 3./decode 3... would write the string This is a test to stdout. Page 5 of 10
6 (b) (10 points (bonus)) If your code from the previous question works correctly, and is compiled as decode, what will get written to stdout as a result of the following command: echo "I taopcekdbr thhwpism ontedssxt" decode 3 Page 6 of 10
7 Tear-off Page Listing 1: maxletter.c 1 #include <s t d i o. h> 2 char t o p L e t t e r ( char s t r ) ; 3 int c o u n t L e t t e r s ( char s tr, char l e t ) ; 4 5 int main ( int argc, char argv ) { 6 char maxletter=? ; 7 char maxcount=0; 8 int maxarg=0; 9 int i ; 10 for ( i =1; i<argc ; i ++) { 11 char l e t t e r=t o p L e t t e r ( argv [ i ] ) ; 12 i f ( maxcount < c o u n t L e t t e r s ( argv [ i ], l e t t e r ) ) { 13 maxletter=l e t t e r ; 14 maxcount=c o u n t L e t t e r s ( argv [ i ], l e t t e r ) ; 15 maxarg=i ; p r i n t f ( Arg : %s has l e t t e r %c used %d times \n, 19 argv [ maxarg ], maxletter, maxcount ) ; 20 return 0 ; char t o p L e t t e r ( char s t r ) { 24 char l e t ; 25 char maxletter=? ; 26 int maxusage=0; 27 for ( l e t= a ; l e t <= z ; l e t ++) { 28 i f ( c o u n t L e t t e r s ( s t r, l e t ) > maxusage ) { 29 maxletter=l e t ; 30 maxusage=c o u n t L e t t e r s ( str, l e t ) ; return maxletter ; int c o u n t L e t t e r s ( char s tr, char l e t ) { 37 int count =0; 38 for ( ; ( s t r )!=0 x00 ; s t r++) i f ( ( s t r)== l e t ) count++; 39 return count ; 40 Page 7 of 10
8 Tear-off Page Listing 2: maxletter.objdump.txt(main) b0 <main >: 6b0 : push %rbp 6b1 : mov %rsp,%rbp 6b4 : push %rbx 6b5 : sub $0x28,%rsp 6b9 : mov %edi, 0x24(%rbp) 6bc : mov %rsi, 0x30(%rbp) 6 c0 : movb $0x3f, 0 x11(%rbp) 6 c4 : movb $0x0, 0x12(%rbp) 6 c8 : movl $0x0, 0x18(%rbp) 6 c f : movl $0x1, 0 x1c(%rbp) 6d6 : jmpq 763 <main+0xb3> 6db : mov 0x1c(%rbp),%eax 6de : cltq 6 e0 : lea 0x0(,%rax,8),%rdx 6 e8 : mov 0x30(%rbp),%rax 6 ec : add %rdx,%rax 6 e f : mov (%rax),%rax 6 f 2 : mov %rax,%rdi 6 f 5 : callq 7 ae <topletter > 6 f a : mov %al, 0x1d(%rbp) 6 fd : movsbl 0x12(%rbp),%ebx : movsbl 0x1d(%rbp),%edx : mov 0x1c(%rbp),%eax : cltq 70a : lea 0x0(,%rax,8),% rcx : mov 0x30(%rbp),%rax : add %rcx,%rax : mov (%rax),%rax 71 c : mov %edx,% e s i 71 e : mov %rax,% rdi : callq 814 <countletters > : cmp %eax,%ebx : jge 75 f <main+0xaf> 72 a : movzbl 0x1d(%rbp),%eax 72 e : mov %al, 0x11(%rbp) : movsbl 0x1d(%rbp),%edx : mov 0x1c(%rbp),%eax : cltq 73a : lea 0x0(,%rax,8),% rcx : mov 0x30(%rbp),%rax : add %rcx,%rax : mov (%rax),%rax 74 c : mov %edx,% e s i 74 e : mov %rax,% rdi : callq 814 <countletters > : mov %al, 0x12(%rbp) : mov 0x1c(%rbp),%eax 75 c : mov %eax, 0 x18(%rbp) 75 f : addl $0x1, 0 x1c(%rbp) : mov 0x1c(%rbp),%eax : cmp 0x24(%rbp),%eax : j l 6db <main+0x2b> 76 f : movsbl 0x12(%rbp),% ecx : movsbl 0x11(%rbp),%edx : mov 0x18(%rbp),%eax 77a : cltq 77 c : lea 0x0(,%rax,8),% r s i : mov 0x30(%rbp),%rax : add %rsi,%rax 78b : mov (%rax),%rax 78 e : mov %rax,% r s i : lea 0 x140(%rip ),% rdi : mov $0x0,%eax 79d : callq 560 <p r i n t p l t > 7 a2 : mov $0x0,%eax 7 a7 : add $0x28,%rsp 7ab : pop %rbx 7 ac : pop %rbp 7ad : retq Listing 3: maxletter.objdump.txt(topletter) ae <topletter >: 7 ae : push %rbp 7 a f : mov %rsp,%rbp 7b2 : sub $0x20,%rsp 7b6 : mov %rdi, 0x18(%rbp) 7ba : movb $0x3f, 0x2(%rbp) 7be : movl $0x0, 0x8(%rbp) 7 c5 : movb $0x61, 0x1(%rbp) 7 c9 : jmp 808 <t o p L e t t e r+0x5a> 7cb : movsbl 0x1(%rbp),%edx 7 c f : mov 0x18(%rbp),%rax 7d3 : mov %edx,% e s i 7d5 : mov %rax,% rdi 7d8 : callq 814 <countletters > 7dd : cmp 0x8(%rbp),%eax 7 e0 : j l e 7 f e <t o p L e t t e r+0x50> 7 e2 : movzbl 0x1(%rbp),%eax 7 e6 : mov %al, 0x2(%rbp) 7 e9 : movsbl 0x1(%rbp),%edx 7ed : mov 0x18(%rbp),%rax 7 f 1 : mov %edx,% e s i 7 f 3 : mov %rax,%rdi 7 f 6 : callq 814 <countletters > 7 fb : mov %eax, 0x8(%rbp) 7 f e : movzbl 0x1(%rbp),%eax : add $0x1,%eax : mov %al, 0x1(%rbp) : cmpb $0x7a, 0x1(%rbp) 80 c : j l e 7cb <t o p L e t t e r+0x1d> 80 e : movzbl 0x2(%rbp),%eax : leaveq : retq Page 8 of 10
9 Tear-off Page Listing 4: maxletter.objdump.txt(countletters) <countletters >: : push %rbp : mov %rsp,%rbp : mov %rdi, 0x18(%rbp) 81 c : mov %esi,%eax 81 e : mov %al, 0 x1c(%rbp) : movl $0x0, 0x4(%rbp) : jmp 83 f <c o u n t L e t t e r s+0x2b> 82a : mov 0x18(%rbp),%rax 82 e : movzbl (%rax),%eax : cmp 0x1c(%rbp),% al : jne 83a <c o u n t L e t t e r s+0x26> : addl $0x1, 0x4(%rbp) 83a : addq $0x1, 0x18(%rbp) 83 f : mov 0x18(%rbp),%rax : movzbl (%rax),%eax : test %al,% al : jne 82a <c o u n t L e t t e r s+0x16> 84a : mov 0x4(%rbp),%eax 84d : pop %rbp 84 e : retq Page 9 of 10
10 Tear-off Page Figure 1: Contents of maxletter Stack Memory Address Value Comments 64 bit, big-endian 0x7fffffffe870 0x f7b9b2e8 0x7fffffffe868 0x00007fffffffe938 0x7fffffffe860 0x x7fffffffe858 0x00007ffff7a5a2b1 0x7fffffffe850 0x x7fffffffe848 0x x7fffffffe840 0x00007fffffffe930 0x7fffffffe838 0x x7fffffffe830 0x x7fffffffe828 0x x7fffffffe820 0x00007fffffffe938 0x7fffffffe818 0x fa 0x7fffffffe810 0x00007fffffffe850 0x7fffffffe808 0x x7fffffffe800 0x00007fffffffe82e 0x7fffffffe7f8 0x00007fffffffec3c 0x7fffffffe7f0 0x c2 0x7fffffffe7e8 0x fb 0x7fffffffe7e0 0x00007fffffffe810 %rsp,%rbp 0x7fffffffe7d8 0x x7fffffffe7d0 0x x7fffffffe7c8 0x00007fffffffec3c 0x7fffffffe7c0 0x t.... 0x7fffffffe7b8 0x x7fffffffe7b0 0x x7fffffffe7a8 0x x7fffffffe7a0 0x Page 10 of 10
CS-220 Spring 2018 Test 2 Version Practice Apr. 23, Name:
CS-220 Spring 2018 Test 2 Version Practice Apr. 23, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : The main difference between
More informationBinghamton University. CS-220 Spring X86 Debug. Computer Systems Section 3.11
X86 Debug Computer Systems Section 3.11 GDB is a Source Level debugger We have learned how to debug at the C level But the machine is executing X86 object code! How does GDB play the shell game? Makes
More informationDownload the tarball for this session. It will include the following files:
Getting Started 1 Download the tarball for this session. It will include the following files: driver driver.c bomb.h bomb.o 64-bit executable C driver source declaration for "bomb" 64-bit object code for
More informationCSE 351 Midterm - Winter 2015 Solutions
CSE 351 Midterm - Winter 2015 Solutions February 09, 2015 Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate
More informationCSE 351 Midterm - Winter 2015
CSE 351 Midterm - Winter 2015 February 09, 2015 Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate will prove
More informationDownload the tarball for this session. It will include the following files:
Getting Started 1 Download the tarball for this session. It will include the following files: driver driver.c bomb.h bomb.o 64-bit executable C driver source declaration for "bomb" 64-bit object code for
More informationCS 261 Fall Machine and Assembly Code. Data Movement and Arithmetic. Mike Lam, Professor
CS 261 Fall 2018 0000000100000f50 55 48 89 e5 48 83 ec 10 48 8d 3d 3b 00 00 00 c7 0000000100000f60 45 fc 00 00 00 00 b0 00 e8 0d 00 00 00 31 c9 89 0000000100000f70 45 f8 89 c8 48 83 c4 10 5d c3 Mike Lam,
More information1 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 informationCSCI 2021: x86-64 Control Flow
CSCI 2021: x86-64 Control Flow Chris Kauffman Last Updated: Mon Mar 11 11:54:06 CDT 2019 1 Logistics Reading Bryant/O Hallaron Ch 3.6: Control Flow Ch 3.7: Procedure calls Goals Jumps and Control flow
More information15-213/18-243, Spring 2011 Exam 1
Andrew login ID: Full Name: Section: 15-213/18-243, Spring 2011 Exam 1 Thursday, March 3, 2011 (v1) Instructions: Make sure that your exam is not missing any sheets, then write your Andrew login ID, full
More informationCS356: 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 informationLab 7 Linux Debugging. EECS 448: Software Engineering I Mark Calnon October 17, 2011
Lab 7 Linux Debugging EECS 448: Software Engineering I Mark Calnon October 17, 2011 GDB Getting Started To start gdb from the command line, first browse to the directory containing the core dump to debug
More informationCS356: Discussion #7 Buffer Overflows. Marco Paolieri
CS356: Discussion #7 Buffer Overflows Marco Paolieri (paolieri@usc.edu) Array Bounds class Bounds { public static void main(string[] args) { int[] x = new int[10]; for (int i = 0; i
More informationCSE351 Autumn 2012 Midterm Exam (5 Nov 2012)
CSE351 Autumn 2012 Midterm Exam (5 Nov 2012) Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate will prove to
More informationComputer Systems C S Cynthia Lee
Computer Systems C S 1 0 7 Cynthia Lee 2 Today s Topics Code optimization! Optimization reality check Don t let it be your Waterloo. 4 Optimization Reality Check Optimization is really exciting but it
More informationCSE 351 Midterm Exam
University of Washington Computer Science & Engineering Winter 2018 Instructor: Mark Wyse February 5, 2018 CSE 351 Midterm Exam Last Name: First Name: SOLUTIONS UW Student ID Number: UW NetID (username):
More informationCSE 351 Spring 2017 Midterm Exam (8 May 2017)
CSE 351 Spring 2017 Midterm Exam (8 May 2017) Please read through the entire examination first! You have 50 minutes for this exam. Don t spend too much time on any one problem! The last page is a reference
More informationDo 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: Student ID Number: Name of person to your Left Right All work is my own. I
More information15-213/18-243, Fall 2010 Exam 1 - Version A
Andrew login ID: Full Name: Section: 15-213/18-243, Fall 2010 Exam 1 - Version A Tuesday, September 28, 2010 Instructions: Make sure that your exam is not missing any sheets, then write your Andrew login
More informationCS 107 Lecture 10: Assembly Part I
CS 107 Lecture 10: Assembly Part I Friday, February 9th, 2018 Computer Systems Winter 2018 Stanford University Computer Science Department Reading: Course Reader: x86-64 Assembly Language, Textbook: Chapter
More informationQuestion 1: Number Representation
Question 1: Number Representation (A) What is the value of the char 0b 1101 1101 in decimal? If x = 0xDD, x = 0x23 = 2 5 +3 = 35 Also accepted unsigned: 0xDD = (16+1)*13 = 221-35 or 221 (B) What is the
More informationUniversity 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 informationBuffer Overflow Attack (AskCypert CLaaS)
Buffer Overflow Attack (AskCypert CLaaS) ---------------------- BufferOverflow.c code 1. int main(int arg c, char** argv) 2. { 3. char name[64]; 4. printf( Addr;%p\n, name); 5. strcpy(name, argv[1]); 6.
More informationHow Software Executes
How Software Executes CS-576 Systems Security Instructor: Georgios Portokalidis Overview Introduction Anatomy of a program Basic assembly Anatomy of function calls (and returns) Memory Safety Intel x86
More informationComputer Systems C S Cynthia Lee
Computer Systems C S 1 0 7 Cynthia Lee 2 Today s Topics Function call and return in x86-64 Registers Call stack NEXT TIME: NEW topic: the build process Taking a look at each step of the process Preprocessor,
More information18-600: Recitation #4 Exploits
18-600: Recitation #4 Exploits 20th September 2016 Agenda More x86-64 assembly Buffer Overflow Attack Return Oriented Programming Attack 3 Recap: x86-64: Register Conventions Arguments passed in registers:
More information1. A student is testing an implementation of a C function; when compiled with gcc, the following x86-64 assembly code is produced:
This assignment refers to concepts discussed in sections 2.1.1 2.1.3, 2.1.8, 2.2.1 2.2.6, 3.2, 3.4, and 3.7.1of csapp; see that material for discussions of x86 assembly language and its relationship to
More informationCSE 351 Midterm - Winter 2017
CSE 351 Midterm - Winter 2017 February 08, 2017 Please read through the entire examination first, and make sure you write your name and NetID on all pages! We designed this exam so that it can be completed
More informationProcedures and the Call Stack
Procedures and the Call Stack Topics Procedures Call stack Procedure/stack instructions Calling conventions Register-saving conventions Why Procedures? Why functions? Why methods? int contains_char(char*
More information15-213/18-213, Fall 2011 Exam 1
Andrew ID (print clearly!): Full Name: 15-213/18-213, Fall 2011 Exam 1 Tuesday, October 18, 2011 Instructions: Make sure that your exam is not missing any sheets, then write your Andrew ID and full name
More informationCS , Fall 2007 Exam 1
Andrew login ID: Full Name: CS 15-213, Fall 2007 Exam 1 Wednesday October 17, 2007 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the
More informationCS377P Programming for Performance Single Thread Performance In-order Pipelines
CS377P Programming for Performance Single Thread Performance In-order Pipelines Sreepathi Pai UTCS September 9, 2015 Outline 1 Introduction 2 Pipeline Preliminaries 3 The Inorder Pipeline and Performance
More informationCS377P Programming for Performance Leveraging the Compiler for Performance
CS377P Programming for Performance Leveraging the Compiler for Performance Sreepathi Pai UTCS October 5, 2015 Outline 1 Compiler Performance 2 Compiler Internals 3 Domain-specific Languages (DSLs) Outline
More informationMachine/Assembler Language Putting It All Together
COMP 40: Machine Structure and Assembly Language Programming Fall 2015 Machine/Assembler Language Putting It All Together Noah Mendelsohn Tufts University Email: noah@cs.tufts.edu Web: http://www.cs.tufts.edu/~noah
More informationCSE351 Autumn 2014 Midterm Exam (29 October 2014)
CSE351 Autumn 2014 Midterm Exam (29 October 2014) Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate will prove
More informationBuffer Overflow. An Introduction
Buffer Overflow An Introduction Workshop Flow-1 Revision (4-10) How a program runs Registers Memory Layout of a Process Layout of a StackFrame Layout of stack frame using GDB and looking at Assembly code
More informationCSE351 Autumn 2014 Midterm Exam (29 October 2014)
CSE351 Autumn 2014 Midterm Exam (29 October 2014) (Version A) Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate
More informationAreas for growth: I love feedback
Assembly part 2 1 Areas for growth: I love feedback Speed, I will go slower. Clarity. I will take time to explain everything on the slides. Feedback. I give more Kahoot questions and explain each answer.
More informationC to Assembly SPEED LIMIT LECTURE Performance Engineering of Software Systems. I-Ting Angelina Lee. September 13, 2012
6.172 Performance Engineering of Software Systems SPEED LIMIT PER ORDER OF 6.172 LECTURE 3 C to Assembly I-Ting Angelina Lee September 13, 2012 2012 Charles E. Leiserson and I-Ting Angelina Lee 1 Bugs
More informationGeneration. representation to the machine
Unoptimized i Code Generation From the intermediate representation to the machine code 5 Outline Introduction Machine Language Overview of a modern processor Memory Layout Procedure Abstraction Procedure
More informationCSE 351 Midterm Exam Spring 2016 May 2, 2015
Name: CSE 351 Midterm Exam Spring 2016 May 2, 2015 UWNetID: Solution Please do not turn the page until 11:30. Instructions The exam is closed book, closed notes (no calculators, no mobile phones, no laptops,
More informationDo 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 informationDo not turn the page until 12:30.
University of Washington Computer Science & Engineering Autumn 2016 Instructor: Justin Hsia 2016-12-13 Last Name: First Name: Student ID Number: Section you attend (circle): Chris Yufang John Kevin Sachin
More informationDo 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 informationMachine Program: Procedure. Zhaoguo Wang
Machine Program: Procedure Zhaoguo Wang Requirements of procedure calls? P() { y = Q(x); y++; 1. Passing control int Q(int i) { int t, z; return z; Requirements of procedure calls? P() { y = Q(x); y++;
More information18-600: Recitation #4 Exploits (Attack Lab)
18-600: Recitation #4 Exploits (Attack Lab) September 19th, 2017 Announcements Some students have triggered the bomb multiple times Use breakpoints for explode_bomb() Attack lab will be released on Sep.
More informationMachine Language CS 3330 Samira Khan
Machine Language CS 3330 Samira Khan University of Virginia Feb 2, 2017 AGENDA Logistics Review of Abstractions Machine Language 2 Logistics Feedback Not clear Hard to hear Use microphone Good feedback
More informationUniversity of Washington Computer Science & Engineering Winter 2018 Instructor: Mark Wyse March 14, CSE 351 Final Exam. Last Name: First Name:
University of Washington Computer Science & Engineering Winter 2018 Instructor: Mark Wyse March 14, 2018 CSE 351 Final Exam Last Name: First Name: UW Student ID Number: UW NetID (username): Academic Integrity
More informationBinghamton University. CS-220 Spring x86 Assembler. Computer Systems: Sections
x86 Assembler Computer Systems: Sections 3.1-3.5 Disclaimer I am not an x86 assembler expert. I have never written an x86 assembler program. (I am proficient in IBM S/360 Assembler and LC3 Assembler.)
More informationChangelog. Assembly (part 1) logistics note: lab due times. last time: C hodgepodge
Changelog Assembly (part 1) Corrections made in this version not seen in first lecture: 31 August 2017: slide 34: split out from previous slide; clarify zero/positive/negative 31 August 2017: slide 26:
More information15-213, Fall 2007 Midterm Exam
Andrew login ID: Full Name: 15-213, Fall 2007 Midterm Exam October 17, 2007, 1:00pm-2:20pm Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID
More informationCorrections made in this version not seen in first lecture:
Assembly (part 1) 1 Changelog 1 Corrections made in this version not seen in first lecture: 31 August 2017: slide 34: split out from previous slide; clarify zero/positive/negative 31 August 2017: slide
More informationQuestion F5: Caching [10 pts]
Question F5: Caching [ pts] SID: We have 6 KiB of RAM and two options for our cache. Both are two-way set associative with 256 B blocks, LRU replacement, and write-back policies. Cache A is size KiB and
More informationHow Software Executes
How Software Executes CS-576 Systems Security Instructor: Georgios Portokalidis Overview Introduction Anatomy of a program Basic assembly Anatomy of function calls (and returns) Memory Safety Programming
More informationDo 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 informationCS 33. Linkers. CS33 Intro to Computer Systems XXV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Linkers CS33 Intro to Computer Systems XXV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. gcc Steps 1) Compile to start here, supply.c file to stop here: gcc -S (produces.s file) if not
More informationBuffer Overflows Many of the following slides are based on those from Complete Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective (CS:APP) Randal E. Bryant and David R. O'Hallaron
More informationCSE351 Spring 2018, Midterm Exam April 27, 2018
CSE351 Spring 2018, Midterm Exam April 27, 2018 Please do not turn the page until 11:30. Last Name: First Name: Student ID Number: Name of person to your left: Name of person to your right: Signature indicating:
More informationDo not turn the page until 12:30.
University of Washington Computer Science & Engineering Autumn 2017 Instructor: Justin Hsia 2017-12-13 Last Name: First Name: Student ID Number: Name of person to your Left Right All work is my own. I
More informationCS 107. Lecture 13: Assembly Part III. Friday, November 10, Stack "bottom".. Earlier Frames. Frame for calling function P. Increasing address
CS 107 Stack "bottom" Earlier Frames Lecture 13: Assembly Part III Argument n Friday, November 10, 2017 Computer Systems Increasing address Argument 7 Frame for calling function P Fall 2017 Stanford University
More informationCSCI 356 Fall 2017 : Practice Exam I DO NOT OPEN EXAM PACKET UNTIL INSTRUCTED TO DO SO YOU MAY FILL IN INFORMATION ON THE FRONT NOW
CSCI 356 Fall 2017 : Practice Exam I DO NOT OPEN EXAM PACKET UNTIL INSTRUCTED TO DO SO YOU MAY FILL IN INFORMATION ON THE FRONT NOW PLEASE TURN OFF ALL ELECTRONIC DEVICES ID#: Name: This exam is closed
More informationMachine Programming 3: Procedures
Machine Programming 3: Procedures CS61, Lecture 5 Prof. Stephen Chong September 15, 2011 Announcements Assignment 2 (Binary bomb) due next week If you haven t yet please create a VM to make sure the infrastructure
More informationDo not turn the page until 11:30.
University of Washington Computer Science & Engineering Autumn 2016 Instructor: Justin Hsia 2016-11-02 Last Name: First Name: Perfect Perry Student ID Number: 1234567 Section you attend (circle): Chris
More informationCS-220 Spring 2018 Test 1 Version A Feb. 28, Name:
CS-220 Spring 2018 Test 1 Version A Feb. 28, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : Every function definition in C must
More informationCS , Spring 2002 Exam 2
Full Name: CS 15-213, Spring 2002 Exam 2 March 28, 2002 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write your answers
More informationCSE 351 Section 4 GDB and x86-64 Assembly Hi there! Welcome back to section, we re happy that you re here
CSE 351 Section 4 GDB and x86-64 Assembly Hi there! Welcome back to section, we re happy that you re here x86-64 Assembly Language Assembly language is a human-readable representation of machine code instructions
More informationDo not turn the page until 12:30.
University of Washington Computer Science & Engineering Autumn 2016 Instructor: Justin Hsia 2016-12-13 Last Name: First Name: Perfect Perry Student ID Number: 1234567 Section you attend (circle): Chris
More informationUniversity of Washington Computer Science & Engineering Winter 2018 Instructor: Mark Wyse March 14, CSE 351 Final Exam. Last Name: First Name:
University of Washington Computer Science & Engineering Winter 2018 Instructor: Mark Wyse March 14, 2018 CSE 351 Final Exam Last Name: First Name: Solutions UW Student ID Number: UW NetID (username): Academic
More informationCS 33. Machine Programming (2) CS33 Intro to Computer Systems XII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Machine Programming (2) CS33 Intro to Computer Systems XII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Processor State (x86-64, Partial) %rax %eax %r8 %r8d %rbx %ebx %r9 %r9d %rcx %ecx
More informationCS165 Computer Security. Understanding low-level program execution Oct 1 st, 2015
CS165 Computer Security Understanding low-level program execution Oct 1 st, 2015 A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns
More informationChangelog. Brief Assembly Refresher. a logistics note. last time
Changelog Brief Assembly Refresher Changes made in this version not seen in first lecture: 23 Jan 2018: if-to-assembly if (...) goto needed b < 42 23 Jan 2018: caller/callee-saved: correct comment about
More informationUW CSE 351, Winter 2013 Midterm Exam
Full Name: Student ID: UW CSE 351, Winter 2013 Midterm Exam February 15, 2013 Instructions: Make sure that your exam is not missing any of the 9 pages, then write your full name and UW student ID on the
More information15-213/18-243, Summer 2011 Exam 1 Tuesday, June 28, 2011
Andrew login ID: Full Name: Section: 15-213/18-243, Summer 2011 Exam 1 Tuesday, June 28, 2011 Instructions: Make sure that your exam is not missing any sheets, then write your Andrew login ID, full name,
More informationL14: 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 informationCS356: Discussion #15 Review for Final Exam. Marco Paolieri Illustrations from CS:APP3e textbook
CS356: Discussion #15 Review for Final Exam Marco Paolieri (paolieri@usc.edu) Illustrations from CS:APP3e textbook Processor Organization Pipeline: Computing Throughput and Delay n 1 2 3 4 5 6 clock (ps)
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 7
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2017 Lecture 7 LAST TIME Dynamic memory allocation and the heap: A run-time facility that satisfies multiple needs: Programs can use widely varying, possibly
More informationProcessor state. Information about currently executing program. %rax, %rdi, ... %r14 %r15. %rsp. %rip CF ZF SF OF. Temporary data
Processor state Information about currently executing program Temporary data %rax, %rdi, current parameters, local variables Location of runtime stack %rsp Location of current instruction %rip Status of
More informationFunctions. Ray Seyfarth. August 4, Bit Intel Assembly Language c 2011 Ray Seyfarth
Functions Ray Seyfarth August 4, 2011 Functions We will write C compatible function C++ can also call C functions using extern "C" {...} It is generally not sensible to write complete assembly programs
More informationWhere We Are. Optimizations. Assembly code. generation. Lexical, Syntax, and Semantic Analysis IR Generation. Low-level IR code.
Where We Are Source code if (b == 0) a = b; Low-level IR code Optimized Low-level IR code Assembly code cmp $0,%rcx cmovz %rax,%rdx Lexical, Syntax, and Semantic Analysis IR Generation Optimizations Assembly
More informationCS527 Software Security
Reverse Engineering Purdue University, Spring 2018 Basics: encodings Code is data is code is data Learn to read hex numbers: 0x38 == 0011'1000 Python: hex(int('00111000', 2)) Remember common ASCII characters
More informationDo not turn the page until 12:30.
University of Washington Computer Science & Engineering Autumn 2018 Instructor: Justin Hsia 2018-12-12 Last Name: First Name: Student ID Number: Name of person to your Left Right All work is my own. I
More informationIntroduction Presentation A
CSE 2421/5042: Systems I Low-Level Programming and Computer Organization Introduction Presentation A Read carefully: Bryant Chapter 1 Study: Reek Chapter 2 Skim: Reek Chapter 1 08/22/2018 Gojko Babić Some
More informationWinter 2017 CS107 Midterm #2 Examination (Practice #2) Problem Points Score Grader TOTAL 30
CS107 Winter 2017 CS107 Midterm #2 Examination (Practice #2) Cynthia Lee This is a closed book, closed note, closed computer exam. You have 90 minutes to complete all problems. You don t need to #include
More informationRepresentation 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 informationMachine-Level Programming V: Unions and Memory layout
Machine-Level Programming V: Unions and Memory layout Slides adapted from Bryant and O Hallaron Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition 1 FAQ Call conventions
More informationCPS104 Recitation: Assembly Programming
CPS104 Recitation: Assembly Programming Alexandru Duțu 1 Facts OS kernel and embedded software engineers use assembly for some parts of their code some OSes had their entire GUIs written in assembly in
More informationadministrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions?
administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions? exam on Wednesday today s material not on the exam 1 Assembly Assembly is programming
More informationInstruction Set Architectures
Instruction Set Architectures! ISAs! Brief history of processors and architectures! C, assembly, machine code! Assembly basics: registers, operands, move instructions 1 What should the HW/SW interface
More informationReview addressing modes
Review addressing modes Op Src Dst Comments movl $0, %rax Register movl $0, 0x605428 Direct address movl $0, (%rcx) Indirect address movl $0, 20(%rsp) Indirect with displacement movl $0, -8(%rdi, %rax,
More informationInstructions and Instruction Set Architecture
Chapter 2 Instructions and Instruction Set Architecture In this lecture, we study computer instructions and instruction set architecture by using assembly language programming. We will study x86-64 architecture
More informationvoid P() {... y = Q(x); print(y); return; } ... int Q(int t) { int v[10];... return v[t]; } Computer Systems: A Programmer s Perspective
void P() { y = Q(x); print(y); return;... int Q(int t) { int v[10]; return v[t]; Computer Systems: A Programmer s Perspective %rax %rbx 0x101 0x41 0x7FFFFA8 0x1 0x7FFFFF8 0xB5A9 0x7FFFFF0 0x789ABC 0x7FFFFE8
More informationStructs & 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 informationPrinceton University Computer Science 217: Introduction to Programming Systems. Assembly Language: Function Calls
Princeton University Computer Science 217: Introduction to Programming Systems Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems x86-64 solutions Pertinent
More informationBuffer overflows (a security interlude) Address space layout the stack discipline + C's lack of bounds-checking HUGE PROBLEM
Buffer overflows (a security interlude) Address space layout the stack discipline + C's lack of bounds-checking HUGE PROBLEM x86-64 Linux Memory Layout 0x00007fffffffffff not drawn to scale Stack... Caller
More informationBrief Assembly Refresher
Brief Assembly Refresher 1 Changelog 1 Changes made in this version not seen in first lecture: 23 Jan 2018: if-to-assembly if (...) goto needed b < 42 23 Jan 2018: caller/callee-saved: correct comment
More informationQuestion Points Score Total: 100
Computer Science 2021 Spring 2016 Midterm Exam 1 February 29th, 2016 Time Limit: 50 minutes, 3:35pm-4:25pm This exam contains 7 pages (including this cover page) and 5 questions. Once we tell you to start,
More informationCS Bootcamp x86-64 Autumn 2015
The x86-64 instruction set architecture (ISA) is used by most laptop and desktop processors. We will be embedding assembly into some of our C++ code to explore programming in assembly language. Depending
More information6.1. CS356 Unit 6. x86 Procedures Basic Stack Frames
6.1 CS356 Unit 6 x86 Procedures Basic Stack Frames 6.2 Review of Program Counter (Instruc. Pointer) PC/IP is used to fetch an instruction PC/IP contains the address of the next instruction The value in
More informationx86-64 Programming II
x86-64 Programming II 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/ Administrative Homework
More informationMachine-Level Programming V: Advanced Topics
Machine-Level Programming V: Advanced Topics CSE 238/2038/2138: Systems Programming Instructor: Fatma CORUT ERGİN Slides adapted from Bryant & O Hallaron s slides 1 Today Memory Layout Buffer Overflow
More information