Compiling C Programs Into x86-64 Assembly Programs

Size: px
Start display at page:

Download "Compiling C Programs Into x86-64 Assembly Programs"

Transcription

1 CSE 2421: Systems I Low-Level Programming and Computer Organization Compiling C Programs Into x86-64 Assembly Programs Part A: Function Calling Read/Study: Bryant Presentation K Gojko Babić Linux & Windows X86-64 Register Usage %rax Return value %rax urn value, and if needed caller %rdi also has to save it, since can %rsi be modified by called function %rdx %rdi, %rsi, %rdx, %rcx, Arguments %r8, %r9 %rcx arguments (1 st,2 nd, 3 rd,, 6 th ) also caller-saved (if needed), since can be modified by called function %r10, %r11 caller-saved (if needed), since can be modified by called function Caller saved temporaries %r8 %r9 %r10 %r11 Carnegie Mellon Presentation K 2 1

2 Linux & Windows X86-64 Register Usage (cont.) Carnegie Mellon %rbx, %r12, %r13, %r14, %rbp If using them, called function must save & restore, since caller expect them to be unchanged Special form of called function save. Should be restored to original value upon exit from called function Callee saved temporaries Special %rbx %r12 %r13 %r14 %rbp Presentation K 3 Function sum() long sum(long int x, long int y) long t = x+y; urn t; Note: This is the complete file sum.c, i.e. without the function main. Compilation command: gcc -O1 -S sum.c generates this x86-64 assembly code in the file sum.s: sum: leaq (%rsi,%rdi), %rax Note, x has to be in %rdi and y in %rsi, set by calling function Presentation K 4 2

3 Function arith() long arith(long int x,long int y,long int z) urn (x+y+z)*(x+4+48*y); Compilation command: gcc -O1 -S arith.c generates this x86-64 assembly code in the file arith.s: arith: leaq (%rsi,%rsi,2), %rax salq $4, %rax leaq 4(%rdi,%rax), %rax addq %rdi, %rsi addq %rdx, %rsi imulq %rsi, %rax Note, x has to be in %rdi, y in %rsi and z in %rdx, set by calling function. Presentation K 5 long arith(long, long, long); long main() long x,y,z,w; x=25; y=12345; z=98765; w=arith(x,y,z); w++; urn w; Function main Calling arith() Instruction subq enlargers the stack for 8 bytes (why??), and second instruction addq shrinks stack back 8 bytes Compilation command: gcc -O1 S main.arith.c generated this x86-64 assembly code (with minor changes in red): subq call addq addq $8, $98765, %rdx $12345, %rsi $25, %rdi arith $1, %rax $8, Presentation K 6 3

4 Function swap() void swap (long *xp, long *yp) long t0 = *xp; long t1 = *yp; *xp = t1; *yp = t0; Compilation command: gcc O1 -S swap.c produces file swap.s Presentation K Note, xp has to be in %rdi and yp in %rsi set by calling function. swap: (%rdi), %rax (%rsi), %rdx %rdx, (%rdi) %rax, (%rsi) 7 Understanding swap() a. void swap (long *xp, long *yp) long t0 = *xp; long t1 = *yp; *xp = t1; *yp = t0; Registers %rdi %rsi %rax %rdx Memory Register %rdi %rsi %rax %rdx Value xp yp t0 t1 swap: (%rdi), %rax # t0 = *xp (%rsi), %rdx # t1 = *yp %rdx, (%rdi) # *xp = t1 %rax, (%rsi) # *yp = t0 Presentation K 8 4

5 Understanding swap() b. Registers %rdi 0x120 %rsi 0x100 %rax %rdx Memory Address 0x120 0x118 0x110 0x108 0x100 swap: (%rdi), %rax # t0 = *xp (%rsi), %rdx # t1 = *yp %rdx, (%rdi) # *xp = t1 %rax, (%rsi) # *yp = t0 Presentation K 9 Understanding swap() c. Registers %rdi 0x120 %rsi 0x100 %rax 123 %rdx Memory Address 0x120 0x118 0x110 0x108 0x100 swap: (%rdi), %rax # t0 = *xp (%rsi), %rdx # t1 = *yp %rdx, (%rdi) # *xp = t1 %rax, (%rsi) # *yp = t0 Presentation K 10 5

