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 B: If Else, Loops, Recursion & Switch Presentation L Read/Study: Bryant 3.6 Gojko Babić General if- Branching Translation Code with if block if (Test) Statement 1a ; Statement 2a ; Statement na ; Statement 1b ; Statement 2b ; Statement nb ; Statement next ; Goto Version ntest =!Test; if (ntest) goto Else; Statement 1a ; Statement 2a ; Statement na ; goto Done; Else: Statement 1b ; Statement 2b ; Statement nb ; Done: Statement Next ; Presentation L 2 1

2 if- Branching: Example A Code with if block long GenBranch(long x, long y, long z) if (x > y) x = x+y; z = z+y; x = x-y; z = z-y; urn x+z; Goto Version long GenBranch(long x, long y, long z) int ntest = x <= y; if (ntest) goto Else; x = x+y; z = z+y; goto Done; Else: x = x-y; z = z-y; Done: urn x+z; Both C codes compile into identical assembly code. We shall consider goto version, since it is closer to the assembly code. Presentation L 3 if- Branching: Example A (cont.) long GenBranch(long x, long y, long z) int ntest = x <= y; if (ntest) goto Else; x = x+y; z = z+y; goto Done; Else: x = x-y; z = z-y; Done: urn x+z; Compilation command: gcc -O1 -S GenBranch.c GenBranch: cmpq %rsi, %rdi # x:y jle.l2 leaq (%rsi,%rdi), %rdi leaq (%rdx,%rsi), %rsi jmp.l3.l2: subq %rsi, %rdi subq %rsi, %rdx movq %rdx, %rsi leaq (%rsi,%rdi), %rax Register %rdi %rsi %rdx %rax Use(s) Argument x Argument y Argument z Return value 4 2

3 if- Branching: Example B Code with if block long absdiff (long x, long y) long result; if (x > y) result = x-y; result = y-x; urn result; Goto Version long absdiff (long x, long y) long result; int ntest = x <= y; if (ntest) goto Else; result = x-y; urn result; Else: result = y-x; urn result; Assembly code following C code on the right will include branching. Branches are very disruptive to instruction flow through CPU pipelines, and when possible (as it is in this case) a compiler uses conditional move which doesn t require control transfer. g.babic Presentation L 5 if- Branching: Example B1 long absdiff (long x, long y) Compilation command: gcc -O1 -S absdiff.c long result; if (x > y) result = x-y; Register Use(s) %rdi Argument x result = y-x; %rsi Argument y urn result; %rax Return value absdiff: movq %rdi, %rax # x subq %rsi, %rax # result = x-y movq %rsi, %rdx subq %rdi, %rdx # eval = y-x cmpq %rsi, %rdi # x:y cmovle %rdx, %rax # if <=, result = eval 6 3

4 if- Branching: Example B2 long absdiff (long x, long y) long result; int ntest = x <= y; if (ntest) goto Else; result = x-y; urn result; Else: result = y-x; urn result; Register %rdi %rsi %rax Use(s) Argument x Argument y Return value Compilation command: gcc -O1 -S fno-if-conversion absdiff.c generates this x86-64 assembly code: absdiff: cmpq %rsi, %rdi # x:y jle.l2 movq %rdi, %rax subq %rsi, %rax.l2: # x <= y movq %rsi, %rax subq %rdi, %rax Option fno-if-conversion absdiff.c in compilation command generates this old style code. Presentation L 7 General do-while Loop Translation Carnegie Mellon Do While Version do Statement 1 ; Statement 2 ; Statement n ; while (Test); loop: Goto Version Statement 1 ; Statement 2 ; Statement n ; if (Test) goto loop Test urns integer: if = 0 interped as false if 0 interped as true Presentation L 8 4

