CSE 351 Midterm Review. Your midterm is next Wednesday Study past midterms (link on the website) Point of emphasis: Registers are not memory Registers.

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
COMP3221 lec06-numbers-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 6: Number Systems - II
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Standard positional representation of numbers:
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
1  2004 Morgan Kaufmann Publishers Chapter Three.

Floating Point Numbers
Quiz 1.1 Convert the following unsigned binary numbers to their decimal equivalent: Number2 Number
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Computer Systems 1 Fundamentals of Computing Negative Binary.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
The Binary Number System
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Fixed-Point Arithmetics: Part II
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
Computing Systems Basic arithmetic for computers.
Computer Architecture
COMPSCI 210 Semester Tutorial 1
Computer Systems Organization CS 1428 Foundations of Computer Science.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
9.4 FLOATING-POINT REPRESENTATION
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Positional Number Systems
ECE 456 Computer Architecture
Floating Point Arithmetic
INEL 4215: Computer Architecture and Organization Number Systems Signed numbers.
Integer and Fixed Point P & H: Chapter 3
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
Numbers in Computers.
Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
Software Design and Development Storing Data Computing Science.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Floating Point Numbers
Cosc 2150: Computer Organization
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Data Representation Binary Numbers Binary Addition
Section 2: Integer & Floating Point Numbers
What to bring: iCard, pens/pencils (They provide the scratch paper)
Data Representation Data Types Complements Fixed Point Representation
How are negative and rational numbers represented on the computer?
Computer Organization COMP 210
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
Chapter3 Fixed Point Representation
ECE 120 Midterm 1 HKN Review Session.
Presentation transcript:

CSE 351 Midterm Review

Your midterm is next Wednesday Study past midterms (link on the website) Point of emphasis: Registers are not memory Registers and caches are on the same piece of silicon as the processor This is done to make things fast (farther away => takes more time) Memory is an external storage bank of contiguous space Registers are individual storage elements that are not “addressable” (i.e. there is no “offset” between %rax and %rdx)

Integer Representation Convert -39 and 99 to binary and add the two’s complement 8-bit integers, then convert the result to hex -39 => => => => 0x3C

Integer Representation What is the difference between the carry flag (CF) and the overflow flag (OF)? They differ in how they are triggered CF is set during unsigned addition when a carry occurs at the most-significant bit OF is set during signed arithmetic and it indicates that the addition yielded a number that was too large (either positive or negative direction)

Floating-Point Representation Suppose we have a 7-bit computer that uses IEEE floating-point arithmetic where a floating-point number has 1 sign bit, 3 exponent bits, and 3 fraction bits. NumberBinaryDecimal Smallest positive normalized number Largest positive number < INF

Pointers int a = 5, b = 15; int *p1, *p2; p1 = &a; // p1 -> a p2 = &b; // p2 -> b *p1 = 10; // a = 10 *p2 = *p1; // b = 10 p1 = p2; // p1 -> b *p1 = 20; // b = 20 What are the values of a, b, p1, p2?

IA-32 vs. x86-64 Look at the following function: int foo(int x, int y) { int c = x << (y + 3); if (x != 0) { return c; } else { return 1; } What does this function look like in x86 assembly? 32-bit and 64-bit.

IA-32 version push %ebp // ?? mov%esp, %ebp // ?? mov $0xc(%ebp), %ecx // ?? add $0x3, %ecx mov 0x8(%ebp), %eax // ?? shl %ecx, %eax cmp $0x8(%ebp), $0 jne $0x mov $0x1, %eax leave // ?? ret This is what the code looks like in IA-32 assembly.

IA-32 version push %ebp // Save the base pointer mov%esp, %ebp // Move the base pointer up to the top of the stack mov $0xc(%ebp), %ecx // Move y into a register add $0x3, %ecx mov 0x8(%ebp), %eax // Move x into a register shl %ecx, %eax cmp $0x8(%ebp), $0 jne $0x mov $0x1, %eax leave // Restore the old base pointer ret This is what the code looks like in IA-32 assembly.

x86-64 version push %ebp mov %esp, %ebp mov $0xc(%ebp), %ecx add $0x3, %rsi mov 0x8(%ebp), %eax mov %rdi, %rax shl %rsi, %rax test %rdi,%rdi jne $0x mov $0x1, %rax leave ret This is what the code looks like in x86-64 assembly. Differences?

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? mov %ebx, %ecx // ?? add %eax, %ebx // ?? je.L1 // ?? sub %eax, %ecx // ?? je.L1 // ?? xor %eax, %eax // ?? jmp.L2 // ?? L1: mov $1, %eax // ?? L2 :

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? mov %ebx, %ecx // %ecx = y add %eax, %ebx // ?? je.L1 // ?? sub %eax, %ecx // ?? je.L1 // ?? xor %eax, %eax // ?? jmp.L2 // ?? L1: mov $1, %eax // ?? L2 :

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? mov %ebx, %ecx // %ecx = y add %eax, %ebx // %ebx = x + y je.L1 // ?? sub %eax, %ecx // ?? je.L1 // ?? xor %eax, %eax // ?? jmp.L2 // ?? L1: mov $1, %eax // ?? L2 :

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? mov %ebx, %ecx // %ecx = y add %eax, %ebx // %ebx = x + y je.L1 // jmp to L1 if x + y == 0 sub %eax, %ecx // ?? je.L1 // ?? xor %eax, %eax // ?? jmp.L2 // ?? L1: mov $1, %eax // ?? L2 :

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? mov %ebx, %ecx // %ecx = y add %eax, %ebx // %ebx = x + y je.L1 // jmp to L1 if x + y == 0 sub %eax, %ecx // %ecx = x - y je.L1 // ?? xor %eax, %eax // ?? jmp.L2 // ?? L1: mov $1, %eax // ?? L2 :

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? mov %ebx, %ecx // %ecx = y add %eax, %ebx // %ebx = x + y je.L1 // jmp to L1 if x + y == 0 sub %eax, %ecx // %ecx = x - y je.L1 // jmp to L1 if x – y == 0 xor %eax, %eax // ?? jmp.L2 // ?? L1: mov $1, %eax // ?? L2 :

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? mov %ebx, %ecx // %ecx = y add %eax, %ebx // %ebx = x + y je.L1 // jmp to L1 if x + y == 0 sub %eax, %ecx // %ecx = x - y je.L1 // jmp to L1 if x – y == 0 xor %eax, %eax // %eax = 0 jmp.L2 // ?? L1: mov $1, %eax // ?? L2 :

Interpreting Assembly Let %eax store x and %ebx store y. What does this compute? |x| == |y| mov %ebx, %ecx // %ecx = y add %eax, %ebx // %ebx = x + y je.L1 // jmp to L1 if x + y == 0 sub %eax, %ecx // %ecx = x - y je.L1 // jmp to L1 if x – y == 0 xor %eax, %eax // %eax = 0 jmp.L2 // return 0 L1: mov $1, %eax // return 1 L2 :