6 Understanding swap() d. Registers %rdi 0x120 %rsi 0x100 %rax 123 %rdx 456 Memory Address 0x120 0x118 0x110 0x108 0x100 swap: (%rdi), %rax # t0 = *xp (%rsi), %rdx # t1 = *yp %rdx, (%rdi) # *xp = t1 %rax, (%rsi) # *yp = t0 Presentation K 11 Understanding swap() e. Registers %rdi 0x120 %rsi 0x100 %rax 123 %rdx 456 Memory Address 0x120 0x118 0x110 0x108 0x100 swap: (%rdi), %rax # t0 = *xp (%rsi), %rdx # t1 = *yp %rdx, (%rdi) # *xp = t1 %rax, (%rsi) # *yp = t0 Presentation K 12 6

7 Understanding swap() f. Registers %rdi 0x120 %rsi 0x100 %rax 123 %rdx 456 Memory Address 0x120 0x118 0x110 0x108 0x100 swap: (%rdi), %rax # t0 = *xp (%rsi), %rdx # t1 = *yp %rdx, (%rdi) # *xp = t1 %rax, (%rsi) # *yp = t0 Presentation K 13 Function Calling swap() void swap(long *,long *); long main() long x= 123; long y= 456; swap(&x, &y); urn 1; Instruction subq $24, enlargers stack for 24 bytes, for local variables x and y, plus additional 8 bytes (why??). Before urn, addq adjusts stack for instruction. Compilation command: gcc O1 -S main.swap.c generated this x86-64 assembly code (with minor changes in red): subq leaq call addq $24, $123, 8() $456, (), %rsi 8(), %rdi swap $1, %rax $24, Presentation K 14 7

8 Understanding Calling swap() a. urn adr 1000 after main is called urn adr subq $24, $123, 8() $456, (), %rsi leaq 8(), %rdi call swap $1, %rax addq $24, 976 Presentation K 15 Understanding Calling swap() b. 976 Address 0 urn adr x y subq leaq call addq $24, $123, 8() $456, (), %rsi 8(), %rdi swap $1, %rax $24, Presentation K 16 8

9 Understanding Calling swap() c. 976 Register %rdi %rsi Value &x &y 456 Address urn adr 1000 x y subq leaq call addq %rdi %rsi $24, $123, 8() $456, (), %rsi 8(), %rdi swap $1, %rax $24, Presentation K 17 Understanding Calling swap() d. Address urn adr urn adr 968 subq leaq call addq $24, $123, 8() $456, (), %rsi 8(), %rdi swap $1, %rax $24, Address of this instruction PC set to the address of swap() Presentation K 18 9

10 Function main with Global Variables void swap(long*,long*); long x= 123; long y= 456; void main() swap(&x, &y); urn 1; Function swap is unchanged. Compilation command: gcc O1 -S main.g.swap.c generated this x86-64 assembly code (with minor changes in red): subq $8, $y, %rsi $x, %rdi call swap $1, %rax addq $8,.align 8 x:.quad 123 y:.quad 456 Presentation K 19 Procedure Data Flow Carnegie Mellon Registers First 6 arguments %rdi %rsi %rdx %rcx %r8 %r9 Return value %rax Arg n Arg 8 Arg 7 Only allocate stack space when needed Presentation K 20 10

11 Function Calling arithex() long arithex(long, long, long, long, long, long, long, long); long main() Compilation command: gcc -O1 S main.arithex.c generated this x86-64 assembly code (with minor changes in red): long a,b,c,d,e,f,g,h,w; subq $24, a=100; $31, 8() b=12345; $29, () c=98765; $27, %r9 d=23; $25, %r8 e=25; $23, %rcx f=27; $98765, %rdx g=29; $12345, %rsi h=31; $100, %rdi w=arithex(a,b,c,d,e,f,g,h); call arithex w++; addq $1, %rax urn w; addq $24, Presentation K 21 Understanding Calling arithex() and registers after main is called urn adr 1000 and registers before call arithex urn adr subq $24, $31, 8() $29, () $27, %r9 $25, %r8 $23, %rcx $98765, %rdx $12345, %rsi $100, %rdi call arithex 976 %rdi= 100 %rsi= %rdx= %rcx= 23 %r8= 25 %r9=