5 do-while Loop Example Do While Version long pcount_do(unsigned long x) do result += x & 0x1; x >>= 1; while (x); urn result; Goto Version long pcount_do(unsigned long x) loop: result += x & 0x1; x >>= 1; if (x) goto loop; urn result; Both of these functions count the number of 1 s in the argument x and urn that value and both C codes are compiled into identical assembly code. We shall be examining a code goto version, because it is closer to compiled assembly code. Presentation L 9 long pcount_do(unsigned long x) loop: result += x & 0x1; x >>= 1; if (x) goto loop; urn result; Compiling pcount_do.c Compilation command: gcc -O1 -S pcount_do.c generates this x86-64 assembly code (with minor changes in red) Register %rdi %rax Use(s) Argument x result pcount_do:.l2: movq %rdi, %rdx andq $1, %rdx addq %rdx, %rax jne.l2 # if (%rdi) goto loop:, i.e. to.l2: rep # rep = noop; See Brayant page

6 General while Loop Translation Carnegie Mellon While Version while (Test) Statement 1 ; Statement 2 ; Statement n ; Do While Version if (!Test) goto done; do Statement 1 ; Statement 2 ; Statement n ; while (Test); done: Goto Version if (!Test) goto done; loop: Statement 1 ; Statement 2 ; Statement n ; if(test) goto loop done: Presentation L 11 While version long pcount_while(unsigned long x) while (x) result += x & 0x1; x >>= 1; urn result; Goto Version long pcount_while(unsigned long x) if (!x) goto done; loop: result += x & 0x1; x >>= 1; if (x) goto loop; done: urn result; This code must jump to skip the loop if the initial test fails Both C codes above compile into identical assembly codes and we shall be examining a code goto version, because it is closer to compiled assembly code. while Loop Example Presentation L 12 6

7 Compiling pcount_while.c long pcount_while(unsigned long x) if (!x) goto done; loop: result += x & 0x1; x >>= 1; if (x) goto loop; done: urn result; Compilation command: gcc -O1 -S pcount_while.c generates this x86-64 assembly code (with minor changes in red): pcount_while: testq %rdi, %rdi.l6: movq %rdi, %rdx andq $1, %rdx addq %rdx, %rax jne.l6 rep Register %rdi %rax Use(s) Argument x result Presentation L 13 for Loop Version for (Init; Test; Update) Body Init; while (Test) Body Update; for Loop Version Goto Version while Loop Version do-while Loop Version if (!Test) goto done; Init; do Body Update while(test); done: Goto Version if (!Test) goto done; Init; loop: Body Update if (Test) goto loop; done: 14 7

8 For Loop Example long pcount_for(unsigned long x) long i; for (i = 0; i < 64; i++) result += (x & 0x1); x >>=1; urn result; Init i = 0 Test i < 64 Update i++ Body result += (x & 0x1); x >>=1; Presentation L 15 long pcount_for(unsigned long x) long i; for (i = 0; i < 64; i++) result += (x & 0x1); x >>=1; urn result; Compilation command: gcc -O1 S pcount_for.c generated this x86-64 assembly Compiling pcount_for.c code (with minor changes in red) Presentation L pcount_for: movq $0, %rdx.l2: movq %rdi, %rcx andq $1, %rcx addq %rcx, %rax addq $1, %rdx cmpq $64, %rdx jne.l2 rep Note: Code above doesn t have test at the beginning, because the compiler figures out it is not necessary. 16 8

9 Compiling pcount_forn33.c int pcount_forn33(unsigned long x) long i,n; N=33; for (i = N; i < 32; i++) result += (x & 0x1); x >>=1; urn result; pcount_forn33: Assembly code is simple since the compiler figures out that urn value is always 0. Compilation command: gcc -O1 S pcount_forn33.c Presentation L 17 Recursive Function /* Recursive popcount */ long pcount_r(unsigned long x) if (x == 0) urn 0; urn (x & 1) + pcount_r(x >> 1); Compilation command: gcc -O1 S pcount_r.c generates this x86-64 assembly code (with minor changes in red) In the following slides, slightly changed code is analyzed; only 3 blue instructions will be moved to make the code more understandable. pcount_r: pushq %rbx movq %rdi, %rbx testq %rdi, %rdi #shift 1 call pcount_r andq $1, %rbx addq %rbx, %rax popq %rbx Presentation L 18 9

