Unoptimized Code Generation
|
|
- Arline Laurel Chandler
- 6 years ago
- Views:
Transcription
1 Unoptimized Code Generation
2 Last time we left off on the procedure abstraction Saman Amarasinghe MIT Fall 1998
3 The Stack Arguments 0 to 6 are in: %b %rbp %rsp %rdi, %rsi, %rdx, %rcx, %r8 and %r9 marks the beginning of the current frame marks the end 8*n+16(%rbp) 16(%rbp) 8(%rbp) 0(%rbp) -8(%rbp) -8*m-8(%rbp) 0(%rsp) argument n argument 7 Return address Previous %rbp local 0 local m Variable size Pre vious Cu urrent Saman Amarasinghe MIT Fall 2001
4 33 Question: Why use a stack? Wh y not use the heap or preallocated in the data segment? Saman Amarasinghe MIT Fall 2001
5 Procedure Linkages Standard procedure linkage procedure p prolog procedure q prolog pre-call post-return epilog epilog Pre-call: Save caller-saved registers Push arguments Prolog: Push old frame pointer Save calle-saved registers Make room for temporaries Epilog: Restore callee-saved Pop old frame pointer Store return value Post-return: Restore R t caller-saved Pop arguments Saman Amarasinghe MIT Fall 2001
6 Calling: Caller Assume %rcx is live and is caller save Call foo(a, B, C, D, E, F, G, H, I) A to I are at -8(%rbp) to -72(%rbp) push push push push %rcx -72(%rbp) -64(%rbp) -56(%rbp) Stack mov -48(%rbp), %r9 mov -40(%rbp), %r8 mov mov mov mov call -32(%rbp), %rcx -24(%rbp), %rdx -16(%rbp), %rsi -8(%rbp), %rdi foo return address previous frame pointer calliee saved registers local variables stack temporaries dynamic area caller saved registers argument 9 argument 8 argument 7 return address rbp rsp Saman Amarasinghe MIT Fall 2001
7 Calling: Calliee Stack return address previous frame pointer calliee saved registers Assume %rbx is used in the function local variables and is calliee save stack temporaries Assume 40 bytes are required for locals dynamic area rbp foo: push %rbp mov sub %rsp, %rbp enter $48, $0 $48, %rsp mov %rbx, -8(%rbp) caller saved registers argument 9 argument 8 argument 7 return address previous frame pointer calliee saved registers local variables stack temporaries dynamic area rsp Saman Amarasinghe MIT Fall 2001
8 Arguments Call foo(a, B, C, D, E, F, G, H, I) CODE Control Flow Procedures Statements Data Access Passed in by pushing before the call push -72(%rbp) push -64(%rbp) push -56(%rbp) mov -48(%rbp), %r9 mov -40(%rbp), %r8 mov -32(%rbp), %rcx mov -24(%rbp), %rdx mov -16(%rbp), %rsi mov -8(%rbp), %rdi call foo Access A to F via registers or put them in local memory Access rest using 16+xx(%rbp) mov 16(%rbp), %rax mov 24(%rbp), %r10 DATA Global Static Variables Global Dynamic Data Local Variables Temporaries Parameter Passing Read-only Data Stack return address previous frame pointer calliee saved registers local variables stack temporaries dynamic area caller saved registers argument 9 argument 8 argument 7 return address previous frame pointer calliee saved registers local variables stack temporaries dynamic area rbp rsp Saman Amarasinghe MIT Fall 2001
9 Locals and Temporaries Stack Calculate the size and allocate space on the stack sub $48, %rsp return address previous frame pointer calliee saved registers local variables stack temporaries dynamic area or enter $48, 0 caller saved registers argument 9 argument 8 argument 7 Access using -8-xx(%rbp) return address mov -28(%rbp), %r10 previous frame pointer mov %r11, -20(%rbp) calliee saved registers CODE Control Flow Procedures Statements Data Access DATA Global Static Variables Global Dynamic Data Local Variables Temporaries Parameter Passing Read-only Data local variables stack temporaries dynamic area rbp rsp Saman Amarasinghe MIT Fall 2001
10 Returning Calliee Stack Assume the return value is the first temporary Restore the caller saved register Put the return value in %rax Tear-down the call stack mov -8(%rbp), %rbx mov -16(%rbp), %rax mov pop ret leave %rbp, %rsp %rbp return address previous frame pointer calliee saved registers local variables stack temporaries dynamic area caller saved registers argument 9 argument 8 argument 7 return address previous frame pointer calliee saved registers local variables stack temporaries dynamic area rbp rsp Saman Amarasinghe MIT Fall 2001
11 Returning Caller Stack return address previous frame pointer calliee saved registers (Assume the return value goes to the first local variables temporary) stack temporaries Restore the stack to reclaim the argument space Restore the caller save registers Save the return value dynamic area caller saved registers argument 9 argument 8 argument 7 rbp rsp call foo CODE DATA add $24, %rsp pop %rcx mov %rax, 8(%rbp) Procedures Global Static Variables Global Dynamic Data Control Flow Local Variables Statements Temporaries Parameter Passing Data Access Read-only Data Saman Amarasinghe MIT Fall 2001
12 47 Question: Do you need the $rbp? What are the advantages and disadvantages of having $rbp? Saman Amarasinghe MIT Fall 2001
13 So far we covered.. CODE Procedures Control Flow Statements Data Access DATA Global Static Variables Global Dynamic Data Local Variables Temporaries Parameter Passing Read-only Data Saman Amarasinghe MIT Fall 1998
14 8 Outline Generation of expressions and statements Generation of control flow x86-64 Processor Guidelines in writing a code generator Saman Amarasinghe MIT Fall 1998
15 Expressions Expressions are represented as trees Expression may produce a value Or, it may set the condition codes (boolean exprs) How do you map expression trees to the machines? How to arrange the evaluation order? Where to keep the intermediate t values? Two approaches Stack Model Flat List Model Saman Amarasinghe MIT Fall 1998
16 Evaluating expression trees Stack model Eval left-sub-tree Put the results on the stack Eval right-sub-tree Put the results on the stack Get top two values from the stack perform the operation OP put the results on the stack Very inefficient! OP Saman Amarasinghe MIT Fall 1998
17 Evaluating expression trees Flat List Model The idea is to linearize the expression tree Left to Right Depth-First Traversal of the expression tree Allocate temporaries for intermediates (all the nodes of the tree) New temporary for each intermediate All the temporaries on the stack (for now) Each expression is a single 3-addr op x = y op z Code generation for the 3-addr expression Load y into register %r10 Load z into register %r11 Perform op %r10, %r11 Store %r11 to x Saman Amarasinghe MIT Fall 1998
18 Issues in Lowering Expressions Map intermediates to registers? registers are limited when the tree is large, registers may be insufficient allocate space in the stack No machine instruction is available May need to expand the intermediate operation into multiple machine ops. Very inefficient too many copies don t worry, we ll take care of them in the optimization passes keep the code generator very simple Saman Amarasinghe MIT Fall 1998
19 What about statements? Assignment statements are simple Generate code for RHS expression Store the resulting value to the LHS address But what about conditionals and loops? Saman Amarasinghe MIT Fall 1998
20 28 Outline Generation of statements Generation of control flow Guidelines in writing a code generator Saman Amarasinghe MIT Fall 1998
21 Two Approaches Template Matching Approach Peephole Optimization Algorithmic Approach Both are based on structural induction Generate a representation for the sub-parts Combine them into a representation for the whole Saman Amarasinghe MIT Fall 1998
22 Generation of control flow: Template Matching Approach Flatten the control structure use a template Put unique labels for control join points Now generate the appropriate code Saman Amarasinghe MIT Fall 1998
23 29 Template for conditionals if (test) true_body else false_body <do the test> joper lab_true <false_body> jmp lab_end lab_true: <true_body> lab _ end: Saman Amarasinghe MIT Fall 1998
24 if(ax > bx) dx = ax - bx; else dx = bx - ax; Example Program <do test>.l0:.l1: joper.l0 <FALSE BODY> jmp.l1 <TRUE BODY> Return address previous frame pointer Local variable px (10) Local variable py (20) Local variable pz (30) Argument 9: cx (30) Argument 8: bx (20) Argument 7: ax (10) Return address previous frame pointer Local variable dx (??) Local variable dy (??) Local variable dz (??) rbp rsp Saman Amarasinghe MIT Fall 1998
25 if(ax > bx) dx = ax - bx; else dx = bx - ax; Example Program.L0:.L1: movq 16(%rbp), %r10 movq 24(%rbp), %r11 cmpq %r10, %r11 jg.l0 <FALSE BODY> jmp.l1 <TRUE BODY> Return address previous frame pointer Local variable px (10) Local variable py (20) Local variable pz (30) Argument 9: cx (30) Argument 8: bx (20) Argument 7: ax (10) Return address previous frame pointer Local variable dx (??) Local variable dy (??) Local variable dz (??) rbp rsp Saman Amarasinghe MIT Fall 1998
26 if(ax > bx) dx = ax - bx; else dx = bx - ax; Example Program.L0:.L1: movq 16(%rbp), %r10 movq 24(%rbp), %r11 cmpq %r10, %r11 jg.l0 movq 24(%rbp), %r10 movq 16(%rbp), %r11 subq %r10, %r11 movq %r11, -8(%rbp) jmp.l1 <TRUE BODY> Return address previous frame pointer Local variable px (10) Local variable py (20) Local variable pz (30) Argument 9: cx (30) Argument 8: bx (20) Argument 7: ax (10) Return address previous frame pointer Local variable dx (??) Local variable dy (??) Local variable dz (??) rbp rsp Saman Amarasinghe MIT Fall 1998
27 if(ax > bx) dx = ax - bx; else dx = bx - ax; Example Program.L0:.L1: movq 16(%rbp), %r10 movq 24(%rbp), %r11 cmpq %r10, %r11 jg.l0 movq 24(%rbp), %r10 movq 16(%rbp), %r11 subq %r10, %r11 movq %r11, -8(%rbp) jmp.l1 movq 16(%rbp), %r10 movq 24(%rbp), %r11 subq %r10, %r11 movq %r11, -8(%rbp) Return address previous frame pointer Local variable px (10) Local variable py (20) Local variable pz (30) Argument 9: cx (30) Argument 8: bx (20) Argument 7: ax (10) Return address previous frame pointer Local variable dx (??) Local variable dy (??) Local variable dz (??) rbp rsp Saman Amarasinghe MIT Fall 1998
28 Template for while loops while (test) body Saman Amarasinghe MIT Fall 1998
29 Template for while loops while (test) body lab_cont: <do the test> joper lab_body body jmp lab_end lab_body: <body> jmp lab_cont lab_end: Saman Amarasinghe MIT Fall 1998
30 31 while (test) body Template for while loops lab_end: An optimized template CODE Control Flow Procedures Statements Data Access DATA Global Static Variables Global Dynamic Data Local Variables Temporaries Parameter Passing Read-only Data lab_cont: <do the test> joper lab_body body jmp lab_end lab_body: <body> jmp lab_cont lab_cont: <do the test> joper lab_end <body> jmp lab_cont lab_end: Saman Amarasinghe MIT Fall 1998
31 33 Question: What is the template for? do body while (test) Saman Amarasinghe MIT Fall 1998
32 33 Question: What is the template for? do body while (test) lab_begin: <body> <do test> joper lab_begin Saman Amarasinghe MIT Fall 1998
33 33 Question: What is a drawback of the template based approach? Saman Amarasinghe MIT Fall 1998
34 Control Flow Graph (CFG) Starting gp point: high level intermediate format, symbol tables Target: CFG CFG Nodes are Instruction Nodes CFG Edges Represent Flow of Control Forks At Conditional Jump Instructions Merges When Flow of Control Can Reach A Point Multiple Ways Entry and Exit Nodes Saman Amarasinghe MIT Fall 1998
35 entry if (x < y) { a = 0; } else { a = 1; } mov $0, a jl xxx < cmp %r10, %r11 mov x, %r10 Mov y, %r11 mov $1, a exit Pattern for if then else Saman Amarasinghe MIT Fall 1998
36 Short-Circuit Conditionals In program, conditionals have a condition written as a boolean expression ((i < n) && (v[i]!= 0)) i > k) Semantics say should execute only as much as required to determine condition Evaluate (v[i]!= 0) only if (i < n) is true Evaluate i > k only if ((i < n) && (v[i]!= 0)) is false Use control-flow graph to represent this short- circuit evaluation Saman Amarasinghe MIT Fall 1998
37 Short-Circuit Conditionals while (i < n && v[i]!= 0) { i=i+1; i+1; } entry jl xxx < cmp %r10, %r11 mov %r11, i add $1, %r11 jl yyy < cmp %r10, %r11 exit mov i, %r11 Saman Amarasinghe MIT Fall 1998
38 More Short-Circuit Conditionals if (a < b c!= 0) { i=i+1; i+1; entry } jl xxx < cmp %r10, %r11 mov %r11, i add $1, %r11 jne yyy < cmp %r10, %r11 mov i, %r11 exit Saman Amarasinghe MIT Fall 1998
39 Routines for Destructuring Program destruct(n) Representation ti generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form shortcircuit(c, t, f) generates short-circuit form of conditional represented by c if c is true, control flows to t node if c is false, control flows to f node returns b - b is begin node for condition evaluation new kind of node - nop node Saman Amarasinghe MIT Fall 1998
40 Destructuring Seq Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form seq x y seq x y Saman Amarasinghe MIT Fall 1998
41 Destructuring Seq Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form seq x y 1: (b x,e x ) = destruct(x); x seq y b x e x Saman Amarasinghe MIT Fall 1998
42 Destructuring Seq Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form seq x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); seq x y b x e b e x b y e y Saman Amarasinghe MIT Fall 1998
43 Destructuring Seq Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form seq x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); 3: next(e x ) = b y ; seq x y b x e b e x b y e y Saman Amarasinghe MIT Fall 1998
44 Destructuring Seq Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form seq x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); 3: next(e x ) = b y ; 4: return (b x, e y ); b x seq x y e x b b y e y Saman Amarasinghe MIT Fall 1998
45 destruct(n) Destructuring If Nodes generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form if c x y c if x y Saman Amarasinghe MIT Fall 1998
46 destruct(n) Destructuring If Nodes generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form if c x y 1: (b x,e x ) = destruct(x); c if x y b x e x Saman Amarasinghe MIT Fall 1998
47 destruct(n) Destructuring If Nodes generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form if c x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); if b x e x c x y b y e y Saman Amarasinghe MIT Fall 1998
48 destruct(n) Destructuring If Nodes generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form if c x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); 3: e = new nop; c if x y b x b y e x e y e Saman Amarasinghe MIT Fall 1998
49 destruct(n) Destructuring If Nodes generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form if c x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); 3: e = new nop; 4: next(e x ) = e; 5: next(e y ) = e; c if x y b x b y e x e y e Saman Amarasinghe MIT Fall 1998
50 destruct(n) Destructuring If Nodes generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form if c x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); 3: e = new nop; 4: next(e x ) = e; 5: next(e y ) = e; 6: b c = shortcircuit(c, i b x, b y ); c if x y b c b x b y e x e y e Saman Amarasinghe MIT Fall 1998
51 destruct(n) Destructuring If Nodes generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form if c x y 1: (b x,e x ) = destruct(x); 2: (b y,e y ) = destruct(y); 3: e = new nop; 4: next(e x ) = e; 5: next(e y ) = e; 6: b c = shortcircuit(c, i b x, b y ); 7: return (b c, e); c if x y b c b x b y e x e y e Saman Amarasinghe MIT Fall 1998
52 Destructuring While Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form while c x while c x Saman Amarasinghe MIT Fall 1998
53 Destructuring While Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form while c x 1: e = new nop; while c x e Saman Amarasinghe MIT Fall 1998
54 Destructuring While Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form while c x 1: e = new nop; 2: (b x,e x ) = destruct(x); while c x b x e e x Saman Amarasinghe MIT Fall 1998
55 Destructuring While Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form while c x 1: e = new nop; 2: (b x,e x ) = destruct(x); 3: b c = shortcircuit(c, b x, e); while b c c x b x e e x Saman Amarasinghe MIT Fall 1998
56 Destructuring While Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form while c x 1: e = new nop; 2: (b x,e x ) = destruct(x); 3: b c = shortcircuit(c, b x, e); 4: next(e x ) = b c ; while b c c x b x e e x Saman Amarasinghe MIT Fall 1998
57 Destructuring While Nodes destruct(n) generates lowered form of structured code represented by n returns (b,e) - b is begin node, e is end node in destructed form if n is of the form while c x 1: e = new nop; 2: (b x,e x ) = destruct(x); 3: b c = shortcircuit(c, b x, e); 4: next(e x ) = b c ; 5: return (b c, e); while b c c x b x e e x Saman Amarasinghe MIT Fall 1998
58 Shortcircuiting And Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 && c 2 c 1 && c 2 Saman Amarasinghe MIT Fall 1998
59 Shortcircuiting And Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 && c 2 1: b 2 = shortcircuit(c 2, t, f); c 1 && c 2 b 2 f t Saman Amarasinghe MIT Fall 1998
60 Shortcircuiting And Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 && c 2 1: b 2 = shortcircuit(c 2, t, f); 2: b 1 = shortcircuit(c 1, b 2, f); b 1 c 1 && c 2 b 2 f t Saman Amarasinghe MIT Fall 1998
61 Shortcircuiting And Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 && c 2 1: b 2 = shortcircuit(c 2, t, f); 2: b 1 = shortcircuit(c 1, b 2, f); 3: return (b 1 ); b b 1 c 1 && c 2 b 2 f t Saman Amarasinghe MIT Fall 1998
62 Shortcircuiting Or Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 c 2 c 1 c 2 Saman Amarasinghe MIT Fall 1998
63 Shortcircuiting Or Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 c 2 1: b 2 = shortcircuit(c 2, t, f); c 1 c 2 b 2 t f Saman Amarasinghe MIT Fall 1998
64 Shortcircuiting Or Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 c 2 1: b 2 = shortcircuit(c 2, t, f); 2: b 1 = shortcircuit(c 1, t, b 2 ); b 1 c 1 c 2 b 2 t f Saman Amarasinghe MIT Fall 1998
65 Shortcircuiting Or Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form c 1 c 2 1: b 2 = shortcircuit(c 2, t, f); 2: b 1 = shortcircuit(c 1, t, b 2 ); 3: return (b 1 ); b b 1 c 1 c 2 b 2 t f Saman Amarasinghe MIT Fall 1998
66 Shortcircuiting Not Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form! c 1 1: b = shortcircuit(c 1, f, t); return(b);! c 1 b f t Saman Amarasinghe MIT Fall 1998
67 Computed Conditions shortcircuit(c, t, f) generates shortcircuit form of conditional represented by c returns b - b is begin node of shortcircuit form if c is of the form e 1 < e 2 1: b = new cbr(e 1 < e 2, t, f); 2: return (b); jl e 1 < e 2 t cmp f e 1 e 2 Saman Amarasinghe MIT Fall 1998
68 Nops In Destructured Representation while (i < n && v[i]!= 0) { i=i+1; i+1; } entry jl xxx < cmp %r10, %r11 mov %r11, i add $1, %r11 nop jl yyy < cmp %r10, %r11 exit mov i, %r11 Saman Amarasinghe MIT Fall 1998
69 Eliminating Nops Via Peephole Optimization i nop Saman Amarasinghe MIT Fall 1998
70 46 Question: What are the pros and cons of template matching vs. algorithmic approach? Saman Amarasinghe MIT Fall 1998
71 49 Outline Generation of statements Generation of control flow x86-64 Processor Guidelines in writing a code generator Saman Amarasinghe MIT Fall 1998
72 Guidelines for the code generator Lower the abstraction level slowly Do many passes, that do few things (or one thing) Easier to break the project down, generate and debug Keep the abstraction level consistent IR should have correct semantics at all time At least you should know the semantics You may want to run some of the optimizations between the passes. Use assertions liberally Use an assertion to check your assumption Saman Amarasinghe MIT Fall 1998
73 Guidelines for the code generator Do the simplest but dumb thing it is ok to generate 0 + 1*x + 0*y Code is painful to look at; let optimizations improve it Make sure you know want can be done at Compile time in the compiler Runtime usinggenerated code Saman Amarasinghe MIT Fall 1998
74 Guidelines for the code generator Remember that optimizations will come later Let the optimizer do the optimizations Think about what optimizer will need and structure your code accordingly Example: Register allocation, algebraic simplification, constant propagation Setup a good testing infrastructure regression tests If a input program creates a bug, use it as a regression test Learn good bug hunting procedures Example: binary search, delta debugging Saman Amarasinghe MIT Fall 1998
75 MIT OpenCourseWare Computer Language Engineering Spring 2010 For information about citing these materials or our Terms of Use, visit:
Generation. 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 information6.035 Project 3: Unoptimized Code Generation. Jason Ansel MIT - CSAIL
6.035 Project 3: Unoptimized Code Generation Jason Ansel MIT - CSAIL Quiz Monday 50 minute quiz Monday Covers everything up to yesterdays lecture Lexical Analysis (REs, DFAs, NFAs) Syntax Analysis (CFGs,
More informationTest I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Department of Electrical Engineering and Computer Science
Department of Electrical Engineering and Computer cience MAACHUETT INTITUTE OF TECHNOLOGY 6.035 Fall 2017 Test I olutions Mean 83.63 Median 86 td. dev 12.03 1 I Regular Expressions and Finite-tate Automata
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 informationAssembly Language: Function Calls
Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems x86-64 solutions Pertinent instructions and conventions 2 Function Call Problems (1) Calling and returning
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 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 informationMachine-Level Programming (2)
Machine-Level Programming (2) Yanqiao ZHU Introduction to Computer Systems Project Future (Fall 2017) Google Camp, Tongji University Outline Control Condition Codes Conditional Branches and Conditional
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: February 28, 2018 at 06:32 CS429 Slideset 9: 1 Mechanisms in Procedures
More informationAssembly III: Procedures. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Assembly III: Procedures Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Mechanisms in Procedures Passing control To beginning of procedure code
More informationx86-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%r8 %r8d. %r9 %r9d. %r10 %r10d. %r11 %r11d. %r12 %r12d. %r13 %r13d. %r14 %r14d %rbp. %r15 %r15d. Sean Barker
Procedure Call Registers Return %rax %eax %r8 %r8d Arg 5 %rbx %ebx %r9 %r9d Arg 6 Arg 4 %rcx %ecx %r10 %r10d Arg 3 %rdx %edx %r11 %r11d Arg 2 %rsi %esi %r12 %r12d Arg 1 %rdi %edi %r13 %r13d ptr %esp %r14
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 informationLecture 4 CIS 341: COMPILERS
Lecture 4 CIS 341: COMPILERS CIS 341 Announcements HW2: X86lite Available on the course web pages. Due: Weds. Feb. 7 th at midnight Pair-programming project Zdancewic CIS 341: Compilers 2 X86 Schematic
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 informationEXAMINATIONS 2014 TRIMESTER 1 SWEN 430. Compiler Engineering. This examination will be marked out of 180 marks.
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2014 TRIMESTER 1 SWEN 430 Compiler Engineering Time Allowed: THREE HOURS Instructions:
More informationComputer Organization: A Programmer's Perspective
A Programmer's Perspective Instruction Set Architecture Gal A. Kaminka galk@cs.biu.ac.il Outline: CPU Design Background Instruction sets Logic design Sequential Implementation A simple, but not very fast
More informationAssembly 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 informationStack Frame Components. Using the Stack (4) Stack Structure. Updated Stack Structure. Caller Frame Arguments 7+ Return Addr Old %rbp
Stack Frame Components Frame pointer %rbp Stack pointer Caller Frame rguments 7+ Return ddr Old %rbp Saved Registers + Local Variables rgument Build 1 Using the Stack (4) Stack Structure long call_incr()
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 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 informationMachine-level Programs Procedure
Computer Systems Machine-level Programs Procedure Han, Hwansoo Mechanisms in Procedures Passing control To beginning of procedure code Back to return point Passing data Procedure arguments Return value
More informationMechanisms in Procedures. CS429: Computer Organization and Architecture. x86-64 Stack. x86-64 Stack Pushing
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: February 28, 2018 at 06:32 Mechanisms in Procedures Passing Control
More informationCSE P 501 Exam Sample Solution 12/1/11
Question 1. (10 points, 5 each) Regular expressions. Give regular expressions that generate the following sets of strings. You may only use the basic operations of concatenation, choice ( ), and repetition
More informationMidterm 1 topics (in one slide) Bits and bitwise operations. Outline. Unsigned and signed integers. Floating point numbers. Number representation
Midterm 1 topics (in one slide) CSci 2021: Review Lecture 1 Stephen McCamant University of Minnesota, Computer Science & Engineering Number representation Bits and bitwise operators Unsigned and signed
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 4
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 4 LAST TIME Enhanced our processor design in several ways Added branching support Allows programs where work is proportional to the input values
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 information18-600: Recitation #3
18-600: Recitation #3 Bomb Lab & GDB Overview September 12th, 2017 1 Today X86-64 Overview Bomb Lab Introduction GDB Tutorial 2 3 x86-64: Register Conventions Arguments passed in registers: %rdi, %rsi,
More informationPart 7. Stacks. Stack. Stack. Examples of Stacks. Stack Operation: Push. Piles of Data. The Stack
Part 7 Stacks The Stack Piles of Data Stack Stack A stack is an abstract data structure that stores objects Based on the concept of a stack of items like a stack of dishes Data can only be added to or
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 informationSpring 2 Spring Loop Optimizations
Spring 2010 Loop Optimizations Instruction Scheduling 5 Outline Scheduling for loops Loop unrolling Software pipelining Interaction with register allocation Hardware vs. Compiler Induction Variable Recognition
More informationMachine-Level Programming III: Procedures
Machine-Level Programming III: Procedures CSE 238/2038/2138: Systems Programming Instructor: Fatma CORUT ERGİN Slides adapted from Bryant & O Hallaron s slides Mechanisms in Procedures Passing control
More informationAssembly Programming III
Assembly Programming III CSE 410 Winter 2017 Instructor: Justin Hsia Teaching Assistants: Kathryn Chan, Kevin Bi, Ryan Wong, Waylon Huang, Xinyu Sui Facebook Stories puts a Snapchat clone above the News
More informationRegister Allocation, i. Overview & spilling
Register Allocation, i Overview & spilling 1 L1 p ::=(label f...) f ::=(label nat nat i...) i ::=(w
More informationBryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon
Carnegie Mellon Machine-Level Programming III: Procedures 15-213/18-213/14-513/15-513: Introduction to Computer Systems 7 th Lecture, September 18, 2018 Today Procedures Mechanisms Stack Structure Calling
More informationThe Stack & Procedures
The Stack & Procedures CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Homework 2 due
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 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 informationx86 Programming II CSE 351 Winter
x86 Programming II CSE 351 Winter 2017 http://xkcd.com/1652/ Administrivia 2 Address Computation Instruction v leaq src, dst lea stands for load effective address src is address expression (any of 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 informationa translator to convert your AST representation to a TAC intermediate representation; and
CS 301 Spring 2016 Project Phase 3 March 28 April 14 IC Compiler Back End Plan By the end of this phase of the project, you will be able to run IC programs generated by your compiler! You will implement:
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 informationx86-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 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 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 informationMachine-Level Programming II: Control
Machine-Level Programming II: Control CSE 238/2038/2138: Systems Programming Instructor: Fatma CORUT ERGİN Slides adapted from Bryant & O Hallaron s slides 1 Today Control: Condition codes Conditional
More informationMachine-Level Programming II: Control
Mellon Machine-Level Programming II: Control CS140 Computer Organization and Assembly Slides Courtesy of: Randal E. Bryant and David R. O Hallaron 1 First https://www.youtube.com/watch?v=ivuu8jobb1q 2
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 informationRegisters. Ray Seyfarth. September 8, Bit Intel Assembly Language c 2011 Ray Seyfarth
Registers Ray Seyfarth September 8, 2011 Outline 1 Register basics 2 Moving a constant into a register 3 Moving a value from memory into a register 4 Moving values from a register into memory 5 Moving
More informationCSC 252: Computer Organization Spring 2018: Lecture 11
CSC 252: Computer Organization Spring 2018: Lecture 11 Instructor: Yuhao Zhu Department of Computer Science University of Rochester Action Items: Assignment 3 is due March 2, midnight Announcement Programming
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 informationComputer Architecture I: Outline and Instruction Set Architecture. CENG331 - Computer Organization. Murat Manguoglu
Computer Architecture I: Outline and Instruction Set Architecture CENG331 - Computer Organization Murat Manguoglu Adapted from slides of the textbook: http://csapp.cs.cmu.edu/ Outline Background Instruction
More informationObject Code (Machine Code) Dr. D. M. Akbar Hussain Department of Software Engineering & Media Technology. Three Address Code
Code Generation Intermediate Code? Assembly Code Object Code (Machine Code) 1 Intermediate Code P-Code Three Address Code 2 Compiler Construction F6S 1 Intermediate Representation Abstract Syntax Tree
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 informationThe Stack & Procedures
The Stack & Procedures 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/648/
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 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 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 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 informationWhat Compilers Can and Cannot Do. Saman Amarasinghe Fall 2009
What Compilers Can and Cannot Do Saman Amarasinghe Fall 009 Optimization Continuum Many examples across the compilation pipeline Static Dynamic Program Compiler Linker Loader Runtime System Optimization
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 informationCSE 401/M501 Compilers
CSE 401/M501 Compilers x86-64 Lite for Compiler Writers A quick (a) introduction or (b) review [pick one] Hal Perkins Autumn 2018 UW CSE 401/M501 Autumn 2018 J-1 Administrivia HW3 due tonight At most 1
More informationL09: Assembly Programming III. Assembly Programming III. CSE 351 Spring Guest Lecturer: Justin Hsia. Instructor: Ruth Anderson
Assembly Programming III CSE 351 Spring 2017 Guest Lecturer: Justin Hsia Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis
More informationTHE UNIVERSITY OF BRITISH COLUMBIA CPSC 261: MIDTERM 1 February 14, 2017
THE UNIVERSITY OF BRITISH COLUMBIA CPSC 261: MIDTERM 1 February 14, 2017 Last Name: First Name: Signature: UBC Student #: Important notes about this examination 1. You have 70 minutes to write the 6 questions
More informationCSC 2400: Computing Systems. X86 Assembly: Function Calls"
CSC 24: Computing Systems X86 Assembly: Function Calls" 1 Lecture Goals! Challenges of supporting functions" Providing information for the called function" Function arguments and local variables" Allowing
More informationAssembly 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 informationMachine- Level Representa2on: Procedure
Machine- Level Representa2on: Procedure CSCI 2021: Machine Architecture and Organiza2on Pen- Chung Yew Department Computer Science and Engineering University of Minnesota With Slides from Bryant, O Hallaron
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 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 informationcmovxx ra, rb 2 fn ra rb irmovq V, rb 3 0 F rb V rmmovq ra, D(rB) 4 0 ra rb mrmovq D(rB), ra 5 0 ra rb OPq ra, rb 6 fn ra rb jxx Dest 7 fn Dest
Instruction Set Architecture Computer Architecture: Instruction Set Architecture CSci 2021: Machine Architecture and Organization Lecture #16, February 24th, 2016 Your instructor: Stephen McCamant Based
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 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 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 informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 5
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2017 Lecture 5 LAST TIME Began exploring x86-64 instruction set architecture 16 general-purpose registers Also: All registers are 64 bits wide rax-rdx are
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: February 26, 2018 at 12:02 CS429 Slideset 8: 1 Controlling Program
More informationCS367. Program Control
CS367 Program Control outline program control condition codes branching looping conditional moves switches (special case of branching) Condition Codes Processor State (x86-64, Partial) Info about currently
More informationIntermediate Code & Local Optimizations. Lecture 20
Intermediate Code & Local Optimizations Lecture 20 Lecture Outline Intermediate code Local optimizations Next time: global optimizations 2 Code Generation Summary We have discussed Runtime organization
More informationCSE 401 Final Exam. March 14, 2017 Happy π Day! (3/14) This exam is closed book, closed notes, closed electronics, closed neighbors, open mind,...
CSE 401 Final Exam March 14, 2017 Happy π Day! (3/14) Name This exam is closed book, closed notes, closed electronics, closed neighbors, open mind,.... Please wait to turn the page until everyone has their
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 informationx64 Cheat Sheet Fall 2014
CS 33 Intro Computer Systems Doeppner x64 Cheat Sheet Fall 2014 1 x64 Registers x64 assembly code uses sixteen 64-bit registers. Additionally, the lower bytes of some of these registers may be accessed
More informationCSC 2400: Computing Systems. X86 Assembly: Function Calls
CSC 24: Computing Systems X86 Assembly: Function Calls 1 Lecture Goals Challenges of supporting functions Providing information for the called function Function arguments and local variables Allowing the
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 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 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 informationRecitation: Attack Lab
15-213 Recitation: Attack Lab TA 11 Feb 2017 Agenda Reminders Stacks Attack Lab Activities Reminders Bomb lab is due tomorrow (14 Feb, 2017)! But if you wait until the last minute, it only takes a minute!
More informationDr. D.M. Akbar Hussain
1 2 Compiler Construction F6S 1 3 4 Compiler Construction F6S 2 5 6 Compiler Construction F6S 3 7 8 Compiler Construction F6S 4 a=b*- c + b*- c 9 a=b*- c + b*- c 10 Compiler Construction F6S 5 a=b*- c
More informationComputer Architecture and System Programming Laboratory. TA Session 3
Computer Architecture and System Programming Laboratory TA Session 3 Stack - LIFO word-size data structure STACK is temporary storage memory area register points on top of stack (by default, it is highest
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 informationIntroduction to Intel x86-64 Assembly, Architecture, Applications, & Alliteration. Xeno Kovah
Introduction to Intel x86-64 Assembly, Architecture, Applications, & Alliteration Xeno Kovah 2014-2015 xeno@legbacore.com All materials is licensed under a Creative Commons Share Alike license. http://creativecommons.org/licenses/by-sa/3.0/
More informationThe Hardware/Software Interface CSE351 Spring 2013
The Hardware/Software Interface CSE351 Spring 2013 x86 Programming II 2 Today s Topics: control flow Condition codes Conditional and unconditional branches Loops 3 Conditionals and Control Flow A conditional
More informationData Representa/ons: IA32 + x86-64
X86-64 Instruc/on Set Architecture Instructor: Sanjeev Se(a 1 Data Representa/ons: IA32 + x86-64 Sizes of C Objects (in Bytes) C Data Type Typical 32- bit Intel IA32 x86-64 unsigned 4 4 4 int 4 4 4 long
More informationCS 261 Fall Mike Lam, Professor. x86-64 Control Flow
CS 261 Fall 2018 Mike Lam, Professor x86-64 Control Flow Topics Condition codes Jumps Conditional moves Jump tables Motivation We cannot translate the following C function to assembly, using only data
More information16.317: Microprocessor Systems Design I Fall 2015
16.317: Microprocessor Systems Design I Fall 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationCredits and Disclaimers
Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 3 nd Edition by Bryant and O'Hallaron
More informationModule 27 Switch-case statements and Run-time storage management
Module 27 Switch-case statements and Run-time storage management In this module we will discuss the pending constructs in generating three-address code namely switch-case statements. We will also discuss
More information143A: Principles of Operating Systems. Lecture 5: Calling conventions. Anton Burtsev January, 2017
143A: Principles of Operating Systems Lecture 5: Calling conventions Anton Burtsev January, 2017 Stack and procedure calls Stack Main purpose: Store the return address for the current procedure Caller
More information143A: Principles of Operating Systems. Lecture 4: Calling conventions. Anton Burtsev October, 2017
143A: Principles of Operating Systems Lecture 4: Calling conventions Anton Burtsev October, 2017 Recap from last time Stack and procedure calls What is stack? Stack It's just a region of memory Pointed
More informationlast time Exam Review on the homework on office hour locations hardware description language programming language that compiles to circuits
last time Exam Review hardware description language programming language that compiles to circuits stages as conceptual division not the order things happen easier to figure out wiring stage-by-stage?
More informationAssembly II: Control Flow
Assembly II: Control Flow 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 information16.317: Microprocessor Systems Design I Spring 2015
16.317: Microprocessor Systems Design I Spring 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by
More information