12 Function arithex() long arithex(long x, long y, long z, long w, long m, long n, long o, long p) urn (x+y+z+w+m+n+o+p); Compilation command: gcc -O1 -S arithex.c arithex: leaq (%rsi,%rdi),%rdi ;%rdi y+x leaq (%rdi,%rdx),%rdx ;%rdx y+x+z addq %rcx, %rdx ;%rdx y+x+z+w addq %r8, %rdx ;%rdx y+x+z+w+m addq %r9, %rdx ;%rdx y+x+z+w+m+n %rdx, %rax ;%rax y+x+z+w+m+n addq 8(), %rax ;%rax y+x+z+w+m+n+o addq 16(), %rax ;%rax y+x+z+w+m+n+o+p Presentation K 23 X86-64/Linux Frame Structure Current Frame ( Top to Bottom) Argument build: parameters for function about to call Local variables, if can t keep in registers Saved register context, if needed Caller Frame Return address, pushed by call instruction Arguments 7, 8 for this call Increasing addresses Argument n Argument 7 Return address Saved registers, local variables, and temporary space (if need) bottom Earlier frames Caller s frame Current (callee) frame pointer Argument build area top 24 12

13 Observations About Function Calling is the right data structure for function call / urn pattern (Last-In, First-Out): if P calls Q, then Q urns before P. allow that each function has private storage for: urn address, local variables (if needed), function arguments (if needed), saved registers (if needed). Register saving conventions prevent one function from corrupting another s data. Return value (result) in %rax. Recursion is handled without special consideration. Also works for mutual recursion, i.e. P calls Q; Q calls P. Presentation K 25 Call Chain Example ( ) (); ( ) (); (); ( ) (); Example Call Chain Procedure () is recursive Presentation K 26 13

14 Call Chain Example (cont.) ( ) (); Presentation K 27 Call Chain Example (cont.) ( ) ( ) (); (); (); Presentation K 28 14

15 Call Chain Example (cont.) ( ) ( ) ( ) (); (); (); (); Presentation K 29 Call Chain Example (cont.) ( ) ( ) ( ) (); (); ( ) (); (); (); Presentation K 30 15

16 Call Chain Example (cont.) ( ) ( ) ( ) (); (); ( ) (); (); ( ) (); (); Presentation K 31 Call Chain Example (cont.) ( ) ( ) ( ) (); (); ( ) (); (); (); Presentation K 32 16

17 Call Chain Example (cont.) ( ) ( ) ( ) (); (); (); (); Presentation K 33 Call Chain Example (cont.) ( ) ( ) (); (); (); Presentation K 34 17

18 Call Chain Example (cont.) ( ) ( ) ( ) (); (); (); (); Presentation K 35 Call Chain Example (cont.) ( ) ( ) (); (); (); Presentation K 36 18

19 Call Chain Example (end) ( ) (); Presentation K 37 main() & swap() Y86-64 Assembly Code # Execution has to begin at address 0.pos 0 init: ir $, # Set up stack pointer call main # call main program halt # Terminate program swap: mr (%rdi), %rax # (%rdi), %rax mr (%rsi), %rdx # (%rsi), %rdx rm %rdx, (%rdi) # %rdx, (%rdi) rm %rax, (%rsi) # %rax, (%rsi) Presentation K 38 19

20 main() & swap() Y86-64 Assembly Code (cont) ir $24, %rax # subq $24, subq %rax, ir $0x123, %rax # $123, 8() rm %rax, 8() ir $0x456, %rax # $456, () rm %rax, () rr, %rsi #, %rsi ir $8, %rdi # leaq 8(), %rdi addq, %rdi call swap ir $1, %rax # $1, %rax ir $24, %r10 # addq $24, addq %r10,.pos 0x200 #The stack starts here and grows to lower addresses :.quad 0 Presentation K 39 main() & swap() Y86-64 Machine Code # Execution has to begin at address 0 0x000:.pos 0 init: 0x000: 30f ir $, # set up stack pointer 0x00a: 803d call main # call main program 0x013: 00 halt # terminate program swap: 0x014: mr (%rdi), %rax 0x01e: mr (%rsi), %rdx 0x028: rm %rdx, (%rdi) 0x032: rm %rax, (%rsi) 0x03c: 90 Presentation K 40 20