10 Recursive Function Terminal Case /* Recursive popcount */ long pcount_r(unsigned long x) if (x == 0) urn 0; urn (x & 1) + pcount_r(x >> 1); Register Use(s) Type %rdi x Argument %rax Return value Return value pcount_r: testq %rdi, %rdi pushq %rbx movq %rdi, %rbx andq $1, %rbx call pcount_r addq %rbx, %rax popq %rbx Presentation L 19 Recursive Function Register Save /* Recursive popcount */ long pcount_r(unsigned long x) if (x == 0) urn 0; urn (x & 1) + pcount_r(x >> 1); Register Use(s) Type %rdi x Argument... Rtn address Saved %rbx %rsp pcount_r: testq %rdi, %rdi pushq %rbx movq %rdi, %rbx andq $1, %rbx call pcount_r addq %rbx, %rax popq %rbx Note that register %rbx has to be urned from called function unchanged. Presentation L 20 10

11 Recursive Function Call Setup /* Recursive popcount */ long pcount_r(unsigned long x) if (x == 0) urn 0; urn (x & 1) + pcount_r(x >> 1); Register Use(s) Type %rdi x >> 1 Rec. argument %rbx x & 1 Callee-saved pcount_r: testq %rdi, %rdi pushq %rbx movq %rdi, %rbx andq $1, %rbx call pcount_r addq %rbx, %rax popq %rbx Presentation L 21 Recursive Function Call /* Recursive popcount */ long pcount_r(unsigned long x) if (x == 0) urn 0; urn (x & 1) + pcount_r(x >> 1); Register Use(s) Type %rbx x & 1 Callee-saved %rax Recursive call urn value pcount_r: testq %rdi, %rdi pushq %rbx movq %rdi, %rbx andq $1, %rbx call pcount_r addq %rbx, %rax popq %rbx Presentation L 22 11

12 Recursive Function Result /* Recursive popcount */ long pcount_r(unsigned long x) if (x == 0) urn 0; urn (x & 1) + pcount_r(x >> 1); Register Use(s) Type %rbx x & 1 Callee-saved %rax Return value pcount_r: testq %rdi, %rdi pushq %rbx movq %rdi, %rbx andq $1, %rbx call pcount_r addq %rbx, %rax popq %rbx Presentation L 23 Recursive Function Completion /* Recursive popcount */ long pcount_r(unsigned long x) if (x == 0) urn 0; urn (x & 1) + pcount_r(x >> 1); Register Use(s) Type %rax Return value Return value pcount_r: testq %rdi, %rdi pushq %rbx movq %rdi, %rbx andq $1, %rbx call pcount_r addq %rbx, %rax popq %rbx... %rsp Presentation L 24 12

13 Switch Statement switch(x) case val_0: Block 0 case val_1: Block 1 case val_n-1: Block n 1 default: Block n Jump Table JTab: Targ Targ Targ Targ Switch statements will be decomposed into blocks and jump table; Blocks 0, 1,, n will be accessed through Jump Presentation L table Targ 0 : Targ 1 : Targ 2 : Targ n-1 : Targ n : Jump Targets Code Block 0 Code Block 1 Code Block 2 Code Block n 1 Code Block n 25 Switch Statement Example long switch_eg (long x, long y, long z) long w = 1; switch(x) case 1: w = y*z; break; case 2: w = y/z; case 3: w += z; break; case 5: case 6: w -= z; break; default: w = 2; urn w; In this example, we have all possible cases with case labels: multiple case labels: 5 &6 fall through case: 2 missing case: 4 default Compilation command: gcc -O1 -S switch_eg.c generated x86-64 assembly code on the following slide: Presentation L 26 13

