System Programming and Computer Architecture (Fall 2009)
|
|
- Hugo Nash
- 6 years ago
- Views:
Transcription
1 System Programming and Computer Architecture (Fall 2009) Recitation 2 October 8 th, 2009 Zaheer Chothia zchothia@student.ethz.ch Web:
2 Topics for Today Classroom Exercise 1 Review: Data Lab (Homework 2) Classroom Exercise & Homework 3 Parameter passing Control structures in assembly - If statements - Switch statements - For loops Reading condition codes with C Due in one week: October 15 2
3 Assignment 1
4 Review: Assignment 1 Question 3: Unsigned Two s complement x -x Hex Decimal Decimal Hex E D A F
5 Review: Assignment 1 Question 5: float sum = 255.0; E2 = e = = 7 10 M2 = 1.f = float delta = 1.0e-5; E1 = e = = M1 = 1.f =
6 Review: Assignment 1 Question 5: E = max{e1, E2} = 710 M: sum': rounding What happens after adding delta times? 6
7 Classroom Exercise 1
8 Question 5: Conditional branches What is the value of %eax, when the last label (.L3 and.l17 respectively) is reached? 5.1 %eax := a, %edx := d 1 cmpl %eax, %edx 2 jle.l2 3 subl %eax, %edx 4 movl %edx, %eax 5 jmp.l3 6.L2: 7 subl %edx, %eax 8.L3: %eax := 1, %edx := N 1 testl %ecx, %ecx 2 jle.l17 3 xorl %edx, %edx 4.L18: 5 incl %edx 6 addl %eax, %eax 7 cmpl %edx, %ecx 8 jne.l18 9.L17:
9 Question 5: Conditional branches Solution 5.1 %eax := (a - d) if (d > a) { t = d - a; } else { t = a - d; } 5.2 %eax := 2 N t = 1; for (i = 0; i < N; i++) { t = t * 2; } 9
10 Review: Data Lab (Homework 2)
11 Surprising Results Almost half of the students beat the professor Really? Actually, there was a bug in the data lab Written in good old 32 bit times Use of LONG_MIN from limits.h to get T min But: int and long have different size on 64 bit machines Overflow in test code Accepted incorrect solutions To check if your solution is really correct: Pass -m32 to gcc in the Makefile 11
12 Example: islessorequal int islessorequal(int x, int y) { int x_neg = x>>31; int y_neg = y>>31; return!((!x_neg & y_neg) (!(x_neg ^ y_neg) & (y+~x+1)>>31)); } 12
13 Example: islessorequal int islessorequal(int x, int y) { int x_neg = x>>31; int y_neg = y>>31; return!((!x_neg & y_neg) (!(x_neg ^ y_neg) & (y+~x+1)>>31)); } Are x and y negative? 13
14 Example: islessorequal int islessorequal(int x, int y) { int x_neg = x>>31; int y_neg = y>>31; return!((!x_neg & y_neg) (!(x_neg ^ y_neg) & (y+~x+1)>>31)); } Are x and y negative? one is negative and the other is positive 14
15 Example: islessorequal int islessorequal(int x, int y) { int x_neg = x>>31; int y_neg = y>>31; return!((!x_neg & y_neg) (!(x_neg ^ y_neg) & (y+~x+1)>>31)); } Are x and y negative? both have the same sign recall: invert + increment = negate 15
16 Homework 3
17 Assembler: Warm-up exercise 1 movl $0x40, %eax 2 movl (,%eax,4), %ebx 3 leal 0x88(,%eax,2), %ecx 4 movl (%ecx), %ecx 5 cmpl %ecx, %ebx 6 jg L1 7 <Fragment A> 8 jmp L2 9 L1: 10 <Fragment B> 11 L2: Memory Address Value 0x100 0xff 0x104 0xab 0x108 0x01 Which code fragment would be executed? 17
18 Assembler: Warm-up exercise 1 movl $0x40, %eax 2 movl (,%eax,4), %ebx 3 leal 0x88(,%eax,2), %ecx 4 movl (%ecx), %ecx 5 cmpl %ecx, %ebx 6 jg L1 7 <Fragment A> 8 jmp L2 9 L1: 10 <Fragment B> 11 L2: Memory Address Value 0x100 0xff 0x104 0xab 0x108 0x01 Jump Condition %ebx - %ecx > 0 %ebx > %ecx Which code fragment would be executed? 18
19 IA32 Assembler Cheat Sheet Condition Codes Jump Instruction 1 (unconditional) jmp label ZF je label ~ZF jne label SF js label ~SF jns label ~(SF^OF) & ~ZF jg label ~(SF^OF) jge label SF^OF jl label (SF^OF) ZF jle label ~CF & ~ZF ja label CF jb label 19
20 IA32 Assembler Cheat Sheet Condition Codes CF addl Src,Dest cmpl Src2,Src1 testl Src2,Src1 addl a, b t = a + b cmpl a, b Set CCs based on b a Carry or borrow generated out of MSB (unsigned equivalent of overflow flag) testl a, b Set CCs based on a & b ZF t == 0 a == b a & b == 0 SF t < 0 (b-a) < 0 a & b < 0 OF 0 = b (a > 0 && b > 0 && t < 0) (a < 0 && b < 0 && t > 0) 0 20
21 Stack Layout Revisited 21
22 Stack vs. Heap Stack is the place for function parameters and local variables Recursion possible No need for memory management Heap is the place for global variables and dynamically managed memory Explicit memory management Globally accessible 22
23 IA32 Stack Frame Structure Caller Stack Frame Arguments for callee -Pushed from right-to-left ( instruction Return address (call Caller's Frame Arguments Return Addr 23
24 IA32 Stack Frame Structure Caller Stack Frame Arguments for callee -Pushed from right-to-left ( instruction Return address (call Current Stack Frame Caller's Frame Pointer Frame Arguments Return Addr Old %ebp Old frame pointer Saved register context -Callee safe registers ( spilling ) Local variables Current Stack Frame Saved Registers + Local Variables Parameters for next function call Stack Pointer Arguments 24
25 Parameter passing Parameters and return value in assembly int sub(int arg1, int arg2) { return arg1-arg2; } sub: pushl %ebp movl %esp, %ebp movl 12(%ebp), %edx movl 8(%ebp), %eax subl %edx, %eax leave ret 25
26 Control Structures in Assembly - Revisited 26
27 For loops int forloop(int x) { int a, s = x; (++ a for (a=0; a<=8; s += s; return s; } 27
28 For loops int forloop(int x) { int a, s = x; (++ a for (a=0; a<=8; s += s; return s; } int forloop(int x) { int a = 0, s = x; ( 8 > (a if goto done; do { s += s; a++; } while (a <= 8); done: return s; } 28
29 For loops int forloop(int x) { int a, s = x; (++ a for (a=0; a<=8; s += s; return s; } int forloop(int x) { int a = 0, s = x; ( 8 > (a if goto done; do { s += s; a++; } while (a <= 8); done: return s; } forloop: pushl movl subl movl movl movl.test: cmpl jle jmp.body: movl addl leal incl jmp.done: movl leave ret %ebp %esp, %ebp $8, %esp ( 8(%ebp -,$0 8(%ebp), %eax ( 4(%ebp - %eax, ( 8(%ebp -,$8.body.done -4(%ebp), %eax ( 4(%ebp - %eax, -8(%ebp), %eax ( eax %).test -4(%ebp), %eax 29
30 Switch statements Two implementation possibilities: Jump tables vs. nested if-else Question: Advantages and disadvantages? 30
31 Switch statements Two implementation possibilities: Jump tables vs. nested if-else Question: Advantages and disadvantages? Jump tables: constant time If-else: time complexity depends on nb. of cases GCC: Use jump tables when > 4 cases and reasonable range of values 31
32 Example switch (a) { case 100: a+=1; break; case 102: a+=2; case 103: a+=3; break; case 104: case 106: a+=6; default: a+=7; } Jump table: Fall through! Array with addresses of code segments Index = switch index (here: a) Normalize switch index (here: instead of ) 32
33 Example switch (a) { case 100: a+=1; break; case 102: a+=2; case 103: a+=3; break; case 104: case 106: a+=6; default: a+=7; }.L0: leal -100(%eax), %edx cmpl $6, %edx ja.l8 jmp ( L9(,%edx,4.* normalize and jump to right case jump table.section.rodata.align 4.L9:.long.L3 # a==100.long.l8 # a==101.long.l4 # a==102.long.l5 # a==103.long.l7 # a==104.long.l8 # a==105.text.l3:.l4:.l5:.l7:.l8:.l2:.long incl %eax jmp.l2.l7 # a==106 addl $2, %eax # fall through addl $3, %eax jmp.l2 addl $6, %eax # fall through addl $7, %eax 33
34 setx instructions int lessthan(x, y) { return x < y; } movl 12(%ebp), %eax cmpl ( 8(%ebp %eax, setl %al # %al = x < y movzbl %al, %eax # fill rest with 0 ret Integer registers: %eax %ah %ax %al Other setx instructions: sete (ZF), setne (~ZF), sets (SF), setns (~SF), 34
35 Reading condition codes with C EFLAGS register (32 bits): ??? See Intel Architecture Software Developer's Manual (link on course website) 35
36 Quiz 1. Which of the following C expressions has a result value of 0x01? (a)!0x2a (b)!!0x00 (c)!(~0) (d) 0x0102 & (0xff << 8) (e) 0x0102 && (0xff << 8) 36
37 Quiz 1. Which of the following C expressions has a result value of 0x01? (a)!0x2a (b)!!0x00 (c)!(~0) (d) 0x0102 & (0xff << 8) (e) 0x0102 && (0xff << 8) 37
38 Quiz 2. Assuming: 16-bit two s complement integers, Which has the greatest absolute value? (a) 0xffff (b) 0x00ff (c) 0xc000 (d) 0xe000 38
39 Quiz 2. Assuming: 16-bit two s complement integers, Which has the greatest absolute value? (a) 0xffff (b) 0x00ff (c) 0xc000 (d) 0xe000 39
40 Quiz 3. Tiny floating-point: sign bit, 2 bit exponent, 2 bit fraction Which bit pattern corresponds to +1 10? (a) (b) (c) (d) (e)
41 Quiz 3. Tiny floating-point: sign bit, 2 bit exponent, 2 bit fraction Which bit pattern corresponds to +1 10? (a) (b) (c) (d) (e)
42 Quiz 4. Single-precision floating-point: sign bit, 8 bit exponent, 23 bit fraction Which has the greatest value? (a) 0x (b) 0x (c) 0x (d) 0x (e) 0xc
43 Quiz 4. Single-precision floating-point: sign bit, 8 bit exponent, 23 bit fraction Which has the greatest value? (a) 0x (b) 0x (c) 0x (d) 0x (e) 0xc
44 Quiz 5. In assembly code corresponding to a C function, a reference to an operand at memory location -8(%ebp) most likely corresponds to: (a) a local variable declared within that function (b) a global variable declared within that function (c) an incoming parameter value for that function (d) a dynamically allocated variable from the heap 44
45 Quiz 5. In assembly code corresponding to a C function, a reference to an operand at memory location -8(%ebp) most likely corresponds to: (a) a local variable declared within that function (b) a global variable declared within that function (c) an incoming parameter value for that function (d) a dynamically allocated variable from the heap 45
46 That's all for today! Questions? 46
Machine-Level Programming II: Control and Arithmetic
Machine-Level Programming II: Control and Arithmetic CSCI 2400: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides 1 Today Complete addressing mode, address
More informationThe Hardware/Software Interface CSE351 Spring 2013
The Hardware/Software Interface CSE351 Spring 2013 x86 Programming II 2 Today s Topics: control flow Condition codes Conditional and unconditional branches Loops 3 Conditionals and Control Flow A conditional
More informationMachine 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 informationMachine-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 informationSungkyunkwan University
- 2 - Complete addressing mode, address computation (leal) Arithmetic operations Control: Condition codes Conditional branches While loops - 3 - Most General Form D(Rb,Ri,S) Mem[ Reg[ R b ] + S Reg[ R
More informationMachine-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 informationProcess Layout and Function Calls
Process Layout and Function Calls CS 6 Spring 07 / 8 Process Layout in Memory Stack grows towards decreasing addresses. is initialized at run-time. Heap grow towards increasing addresses. is initialized
More informationChapter 3 Machine-Level Programming II Control Flow
Chapter 3 Machine-Level Programming II Control Flow Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements Condition Codes Single Bit Registers CF Carry Flag
More informationMachine-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 informationCredits to Randy Bryant & Dave O Hallaron
Mellon Machine Level Programming II: Arithmetic & Control Lecture 4, March 10, 2011 Alexandre David Credits to Randy Bryant & Dave O Hallaron from Carnegie Mellon 1 Today Complete addressing mode, address
More informationCS61 Section Solutions 3
CS61 Section Solutions 3 (Week of 10/1-10/5) 1. Assembly Operand Specifiers 2. Condition Codes 3. Jumps 4. Control Flow Loops 5. Procedure Calls 1. Assembly Operand Specifiers Q1 Operand Value %eax 0x104
More informationCS241 Computer Organization Spring Addresses & Pointers
CS241 Computer Organization Spring 2015 Addresses & Pointers 2-24 2015 Outline! Addresses & Pointers! leal - load effective address! Condition Codes & Jumps! conditional statements: if-then-else! conditional
More informationASSEMBLY II: CONTROL FLOW. Jo, Heeseung
ASSEMBLY II: CONTROL FLOW Jo, Heeseung IA-32 PROCESSOR STATE Temporary data Location of runtime stack %eax %edx %ecx %ebx %esi %edi %esp %ebp General purpose registers Current stack top Current stack frame
More informationAssembly 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 IA-32 Processor State %eax %edx Temporary data Location of runtime stack
More informationYou may work with a partner on this quiz; both of you must submit your answers.
Instructions: Choose the best answer for each of the following questions. It is possible that several answers are partially correct, but one answer is best. It is also possible that several answers are
More informationCredits and Disclaimers
Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 2 nd Edition by Bryant and O'Hallaron
More informationCISC 360. Machine-Level Programming II: Control Flow Sep 23, 2008
CISC 360 Machine-Level Programming II: Control Flow Sep 23, 2008 class06 Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements Condition Codes Single Bit
More informationCS 33. Machine Programming (2) CS33 Intro to Computer Systems XII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Machine Programming (2) CS33 Intro to Computer Systems XII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Processor State (x86-64, Partial) %rax %eax %r8 %r8d %rbx %ebx %r9 %r9d %rcx %ecx
More informationPage # CISC 360. Machine-Level Programming II: Control Flow Sep 23, Condition Codes. Setting Condition Codes (cont.)
CISC 360 Machine-Level Programming II: Control Flow Sep 23, 2008 class06 Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements Condition Codes Single Bit
More informationCS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College February 9, 2016 Reading Quiz Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between
More informationControl 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 informationProcess Layout, Function Calls, and the Heap
Process Layout, Function Calls, and the Heap CS 6 Spring 20 Prof. Vern Paxson TAs: Devdatta Akhawe, Mobin Javed, Matthias Vallentin January 9, 20 / 5 2 / 5 Outline Process Layout Function Calls The Heap
More informationCondition Codes The course that gives CMU its Zip! Machine-Level Programming II Control Flow Sept. 13, 2001 Topics
15-213 The course that gives CMU its Zip! Machine-Level Programming II Control Flow Sept. 13, 2001 Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements
More informationCredits and Disclaimers
Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 2 nd Edition by Bryant and O'Hallaron
More informationCS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College September 25, 2018 Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between programmer
More informationMachine Programming 2: Control flow
Machine Programming 2: Control flow CS61, Lecture 4 Prof. Stephen Chong September 13, 2011 Announcements Assignment 1 due today, 11:59pm Hand in at front during break or email it to cs61- staff@seas.harvard.edu
More informationCS 3843 Final Exam Fall 2012
CS 3843 Final Exam Fall 2012 Name (Last), (First) ID Please indicate your session: Morning Afternoon You may use a calculator and two sheets of notes on this exam, but no other materials and no computer.
More informationCondition Codes. Lecture 4B Machine-Level Programming II: Control Flow. Setting Condition Codes (cont.) Setting Condition Codes (cont.
Lecture 4B Machine-Level Programming II: Control Flow Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements Condition Codes Single Bit Registers CF Carry
More informationCS 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 informationMachine- Level Programming II: Arithme6c & Control
Machine- Level Programming II: Arithme6c & Control 15-213: Introduc0on to Computer Systems 5 th Lecture, Sep. 7, 2010 Instructors: Randy Bryant and Dave O Hallaron Modified by Karen L. Karavanic 2015 1
More informationHomework 0: Given: k-bit exponent, n-bit fraction Find: Exponent E, Significand M, Fraction f, Value V, Bit representation
Homework 0: 2.84 Given: k-bit exponent, n-bit fraction Find: Exponent E, Significand M, Fraction f, Value V, Bit representation Homework 0: 2.84 Given: k-bit exponent, n-bit fraction 7.0: 0111 = 1.11 2
More informationCF Carry Flag SF Sign Flag ZF Zero Flag OF Overflow Flag. ! CF set if carry out from most significant bit. "Used to detect unsigned overflow
Lecture 4B Machine-Level Programming II: Control Flow Topics! Condition Codes " Setting " Testing! Control Flow " If-then-else " Varieties of Loops " Switch Statements Condition Codes Single Bit Registers
More informationadministrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions?
administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions? exam on Wednesday today s material not on the exam 1 Assembly Assembly is programming
More informationMachine- Level Programming II: Arithme c & Control
Machine- Level Programming II: Arithme c & Control 15-213 / 18-213: Introduc on to Computer Systems 6 th Lecture, Sep. 12, 2013 Instructors: Randy Bryant, David O Hallaron, and Greg Kesden 1 Today Complete
More informationGiving credit where credit is due
CSCE 230J Computer Organization Machine-Level Programming II: Control Flow Dr. Steve Goddard goddard@cse.unl.edu Giving credit where credit is due Most of slides for this lecture are based on slides created
More informationIntroduction to Computer Systems. Exam 1. February 22, Model Solution fp
15-213 Introduction to Computer Systems Exam 1 February 22, 2005 Name: Andrew User ID: Recitation Section: Model Solution fp This is an open-book exam. Notes are permitted, but not computers. Write your
More informationMachine- Level Programming II: Arithme6c & Control
Machine- Level Programming II: Arithme6c & Control Computer Architecture Instructor: Norbert Lu*enberger based on the book by Randy Bryant and Dave O Hallaron 1 Today Complete addressing mode, address
More informationFunction Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site)
Function Calls COS 217 Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site) 1 Goals of Today s Lecture Finishing introduction to assembly language o EFLAGS register
More informationMachine-Level Programming II: Control
Machine-Level Programming II: Control CSE 238/2038/2138: Systems Programming Instructor: Fatma CORUT ERGİN Slides adapted from Bryant & O Hallaron s slides 1 Today Control: Condition codes Conditional
More informationMachine-Level Programming II: Control
Mellon Machine-Level Programming II: Control CS140 Computer Organization and Assembly Slides Courtesy of: Randal E. Bryant and David R. O Hallaron 1 First https://www.youtube.com/watch?v=ivuu8jobb1q 2
More informationSecond Part of the Course
CSC 2400: Computer Systems Towards the Hardware 1 Second Part of the Course Toward the hardware High-level language (C) assembly language machine language (IA-32) 2 High-Level Language g Make programming
More informationMachine- level Programming II: Control Flow
Machine- level Programming II: Control Flow Topics Condi;on Codes Se=ng Tes;ng Control Flow If- then- else Varie;es of Loops Switch Statements 1! Condi;on Codes Single Bit Registers CF Carry Flag SF Sign
More informationAssembly Language: IA-32 Instructions
Assembly Language: IA-32 Instructions 1 Goals of this Lecture Help you learn how to: Manipulate data of various sizes Leverage more sophisticated addressing modes Use condition codes and jumps to change
More informationCISC 360. Machine-Level Programming II: Control Flow Sep 17, class06
CISC 360 Machine-Level Programming II: Control Flow Sep 17, 2009 class06 Condition Codes 2 Setting Condition Codes (cont.) 3 Setting Condition Codes (cont.) 4 Reading Condition Codes SetX Condition Description
More informationMachine 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 informationQuestions about last homework? (Would more feedback be useful?) New reading assignment up: due next Monday
Questions about last homework? (Would more feedback be useful?) New reading assignment up: due next Monday addl: bitwise for signed (& unsigned) 4 bits: 1000 = -8, 0111 = 7-8 + -8 = -16 = 0 1000 + 1000
More informationCPSC W Term 2 Problem Set #3 - Solution
1. (a) int gcd(int a, int b) { if (a == b) urn a; else if (a > b) urn gcd(a - b, b); else urn gcd(a, b - a); CPSC 313 06W Term 2 Problem Set #3 - Solution.file "gcdrec.c".globl gcd.type gcd, @function
More informationThis is a medical robot, guided by a skilled surgeon and designed to get to places doctors are unable to reach without opening a pacent up.
BBC Headline: Slashdot Headline: Robots join the fight against cancer Robot Snakes To Fight Cancer Via Natural Orifice Surgery This is a medical robot, guided by a skilled surgeon and designed to get to
More informationCS 33: Week 3 Discussion. x86 Assembly (v1.0) Section 1G
CS 33: Week 3 Discussion x86 Assembly (v1.0) Section 1G Announcements - HW2 due Sunday - MT1 this Thursday! - Lab2 out Info Name: Eric Kim (Section 1G, 2-4 PM, BH 5419) Office Hours (Boelter 2432) - Wed
More informationCSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs
CSC 2400: Computer Systems Towards the Hardware: Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32)
More informationCredits and Disclaimers
Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 3 nd Edition by Bryant and O'Hallaron
More informationCS241 Computer Organization Spring 2015 IA
CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,
More informationIntroduction to Computer Systems. Exam 1. February 22, This is an open-book exam. Notes are permitted, but not computers.
15-213 Introduction to Computer Systems Exam 1 February 22, 2005 Name: Andrew User ID: Recitation Section: This is an open-book exam. Notes are permitted, but not computers. Write your answer legibly in
More informationPage 1. Condition Codes CISC 360. Machine-Level Programming II: Control Flow Sep 17, Setting Condition Codes (cont.)
CISC 360 Condition Codes Machine-Level Programming II: Control Flow Sep 17, 2009 class06 2 Setting Condition Codes (cont.) Setting Condition Codes (cont.) 3 4 Page 1 Reading Condition Codes Reading Condition
More informationCSC 8400: Computer Systems. Machine-Level Representation of Programs
CSC 8400: Computer Systems Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32) 1 Compilation Stages
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View! Processor
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View Processor
More information4) C = 96 * B 5) 1 and 3 only 6) 2 and 4 only
Instructions: The following questions use the AT&T (GNU) syntax for x86-32 assembly code, as in the course notes. Submit your answers to these questions to the Curator as OQ05 by the posted due date and
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant adapted by Jason Fritts http://csapp.cs.cmu.edu CS:APP2e Hardware Architecture - using Y86 ISA For learning aspects
More informationx86-64 Programming II
x86-64 Programming II CSE 351 Winter 2018 Instructor: Mark Wyse Teaching Assistants: Kevin Bi Parker DeWilde Emily Furst Sarah House Waylon Huang Vinny Palaniappan http://xkcd.com/409/ Administrative Homework
More informationAssembly 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 informationInstruction Set Architecture
CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter
More informationCISC 360 Instruction Set Architecture
CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter
More informationCS367. Program Control
CS367 Program Control outline program control condition codes branching looping conditional moves switches (special case of branching) Condition Codes Processor State (x86-64, Partial) Info about currently
More informationCPS104 Recitation: Assembly Programming
CPS104 Recitation: Assembly Programming Alexandru Duțu 1 Facts OS kernel and embedded software engineers use assembly for some parts of their code some OSes had their entire GUIs written in assembly in
More informationControl. Young W. Lim Mon. Young W. Lim Control Mon 1 / 16
Control Young W. Lim 2016-11-21 Mon Young W. Lim Control 2016-11-21 Mon 1 / 16 Outline 1 Introduction References Condition Code Accessing the Conditon Codes Jump Instructions Translating Conditional Branches
More informationSungkyunkwan 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 informationY86 Processor State. Instruction Example. Encoding Registers. Lecture 7A. Computer Architecture I Instruction Set Architecture Assembly Language View
Computer Architecture I Instruction Set Architecture Assembly Language View Processor state Registers, memory, Instructions addl, movl, andl, How instructions are encoded as bytes Layer of Abstraction
More informationAssembly II: Control Flow
Assembly II: Control Flow Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE2030: Introduction to Computer Systems, Spring 2018, Jinkyu Jeong (jinkyu@skku.edu)
More informationMachine-Level Programming (2)
Machine-Level Programming (2) Yanqiao ZHU Introduction to Computer Systems Project Future (Fall 2017) Google Camp, Tongji University Outline Control Condition Codes Conditional Branches and Conditional
More informationAssembly Language: Function Calls
Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and returning Passing parameters Storing local variables Handling registers without interference
More informationAssembly Programming III
Assembly Programming III CSE 410 Winter 2017 Instructor: Justin Hsia Teaching Assistants: Kathryn Chan, Kevin Bi, Ryan Wong, Waylon Huang, Xinyu Sui Facebook Stories puts a Snapchat clone above the News
More informationCSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature
CSE2421 FINAL EXAM SPRING 2013 Name KEY Instructions: This is a closed-book, closed-notes, closed-neighbor exam. Only a writing utensil is needed for this exam. No calculators allowed. If you need to go
More informationX86 Addressing Modes Chapter 3" Review: Instructions to Recognize"
X86 Addressing Modes Chapter 3" Review: Instructions to Recognize" 1 Arithmetic Instructions (1)! Two Operand Instructions" ADD Dest, Src Dest = Dest + Src SUB Dest, Src Dest = Dest - Src MUL Dest, Src
More informationCS 261 Fall Mike Lam, Professor. x86-64 Control Flow
CS 261 Fall 2018 Mike Lam, Professor x86-64 Control Flow Topics Condition codes Jumps Conditional moves Jump tables Motivation We cannot translate the following C function to assembly, using only data
More informationDo not turn the page until 5:10.
University of Washington Computer Science & Engineering Autumn 2018 Instructor: Justin Hsia 2018-10-29 Last Name: First Name: Student ID Number: Name of person to your Left Right All work is my own. I
More informationAssembly Language: Function Calls" Goals of this Lecture"
Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and returning" Passing parameters" Storing local variables" Handling registers without interference"
More informationASSEMBLY 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 informationAssembly 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 informationAssembly Language: Function Calls" Goals of this Lecture"
Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and urning" Passing parameters" Storing local variables" Handling registers without interference"
More information2/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 informationProcedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27
Procedure Calls Young W. Lim 2016-11-05 Sat Young W. Lim Procedure Calls 2016-11-05 Sat 1 / 27 Outline 1 Introduction References Stack Background Transferring Control Register Usage Conventions Procedure
More informationChapter 4 Processor Architecture: Y86 (Sections 4.1 & 4.3) with material from Dr. Bin Ren, College of William & Mary
Chapter 4 Processor Architecture: Y86 (Sections 4.1 & 4.3) with material from Dr. Bin Ren, College of William & Mary 1 Outline Introduction to assembly programing Introduction to Y86 Y86 instructions,
More informationAssembly Language: Function Calls. Goals of this Lecture. Function Call Problems
Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and urning Passing parameters Storing local variables Handling registers without interference Returning
More informationQuestion 4.2 2: (Solution, p 5) Suppose that the HYMN CPU begins with the following in memory. addr data (translation) LOAD 11110
Questions 1 Question 4.1 1: (Solution, p 5) Define the fetch-execute cycle as it relates to a computer processing a program. Your definition should describe the primary purpose of each phase. Question
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: February 26, 2018 at 12:02 CS429 Slideset 8: 1 Controlling Program
More informationx86 Programming II CSE 351 Winter
x86 Programming II CSE 351 Winter 2017 http://xkcd.com/1652/ Administrivia 2 Address Computation Instruction v leaq src, dst lea stands for load effective address src is address expression (any of the
More informationAssembly Language: Part 2
Assembly Language: Part 2 1 Goals of this Lecture Help you learn: Intermediate aspects of IA-32 assembly language Control flow with signed integers Control flow with unsigned integers Arrays Structures
More informationInstructor: Alvin R. Lebeck
X86 Assembly Programming with GNU assembler Lecture 7 Instructor: Alvin R. Lebeck Some Slides based on those from Randy Bryant and Dave O Hallaron Admin Reading: Chapter 3 Note about pointers: You must
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Warren Hunt, Jr. and Bill Young Department of Computer Sciences University of Texas at Austin Last updated: October 1, 2014 at 12:03 CS429 Slideset 6: 1 Topics
More informationCS213. Machine-Level Programming III: Procedures
CS213 Machine-Level Programming III: Procedures Topics IA32 stack discipline Register saving conventions Creating pointers to local variables IA32 Region of memory managed with stack discipline Grows toward
More informationAssembly III: Procedures. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Assembly III: Procedures Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu IA-32 (1) Characteristics Region of memory managed with stack discipline
More informationProcedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29
Procedure Calls Young W. Lim 2017-08-21 Mon Young W. Lim Procedure Calls 2017-08-21 Mon 1 / 29 Outline 1 Introduction Based on Stack Background Transferring Control Register Usage Conventions Procedure
More informationCarnegie 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 informationMachine Language CS 3330 Samira Khan
Machine Language CS 3330 Samira Khan University of Virginia Feb 2, 2017 AGENDA Logistics Review of Abstractions Machine Language 2 Logistics Feedback Not clear Hard to hear Use microphone Good feedback
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2016 Lecture 12
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2016 Lecture 12 CS24 MIDTERM Midterm format: 6 hour overall time limit, multiple sittings (If you are focused on midterm, clock should be running.) Open book
More informationMachine-level Programming (3)
Machine-level Programming (3) Procedures A: call A call A return Two issues How to return to the correct position? How to pass arguments and return values between callee to caller? 2 Procedure Control
More informationCSE351 Autumn 2014 Midterm Exam (29 October 2014)
CSE351 Autumn 2014 Midterm Exam (29 October 2014) (Version A) Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate
More informationThe Hardware/Software Interface CSE351 Spring 2015
The Hardware/Software Interface CSE351 Spring 2015 Lecture 8 Instructor: Katelin Bailey Teaching Assistants: Kaleo Brandt, Dylan Johnson, Luke Nelson, Alfian Rizqi, Kritin Vij, David Wong, and Shan Yang
More informationCS , Fall 2004 Exam 1
Andrew login ID: Full Name: CS 15-213, Fall 2004 Exam 1 Tuesday October 12, 2004 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front.
More information