21 main() & swap() Y86-64 Machine Code (cont) 0x03d: 30f ir $24, %rax # subq $24, 0x047: 6104 subq %rax, 0x049: 30f ir $0x123, %rax # $123, 8() 0x053: rm %rax, 8() 0x05d: 30f ir $0x456, %rax # $456, () 0x067: rm %rax, () 0x071: 2046 rr, %rsi #, %rsi 0x073: 30f ir $8, %rdi # leaq 8(), %rdi 0x07d: 6047 addq, %rdi 0x07f: call swap 0x088: 30f ir $1, %rax # $1, %rax 0x092: 30fa ir $24, %r10 # addq $24, 0x09c: 60a4 addq %r10, 0x09e: 90 0x200:.pos 0x200 # The stack starts here and # grows to lower addresses 0x200: :.quad x03d: 30f ir $8, %rax # subq $8, 0x047: 6104 subq %rax, 0x049: 30f ir $y, %rsi # $y, %rsi 0x053: 30f ir $x, %rdi # $x, %rdi 0x05d: call swap # call swap 0x066: 30f ir $1, %rax # $1, %rax 0x070: 30fa ir $8, %r10 # addq $8, 0x07a: 60a4 addq %r10, 0x07c: 90 0x080:.align 8 0x080: x:.quad 0x123 0x088: y:.quad 0x456 0x200:.pos 0x200 #The stack starts here 0x200: :.quad 0 main() & swap() with Global Variables Presentation K 42 21

22 Function with struct Argument (new slides) struct pair long a; long b; long c; long d; ; long xyz(struct pair p); long main() struct pair x; long y; x.a = 1; x.b = 2; x.c = 3; x.d = 4; y = xyz(x); y=y+1; urn y; Compilation command: gcc O1 -S strmain.c generated this x86-64 assembly code Presentation K subq call addq addq $72, $1, 32() $2, 40() $3, 48() $4, 56() $1, () $2, 8() $3, 16() $4, 24() xyz $1, %rax $72, 43 Function with struct Argument (cont.) struct pair long a; long b; long c; long d; ; long xyz(struct pair p) long a; a=p.a + p.b + p.c + p.d; urn a; Compilation command: gcc O1 -S structurer.c generated this x86-64 assembly code xyz: addq addq addq 16(), %rax 8(), %rax 24(), %rax 32(), %rax Presentation K 44 22

23 Function with struct Argument & Return struct pair long a; long b; long c; long d; ; struct pair xyz(struct pair p); long int main() struct pair x, y; x.a = 1; x.b = 2; x.c = 3; x.d = 4; y = xyz(x); urn 1; Compilation command: gcc O1 -S strmainnew.c generated this x86-64 assembly code subq $104, $1, 64() $2, 72() $3, 80() $4, 88() leaq 32(), %rdi $1, () $2, 8() $3, 16() $4, 24() call xyz $1, %rax addq $104, Presentation K 45 Function with struct Argument & Return (cont.) struct pair long a; long b; long c; long d; ; struct pair xyz(struct pair p) struct pair z; z.a=p.a ; z.b=p.b ; z.c=p.c ; z.d=p.d ; urn z; Compilation command: gcc O1 -S structurernew.c generated this x86-64 assembly code xyz: %rdi, %rax 32(), %rdx %rdx, 24(%rdi) 24(), %rdx %rdx, 16(%rdi) 16(), %rdx %rdx, 8(%rdi) 8(), %rdx %rdx, (%rdi) 46 23

Assembly III: Procedures. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Assembly 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 information

Machine Program: Procedure. Zhaoguo Wang

Machine 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 information

The Stack & Procedures

The 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 information

Machine-Level Programming III: Procedures

Machine-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 information

Machine-level Programs Procedure