14 Compiling switch_eg.c.text switch_eg: movq %rdx, %rcx cmpq $6, %rdi ja.l2 jmp *.L7(,%rdi,8).section.rodata.align 8.L7:.quad.L2.quad.L3.quad.L4.quad.L5.quad.L2.quad.L6.quad.L6.text: code section.rodata = read only data.text.l2: movq $2, %rax.l5: movq $1, %rax jmp.l9 movq %rdx, %rax imulq %rsi, %rax.l4: movq %rsi, %rdx movq %rsi, %rax sarq $63, %rdx idivq %rcx.l9: addq %rcx, %rax.l6: movq $1, %rax subq %rdx, %rax 27 Switch Statement Setup long switch_eg (long x, long y, long z) long w = 1; switch(x)... default: w = 2; urn w; switch_eg: movq cmpq %rdx, %rcx $6, %rdi ja.l2 #if >6, default jmp *.L7(,%rdi,8) Indirect jump: jmp *.L7(,%rdi,8) fetch jump target from effective address.l7 + %rdi*8 Register Use(s) %rdi Argument x %rsi Argument y %rdx Argument z %rax Return value Jump Table.section.rodata.align 8.L7:.quad.L2 #x = 0.quad.L3 #x = 1.quad.L4 #x = 2.quad.L5 #x = 3.quad.L2 #x = 4.quad.L6 #x = 5.quad.L6 #x =

15 Example Jump Table Jump table.section.rodata.align 8.L7:.quad.L2 #x = 0.quad.L3 #x = 1.quad.L4 #x = 2.quad.L5 #x = 3.quad.L2 #x = 4.quad.L6 #x = 5.quad.L6 #x = 6.text.L2: movq $2, %rax.l5: movq $1, %rax jmp.l9 movq %rdx, %rax imulq %rsi, %rax.l4: movq %rsi, %rdx movq %rsi, %rax sarq $63, %rdx idivq %rcx.l9: addq %rcx, %rax.l6: movq $1, %rax subq %rdx, %rax 29 Sparse Switch Statement Example long switch_sp (long x, long y, long z) int w = 1; switch(x) case 100: w = y*z; break; case 200: w = y/z; case 300: w += z; break; case 400: case 500: w -= z; break; default: w = 2; urn w; Presentation L The example is almost identical to the previous switch example. Except in this example, we have case labels far apart from each other, and jump table would be very large. Compilation command: gcc -O1 -S switch_sp.c generated IA-32 assembly code on the following slide: 30 15

16 Compiling switch_sp.c switch_sp: movq %rdx, %rcx cmpq $300, %rdi je.l5 cmpq $300, %rdi jg.l7 cmpq $100, %rdi cmpq $200, %rdi jne.l2 jmp.l11.l7: cmpq $400, %rdi je.l6 cmpq $500, %rdi je.l6.l2: movq $2, %rax.l5: movq $1, %rax jmp.l9 movq %rdx, %rax imulq %rsi, %rax.l11: movq %rsi, %rdx movq %rsi, %rax sarq $63, %rdx idivq %rcx.l9: addq %rcx, %rax.l6: movq $1, %rax subq %rcx, %rax 31 16

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

Machine-Level Programming II: Control

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

x86 Programming III CSE 351 Autumn 2016 Instructor: Justin Hsia

x86 Programming III CSE 351 Autumn 2016 Instructor: Justin Hsia x86 Programming III 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/648/

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

2/12/2016. Today. Machine-Level Programming II: Control. Condition Codes (Implicit Setting) Processor State (x86-64, Partial)

2/12/2016. Today. Machine-Level Programming II: Control. Condition Codes (Implicit Setting) Processor State (x86-64, Partial) Today Machine-Level Programming II: Control CSci 2021: Machine Architecture and Organization Lectures #9-11, February 8th-12th, 2016 Control: Condition codes Conditional branches Loops Switch Statements

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

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