Machine-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 information

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

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon 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 information

Mechanisms in Procedures. CS429: Computer Organization and Architecture. x86-64 Stack. x86-64 Stack Pushing

Mechanisms 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 information

Stack Frame Components. Using the Stack (4) Stack Structure. Updated Stack Structure. Caller Frame Arguments 7+ Return Addr Old %rbp

Stack 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 information

Machine Programming 3: Procedures

Machine 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 information

Compiling C Programs Into X86-64 Assembly Programs

Compiling C Programs Into X86-64 Assembly Programs CSE 2421: Systems I Low-Level Programming and Computer Organization Compiling C Programs Into X86-64 Assembly Programs Part B: If Else, Loops, Recursion & Switch Presentation L Read/Study: Bryant 3.6 Gojko

More information

The Stack & Procedures

The 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 information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: February 28, 2018 at 06:32 CS429 Slideset 9: 1 Mechanisms in Procedures

More information

Machine Level Programming: Basics

Machine Level Programming: Basics Machine Level Programming: Basics Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Why do we look at machine code? understanding how the high-level programming

More information

C to Machine Code x86 basics: Registers Data movement instructions Memory addressing modes Arithmetic instructions

C to Machine Code x86 basics: Registers Data movement instructions Memory addressing modes Arithmetic instructions C to Machine Code x86 basics: Registers Data movement instructions Memory addressing modes Arithmetic instructions Program, Application Software Hardware next few weeks Programming Language Compiler/Interpreter

More information

L08: Assembly Programming II. Assembly Programming II. CSE 351 Spring Guest Lecturer: Justin Hsia. Instructor: Ruth Anderson

L08: Assembly Programming II. Assembly Programming II. CSE 351 Spring Guest Lecturer: Justin Hsia. Instructor: Ruth Anderson Assembly Programming II 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 information

University of Washington

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

More information

MACHINE LEVEL PROGRAMMING 1: BASICS

MACHINE LEVEL PROGRAMMING 1: BASICS MACHINE LEVEL PROGRAMMING 1: BASICS CS 045 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

More information

Assembly I: Basic Operations. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Assembly I: Basic Operations. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Assembly I: Basic Operations Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Basic Execution Environment RAX RBX RCX RDX RSI RDI RBP RSP R8 R9 R10

More information

Machine Level Programming: Basics

Machine Level Programming: Basics Machine Level Programming: Basics Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed

More information

x86 64 Programming I CSE 351 Autumn 2017 Instructor: Justin Hsia

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

More information

Assembly Programming IV

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

More information

x86 Programming II CSE 351 Winter

x86 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 information

Assembly Language: Function Calls

Assembly 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 information

Princeton 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 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 information

Procedures and the Call Stack

Procedures 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 information

Data Representa/ons: IA32 + x86-64

Data 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 information

Chapter 3 Machine-Level Programming I: Basics. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Chapter 3 Machine-Level Programming I: Basics. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition Chapter 3 Machine-Level Programming I: Basics 1 Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics: Registers, operands, move Arithmetic

More information

Machine- Level Representa2on: Procedure

Machine- 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 information

CS201- Lecture 7 IA32 Data Access and Operations Part II

CS201- Lecture 7 IA32 Data Access and Operations Part II CS201- Lecture 7 IA32 Data Access and Operations Part II RAOUL RIVAS PORTLAND STATE UNIVERSITY Announcements 2 Address Computation Examples %rdx %rcx 0xf000 0x0100 movq 8(%rdx),%rax movq (%rdx,%rcx),%rax

More information

Machine-Level Programming I: Basics

Machine-Level Programming I: Basics Machine-Level Programming I: Basics CSE 238/2038/2138: Systems Programming Instructor: Fatma CORUT ERGİN Slides adapted from Bryant & O Hallaron s slides 1 Today: Machine Programming I: Basics History

More information

Machine-Level Programming (2)

Machine-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 information

Intel x86-64 and Y86-64 Instruction Set Architecture

Intel x86-64 and Y86-64 Instruction Set Architecture CSE 2421: Systems I Low-Level Programming and Computer Organization Intel x86-64 and Y86-64 Instruction Set Architecture Presentation J Read/Study: Bryant 3.1 3.5, 4.1 Gojko Babić 03-07-2018 Intel x86