Machine-Level Programming II: Control

Machine-Level Programming II: Control Machine-Level Programming II: Control 15-213: Introduction to Computer Systems 6 th Lecture, Feb. 2, 2017 Instructors: Franz Franchetti and Seth C. Goldstein 1 Office Hours Thanks for Coming! and sorry

More information

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

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition 1 Machine-Level Programming II: Control 15-213: Introduction to Computer Systems 6 th Lecture, Sept. 13, 2018 2 Today Control: Condition codes Conditional branches Loops Switch Statements 3 Recall: ISA

More information

Outline. Review: Assembly/Machine Code View. Processor State (x86-64, Par2al) Condi2on Codes (Explicit Se^ng: Compare) Condi2on Codes (Implicit Se^ng)

Outline. Review: Assembly/Machine Code View. Processor State (x86-64, Par2al) Condi2on Codes (Explicit Se^ng: Compare) Condi2on Codes (Implicit Se^ng) Outline Machine- Level Representa2on: Control CSCI 2021: Machine Architecture and Organiza2on Pen- Chung Yew Department Computer Science and Engineering University of Minnesota Control: Condi2on codes

More information

CS 33. Machine Programming (2) CS33 Intro to Computer Systems XII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CS 33. Machine Programming (2) CS33 Intro to Computer Systems XII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. CS 33 Machine Programming (2) CS33 Intro to Computer Systems XII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Processor State (x86-64, Partial) %rax %eax %r8 %r8d %rbx %ebx %r9 %r9d %rcx %ecx

More 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 26, 2018 at 12:02 CS429 Slideset 8: 1 Controlling Program

More information

CS367. Program Control

CS367. 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 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

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

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

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

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

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

CS 33. Machine Programming (2) CS33 Intro to Computer Systems XI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

CS 33. Machine Programming (2) CS33 Intro to Computer Systems XI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. CS 33 Machine Programming (2) CS33 Intro to Computer Systems XI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. Observations about arith int arith(int x, int y, int z) { int t1 = x+y; int t2

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

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

Setting & Examining Condition Codes. int gt(long x, long y) { return x > y; } int has_nonzero_masked(long x, long mask) { return!!

Setting & Examining Condition Codes. int gt(long x, long y) { return x > y; } int has_nonzero_masked(long x, long mask) { return!! Setting & Examining Condition Codes int has_nonzero_masked(long x, long mask) urn!!(x & mask); # x in %rdi, y in %rsi, urn value in %eax has_nonzero_masked: xorl %eax, %eax testq %rsi, %rdi setne %al int

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

Foundations of Computer Systems

Foundations of Computer Systems 18-600 Foundations of Computer Systems Lecture 6: Machine-Level Programming III: Loops, Procedures, the Stack, and More September 18, 2017 Required Reading Assignment: Chapter 3 of CS:APP (3 rd edition)

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

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

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

More information

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

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

More information

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

Machine Level Programming: Control

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

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

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

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 A: Function Calling Read/Study: Bryant 3.7.1-3.7.6 Presentation K Gojko Babić

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 15-213: Introduc;on to Computer Systems 6 th Lecture, Sep. 9, 2010 Instructors: Randy Bryant and Dave O Hallaron Today Switch statements

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

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

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

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

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

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

Recitation #6. Architecture Lab

Recitation #6. Architecture Lab 18-600 Recitation #6 Architecture Lab Overview Where we are Archlab Intro Optimizing a Y86 program Intro to HCL Optimizing Processor Design Where we Are Archlab Intro Part A: write and simulate Y86-64

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

Machine Language CS 3330 Samira Khan

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

Assembly II: Control Flow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Assembly II: Control Flow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Assembly II: Control Flow Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Processor State (x86-64) RAX 63 31 EAX 0 RBX EBX RCX RDX ECX EDX General-purpose

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

Assembly II: Control Flow

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

Machine Level Programming II: Arithmetic &Control

Machine Level Programming II: Arithmetic &Control Machine Level Programming II: Arithmetic &Control Arithmetic operations Control: Condition codes Conditional branches Loops Switch Kai Shen 1 2 Some Arithmetic Operations Two Operand Instructions: Format

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

Building an Executable

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

More information

The Hardware/Software Interface CSE351 Spring 2013

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

Controlling Program Flow

Controlling Program Flow Controlling Program Flow Conditionals (If-statement) Loops (while, do-while, for-loops) Switch Statements New Instructions JMP CMP Conditional jumps (branches) Conditional MOV instruction 1 Conditional

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

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 261: MIDTERM 1 February 14, 2017

THE 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 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

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

Sungkyunkwan University

Sungkyunkwan University u Complete addressing mode, address computa3on (leal) u Arithme3c opera3ons u x86-64 u Control: Condi3on codes u Condi3onal branches u While loops int absdiff(int x, int y) { int result; if (x > y) { result

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

CSE 401/M501 Compilers

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

SYSTEMS PROGRAMMING AND COMPUTER ARCHITECTURE Assignment 5: Assembly and C

SYSTEMS PROGRAMMING AND COMPUTER ARCHITECTURE Assignment 5: Assembly and C Fall Term 2016 SYSTEMS PROGRAMMING AND COMPUTER ARCHITECTURE Assignment 5: Assembly and C Assigned on: 20th Oct 2016 Due by: 27th Oct 2016 Pen & Paper exercise Assembly Code Fragments Consider the following

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

CS 3330 Exam 1 Fall 2017 Computing ID:

CS 3330 Exam 1 Fall 2017 Computing ID: S 3330 Fall 2017 xam 1 Variant page 1 of 8 mail I: S 3330 xam 1 Fall 2017 Name: omputing I: Letters go in the boxes unless otherwise specified (e.g., for 8 write not 8 ). Write Letters clearly: if we are

More information

Lecture 3 CIS 341: COMPILERS

Lecture 3 CIS 341: COMPILERS Lecture 3 CIS 341: COMPILERS HW01: Hellocaml! Announcements is due tomorrow tonight at 11:59:59pm. HW02: X86lite Will be available soon look for an announcement on Piazza Pair-programming project Simulator

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

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

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

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

Machine- Level Programming II: Control Structures and Procedures

Machine- Level Programming II: Control Structures and Procedures Machine- Level Programming II: Control Structures and Procedures Fall 2012 Instructors: Aykut & Erkut Erdem Acknowledgement: The course slides are adapted from the slides prepared by R.E. Bryant, D.R.

More information

Machine- Level Programming II: Control Structures and Procedures

Machine- Level Programming II: Control Structures and Procedures Machine- Level Programming II: Control Structures and Procedures Spring 2012 Instructors: Aykut & Erkut Erdem Acknowledgement: The course slides are adapted from the slides prepared by R.E. Bryant, D.R.

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

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

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

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

1. A student is testing an implementation of a C function; when compiled with gcc, the following x86-64 assembly code is produced:

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

CPSC 261 Midterm 1 Tuesday February 9th, 2016

CPSC 261 Midterm 1 Tuesday February 9th, 2016 CPSC 261 Midterm 1 Tuesday February 9th, 2016 [10] 1. Short Answers [2] a. Two CPUs support the same instruction set, and use the same amount of power. CPU A s latency and throughput are both 10% lower

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 Representa/on of Programs: Control Flow cont d. Previous lecture. Do- While loop. While- Do loop CS Instructors: Sanjeev Se(a

Machine Representa/on of Programs: Control Flow cont d. Previous lecture. Do- While loop. While- Do loop CS Instructors: Sanjeev Se(a Machine Representa/on of Programs: Control Flow cont d Instructors: Sanjeev Se(a 1 Previous lecture Do- While loop C Code Goto Version While- Do loop do while (Test); if (Test) goto loop Do- While Version

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

Machine-Level Programming II: Arithmetic & Control /18-243: Introduction to Computer Systems 6th Lecture, 5 June 2012

Machine-Level Programming II: Arithmetic & Control /18-243: Introduction to Computer Systems 6th Lecture, 5 June 2012 n Mello Machine-Level Programming II: Arithmetic & Control 15-213/18-243: Introduction to Computer Systems 6th Lecture, 5 June 2012 Instructors: Gregory Kesden The course that gives CMU its Zip! Last Time:

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

Computer Organization and Architecture

Computer Organization and Architecture CS 045 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition OVERVIEW GENERALLY USEFUL OPTIMIZATIONS

More information

CS 33. Architecture and Optimization (1) CS33 Intro to Computer Systems XV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CS 33. Architecture and Optimization (1) CS33 Intro to Computer Systems XV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. CS 33 Architecture and Optimization (1) CS33 Intro to Computer Systems XV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Simplistic View of Processor while (true) { instruction = mem[rip]; execute(instruction);

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

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

x86-64 Programming II

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

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

Control flow. Condition codes Conditional and unconditional jumps Loops Switch statements

Control flow. Condition codes Conditional and unconditional jumps Loops Switch statements Control flow Condition codes Conditional and unconditional jumps Loops Switch statements 1 Conditionals and Control Flow Familiar C constructs l l l l l l if else while do while for break continue Two

More information

Changelog. Brief Assembly Refresher. a logistics note. last time

Changelog. Brief Assembly Refresher. a logistics note. last time Changelog Brief Assembly Refresher Changes made in this version not seen in first lecture: 23 Jan 2018: if-to-assembly if (...) goto needed b < 42 23 Jan 2018: caller/callee-saved: correct comment about

More information

Machine-Level Programming II: Arithmetic & Control. Complete Memory Addressing Modes

Machine-Level Programming II: Arithmetic & Control. Complete Memory Addressing Modes Machine-Level Programming II: Arithmetic & Control CS-281: Introduction to Computer Systems Instructor: Thomas C. Bressoud 1 Complete Memory Addressing Modes Most General Form D(Rb,Ri,S)Mem[Reg[Rb]+S*Reg[Ri]+

More information

Machine-Level Programming II: Control Flow

Machine-Level Programming II: Control Flow Machine-Level Programming II: Control Flow Today Condition codes Control flow structures Next time Procedures Fabián E. Bustamante, Spring 2010 Processor state (ia32, partial) Information about currently

More information

CSC 252: Computer Organization Spring 2018: Lecture 14

CSC 252: Computer Organization Spring 2018: Lecture 14 CSC 252: Computer Organization Spring 2018: Lecture 14 Instructor: Yuhao Zhu Department of Computer Science University of Rochester Action Items: Mid-term: March 8 (Thursday) Announcements Mid-term exam:

More information

CSE 401 Compilers. x86-64 Lite for Compiler Writers A quick (a) introduccon or (b) review. Hal Perkins Winter UW CSE 401 Winter 2017 J-1

CSE 401 Compilers. x86-64 Lite for Compiler Writers A quick (a) introduccon or (b) review. Hal Perkins Winter UW CSE 401 Winter 2017 J-1 CSE 401 Compilers x86-64 Lite for Compiler Writers A quick (a) introduccon or (b) review [pick one] Hal Perkins Winter 2017 UW CSE 401 Winter 2017 J-1 Agenda Overview of x86-64 architecture Core part only,

More information

Assembly Programming III

Assembly 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 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 31, 2017 at 09:37 CS429 Slideset 10: 1 Basic Data Types

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

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

Changelog. Assembly (part 1) logistics note: lab due times. last time: C hodgepodge

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

Corrections made in this version not seen in first lecture:

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