More information

Topics of this Slideset. CS429: Computer Organization and Architecture. Instruction Set Architecture. Why Y86? Instruction Set Architecture

Topics of this Slideset. CS429: Computer Organization and Architecture. Instruction Set Architecture. Why Y86? Instruction Set Architecture Topics of this Slideset CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Intro to Assembly language Programmer visible state Y86

More information

Compiling C Programs Into X86-64 Assembly Programs

Compiling C Programs Into X86-64 Assembly Programs CSE 2421: Systems I Low-Level Programming and Computer Organization Compiling C Programs Into X86-64 ssembly Programs Part C: rrays & Structure Read/Study: Bryant 3.8, 3.9.1 Gojko Babić 04-02-2018 Statement:

More information

Machine- Level Programming III: Switch Statements and IA32 Procedures

Machine- Level Programming III: Switch Statements and IA32 Procedures Machine- Level Programming III: Switch Statements and IA32 Procedures CS 485: Systems Programming Fall 2015 Instructor: James Griffioen Adapted from slides by R. Bryant and D. O Hallaron (hjp://csapp.cs.cmu.edu/public/instructors.html)

More information

6.1. CS356 Unit 6. x86 Procedures Basic Stack Frames

6.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 information

CSE P 501 Exam Sample Solution 12/1/11

CSE 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 information

x86 Programming I CSE 351 Winter

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

More information

void 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 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 information

Sungkyunkwan University

Sungkyunkwan University Switch statements IA 32 Procedures Stack Structure Calling Conventions Illustrations of Recursion & Pointers long switch_eg (long x, long y, long z) { long w = 1; switch(x) { case 1: w = y*z; break; case

More information

CS 107. Lecture 13: Assembly Part III. Friday, November 10, Stack "bottom".. Earlier Frames. Frame for calling function P. Increasing address

CS 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 information

CSE P 501 Exam 12/1/11

CSE P 501 Exam 12/1/11 Name There are 7 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following references:

More information

x86 64 Programming II

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

More information

Machine-Level Programming I: Basics

Machine-Level Programming I: Basics Machine-Level Programming I: Basics 15-213/18-213: Introduction to Computer Systems 5 th Lecture, September 13, 2016 Instructor: Phil Gibbons 1 Today: Machine Programming I: Basics History of Intel processors

More information

Computer 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 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 information

Computer Systems C S Cynthia Lee

Computer 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 information

L09: Assembly Programming III. Assembly Programming III. CSE 351 Spring Guest Lecturer: Justin Hsia. Instructor: Ruth Anderson

L09: 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 information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: October 11, 2017 at 17:42 CS429 Slideset 6: 1 Topics of this Slideset

More information

Meet & Greet! Come hang out with your TAs and Fellow Students (& eat free insomnia cookies) When : TODAY!! 5-6 pm Where : 3rd Floor Atrium, CIT

Meet & Greet! Come hang out with your TAs and Fellow Students (& eat free insomnia cookies) When : TODAY!! 5-6 pm Where : 3rd Floor Atrium, CIT Meet & Greet! Come hang out with your TAs and Fellow Students (& eat free insomnia cookies) When : TODAY!! 5-6 pm Where : 3rd Floor Atrium, CIT CS33 Intro to Computer Systems XI 1 Copyright 2017 Thomas

More information

Credits and Disclaimers

Credits 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 information

Function Calls and Stack

Function Calls and Stack Function Calls and Stack Philipp Koehn 16 April 2018 1 functions Another Example 2 C code with an undefined function int main(void) { int a = 2; int b = do_something(a); urn b; } This can be successfully

More information

Machine Level Programming I: Basics

Machine Level Programming I: Basics Carnegie Mellon Machine Level Programming I: Basics Kai Shen Why do I care for machine code? Chances are, you ll never write programs in machine code Compilers are much better & more patient than you are

More information

Lecture 4: x86_64 Assembly Language

Lecture 4: x86_64 Assembly Language CSCI-GA.1144-001 PAC II Lecture 4: x86_64 Assembly Language Some slides adapted (and slightly modified) from: Randy Bryant Dave O Hallaron Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com

More information

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

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon Carnegie Mellon Machine-Level Programming I: Basics 15-213/18-213/15-213: Introduction to Computer Systems 5 th Lecture, September 12, 2017 Today s Instructor: Phil Gibbons 2 Today: Machine Programming

More information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: October 9, 2017 at 10:51 CS429 Slideset 7: 1 Topics of this Slideset

More information

Buffer Overflow Attack (AskCypert CLaaS)

Buffer 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 information

CSC 252: Computer Organization Spring 2018: Lecture 6

CSC 252: Computer Organization Spring 2018: Lecture 6 CSC 252: Computer Organization Spring 2018: Lecture 6 Instructor: Yuhao Zhu Department of Computer Science University of Rochester Action Items: Assignment 2 is out Announcement Programming Assignment

More information

Machine-Level Programming I: Basics

Machine-Level Programming I: Basics Machine-Level Programming I: Basics 15-213/18-213: Introduction to Computer Systems 5 th Lecture, January 30, 2018 Instructors: Franz Franchetti and Seth C. Goldstein 1 Office Hours Not too well attended

More information

cmovxx 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

cmovxx 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 information

%r8 %r8d. %r9 %r9d. %r10 %r10d. %r11 %r11d. %r12 %r12d. %r13 %r13d. %r14 %r14d %rbp. %r15 %r15d. Sean Barker

%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 information

Systems Programming and Computer Architecture ( )

Systems Programming and Computer Architecture ( ) Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-0061-00) Timothy Roscoe Herbstsemester 2016 AS 2016 Compiling C Control Flow 1 8: Compiling C

More information

Assembly Programming IV

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

More information

Machine/Assembler Language Putting It All Together

Machine/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 information

Systems I. Machine-Level Programming V: Procedures

Systems I. Machine-Level Programming V: Procedures Systems I Machine-Level Programming V: Procedures Topics abstraction and implementation IA32 stack discipline Procedural Memory Usage void swap(int *xp, int *yp) int t0 = *xp; int t1 = *yp; *xp = t1; *yp

More information

Carnegie Mellon. 5 th Lecture, Jan. 31, Instructors: Todd C. Mowry & Anthony Rowe

Carnegie Mellon. 5 th Lecture, Jan. 31, Instructors: Todd C. Mowry & Anthony Rowe Machine Level Programming I: Basics 15 213/18 213: 213: Introduction to Computer Systems 5 th Lecture, Jan. 31, 2012 Instructors: Todd C. Mowry & Anthony Rowe 1 Today: Machine Programming gi: Basics History

More information

Foundations of Computer Systems

Foundations of Computer Systems 18-600 Foundations of Computer Systems Lecture 5: Data and Machine-Level Programming I: Basics September 13, 2017 Required Reading Assignment: Chapter 3 of CS:APP (3 rd edition) by Randy Bryant & Dave

More information

CSE 351 Midterm Exam Spring 2016 May 2, 2015

CSE 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 information

Unit 8: Programming Languages CS 101, Fall 2018

Unit 8: Programming Languages CS 101, Fall 2018 Unit 8: Programming Languages CS 101, Fall 2018 Learning Objectives After completing this unit, you should be able to: Explain the difference between an assembler, compiler, and interpreter. Name and describe

More information

Machine-Level Programming V: Unions and Memory layout

Machine-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 information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 7

CS24: 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 information

Computer Organization: A Programmer's Perspective

Computer 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 information

x86-64 Programming III

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

More information

18-600: Recitation #4 Exploits (Attack Lab)

18-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 information

CSCI 2021: x86-64 Control Flow

CSCI 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 information

CS356: Discussion #15 Review for Final Exam. Marco Paolieri Illustrations from CS:APP3e textbook

CS356: 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 information

Computer Organization: A Programmer's Perspective

Computer Organization: A Programmer's Perspective A Programmer's Perspective Machine-Level Programming (4: Data Structures) Gal A. Kaminka galk@cs.biu.ac.il Today Arrays One-dimensional Multi-dimensional (nested) Multi-level Structures Allocation Access

More information

Assembly III: Procedures. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Assembly 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 IA-32 (1) Characteristics Region of memory managed with stack discipline

More information

Machine-Level Programming II: Control

Machine-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 information

Register Allocation, i. Overview & spilling

Register Allocation, i. Overview & spilling Register Allocation, i Overview & spilling 1 L1 p ::=(label f...) f ::=(label nat nat i...) i ::=(w

More information

Where We Are. Optimizations. Assembly code. generation. Lexical, Syntax, and Semantic Analysis IR Generation. Low-level IR code.

Where 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 information

Today: Machine Programming I: Basics. Machine-Level Programming I: Basics. Intel x86 Processors. Intel x86 Evolution: Milestones

Today: Machine Programming I: Basics. Machine-Level Programming I: Basics. Intel x86 Processors. Intel x86 Evolution: Milestones Today: Machine Programming I: Basics Machine-Level Programming I: Basics CSci 2021: Machine Architecture and Organization Lectures #7-8, February 3th-5th, 2016 Assembly Basics:, operands, move Arithmetic

More information

Areas for growth: I love feedback

Areas 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 information

ASSEMBLY III: PROCEDURES. Jo, Heeseung

ASSEMBLY III: PROCEDURES. Jo, Heeseung ASSEMBLY III: PROCEDURES Jo, Heeseung IA-32 STACK (1) Characteristics Region of memory managed with stack discipline Grows toward lower addresses Register indicates lowest stack address - address of top

More information

18-600: Recitation #4 Exploits

18-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 information

Machine Level Programming I: Basics. Credits to Randy Bryant & Dave O Hallaron

Machine Level Programming I: Basics. Credits to Randy Bryant & Dave O Hallaron Machine Level Programming I: Basics Lecture 3, Feb. 24, 2011 Alexandre David Credits to Randy Bryant & Dave O Hallaron from Carnegie Mellon 1 Today: Machine Programming I: Basics History of Intel processors

More information

Question Points Score Total: 100

Question 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 information

Assembly III: Procedures. Jo, Heeseung

Assembly III: Procedures. Jo, Heeseung Assembly III: Procedures Jo, Heeseung IA-32 Stack (1) Characteristics Region of memory managed with stack discipline Grows toward lower addresses Register indicates lowest stack address - address of top

More information

The Hardware/Software Interface CSE351 Spring 2015

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

More information

CSC 252: Computer Organization Spring 2018: Lecture 5

CSC 252: Computer Organization Spring 2018: Lecture 5 CSC 252: Computer Organization Spring 2018: Lecture 5 Instructor: Yuhao Zhu Department of Computer Science University of Rochester Action Items: Assignment 1 is due tomorrow, midnight Assignment 2 is out

More information

Control flow (1) Condition codes Conditional and unconditional jumps Loops Conditional moves Switch statements

Control flow (1) Condition codes Conditional and unconditional jumps Loops Conditional moves Switch statements Control flow (1) Condition codes Conditional and unconditional jumps Loops Conditional moves Switch statements 1 Conditionals and Control Flow Two key pieces 1. Comparisons and tests: check conditions

More information

x86-64 Programming III & The Stack

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

More information

Today: Machine Programming I: Basics

Today: Machine Programming I: Basics Today: Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics: Registers, operands, move Intro to x86-64 1 Intel x86 Processors Totally dominate

More information

Machine Level Programming: Arrays, Structures and More

Machine Level Programming: Arrays, Structures and More Machine Level Programming: rrays, Structures and More Computer Systems Organization (Spring 2016) CSCI-U 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O

More information

C to Assembly SPEED LIMIT LECTURE Performance Engineering of Software Systems. I-Ting Angelina Lee. September 13, 2012

C 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 information

Recitation: Attack Lab

Recitation: 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 information

143A: 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 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 information

x86 64 Programming I CSE 351 Autumn 2018 Instructor: Justin Hsia

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

More information

143A: 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 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 information

Lecture 4 CIS 341: COMPILERS

Lecture 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 information

x86 Programming I CSE 351 Autumn 2016 Instructor: Justin Hsia

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

More information