Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?
|
|
- Mark Pearson
- 6 years ago
- Views:
Transcription
1 Where Have We Been? Class Introduction Great Realities of Computing Int s are not Integers, Float s are not Reals You must know assembly Memory Matters Performance! Asymptotic Complexity It s more than executing programs Computer Organization Where Are We Going? Representation of Information Chapter 2 Representing and Manipulating Information Topics: Bits and Bytes Representing information as bits Binary/Hexadecimal Byte representations»numbers»characters and strings»instructions Bit-level manipulations Boolean algebra Expressing in C wc2.ppt Why Don t Computers Use Base? Base Number Representation That s why fingers are known as digits Natural representation for financial transactions Even carries through in scientific notation.52 X 4 Implementing Electronically 4 Page
2 Binary Representations Electronic Implementation Easy to store with bi-stable elements Reliably transmitted on noisy and inaccurate wires 3.3V 2.8V.5V.V Straightforward implementation of logical/arithmetic functions Base 2 Number Representation Represent 5 as 2 Represent 7 as 2 Represent.5 as. 2 5 Converting between Decimal and Binary Binary to Decimal 2 *2 3 + * * 2 + * Converting between Decimal and Binary Binary to Decimal * Page 2
3 Converting between Decimal and Binary Decimal to Binary (Dividing the number repeatedly by 2 until the number becomes ) Divide by Number Remainder Example: Binary equivalent 24 is Converting between Decimal and Binary Fraction to Binary (multiply the number by 2 and register the integer portion the s place) multiply by 2 Number Integer part Example:.325 Binary equivalent is. 9 Practice Fill in the missing entries Decimal Binary Page 3
4 Byte-Oriented Memory Organization Programs Refer to Virtual Addresses Conceptually very large array of bytes Actually implemented with hierarchy of different memory types A pointer is the virtual address of the first byte of some block of storage Compiler + Run-Time System Control Allocation Where different program objects should be stored Multiple mechanisms: static, stack, and heap All allocation within single virtual address space 3 Encoding Byte Values HEX DEC Binary Byte 8 bits Binary 2 to Decimal: to Hexadecimal 6 to FF 6 Base 6 number representation Use characters to 9 and A to F Write FAD37B 6 in C as xfad37b or xfad37b A B C D 3 E 4 F 5 4 Converting Binary to Hex Given a binary number: 2 Break it up into 4-bit nibbles 2 Covert each nibble to Hex D 6 (3 ) 3 6 (3 ) 7 6 (7 ) B 6 ( ) 2 D37B 6 5 Page 4
5 Hex to Decimal Converting Hex to Decimal A5 BA5 * * * Try example program d2h on section 2. 6 Converting Decimal to Hex Decimal to Hex (Dividing the number repeatedly by 6 until the number becomes ) Divide by Number Remainder Example: Hex equivalent 3 3 is (B) 4 Example: 75 is 4B 7 Encoding Byte Values Practice: Fill in the missing entries Hex Decimal Binary 65 BC Page 5
6 Machine Words Machine Has Word Size Nominal size of integer-valued data and pointer data Most current machines are 32 bits (4 bytes) Limits addresses to 4GB Becoming too small for memory-intensive (e.g. scientific or large data base) applications High-end systems are 64 bits (8 bytes) Potentially address.8 X 9 bytes Machines support multiple data formats Fractions or multiples of word size»load byte, load half word, load word, etc Always integral number of bytes 2 Byte-Oriented Memory Organization Programs Refer to Virtual Addresses Conceptually very large array of bytes Actually implemented with hierarchy of different memory types A pointer is the virtual address of the first byte of some block of storage Compiler + Run-Time System Control Allocation Where different program objects should be stored Multiple mechanisms: static, stack, and heap All allocation within single virtual address space 22 Machine Words Machine Has Word Size Nominal size of integer-valued data and pointer data Most current machines are 32 bits (4 bytes) Limits addresses to 4GB Becoming too small for memory-intensive (e.g. scientific or large data base) applications High-end systems are 64 bits (8 bytes) Potentially address.8 X 9 bytes Machines support multiple data formats Fractions or multiples of word size»load byte, load half word, load word, etc Always integral number of bytes 23 Page 6
7 Data Representations Sizes of C Objects (in Bytes) C Data Type Compaq Alpha Typical 32-bit Intel IA32 int long int char short float double long double 8 8 /2 char * other pointer Many programmers assume a program variable declared as int can store a pointer. This will create porting problems. 24 Word-Oriented Memory Organization Addresses Specify Byte Locations Address of first byte in word Addresses of successive words differ by 4 (32-bit) or 8 (64-bit) A pointer is (or holds) the address of a chunk of data bit Words Addr Addr 4 Addr 8 Addr 2 64-bit Words Addr Addr 8 Bytes Addr Byte Ordering Issue How should bytes within a multi-byte word be ordered in memory? Which byte is considered as the first byte? Conventions Alphas, PC s are little Endian machines Least significant byte is the first byte Sun s, Mac s are big Endian machines Most significant byte is the first byte Example Variable x has 4-byte representation x Address given by &x is x Big Endian Little Endian x x x2 x x x x2 x Page 7
8 Byte Ordering For most applications, the byte orderings are invisible. A multi-byte object is normally referenced as a single object. Byte ordering becomes an issue when 28 Examining Data Representations Code to Print Byte Representation of Data Casting pointer to unsigned char * creates byte array typedef unsigned char *pointer; void show_bytes(pointer start, int len) { int i; for (i ; i < len; i++) printf("x%p\tx%.2x\n", start+i, start[i]); printf("\n"); } Printf directives: %p:print pointer %x:print Hex 29 show_bytes Execution Example int a 523; printf("int a 523;\n"); show_bytes((pointer) &a, sizeof(int)); Result: int a 523; xffffcb8 x6d xffffcb9 x3b xffffcba x xffffcbb x Is this machine Little Endian or Big Endian? 3 Page 8
9 int A 523; int B -523; long int C 523; Alpha A 6D 3B Alpha B 93 C4 FF FF Representing Integers Sun A 3B 6D Sun B FF FF C4 93 Decimal: 523 Binary: Hex: 3 B 6 D Alpha C 6D 3B Sun C 3B 6D Two s complement representation (Covered next lecture) 3 int B -523; int *P &B; Alpha Address Representing Pointers Hex: F F F F F C A Binary: Alpha P A FC FF FF Sun P EF FF FB 2C Sun Address Hex: E F F F F B 2 C Binary: Different compilers & machines assign different locations to objects 33 Representing Floats Float F 523.; Alpha F B4 6D 46 Sun F 46 6D B4 IEEE Single Precision Floating Point Representation Hex: D B 4 Binary: 523: Not same as integer representation, but consistent across machines 34 Page 9
10 Representing Strings Strings in C char S[6] "523"; Represented by array of characters Each character encoded in ASCII format Alpha S Sun S Standard 7-bit encoding of character set 3 3 Other encodings exist, but uncommon Character has code x Digit i has code x3+i 3 3 String should be null-terminated Final character Compatibility Byte ordering not an issue Data are single byte quantities Text files generally platform independent Except for different conventions of line termination character! 35 Review questions What is the meaning for the following binary string on the latest PC (Intel x86)? (Hex: : 3 32) )Character string 2) A short integer: * * * 6 + 3) 37 Machine-Level Code Representation Encode Program as Sequence of Instructions Each simple operation Arithmetic operation Read or write memory Conditional branch Instructions encoded as bytes Alpha s, Sun s, Mac s use 4 byte instructions» Most Reduced Instruction Set Computer (RISC) PC s use variable length instructions» Complex Instruction Set Computer (CISC) Cray machine uses variable length instructions! Different instruction types and encodings for different machines Most code not binary compatible Programs are Byte Sequences Too! 38 Page
11 Representing Instructions int sum(int x, int y) { return x+y; } For this example, Alpha & Sun use two 4-byte instructions Use differing numbers of instructions in other cases PC uses 7 instructions with lengths, 2, and 3 bytes Same for NT and for Linux NT / Linux not binary compatible Alpha sum FA 6B Sun sum 8 C3 E PC sum E5 8B 45 C EC 5D C3 Different machines use totally different instructions and encodings 39 Boolean Algebra Developed by George Boole in 9th Century Algebraic representation of logic Encode True as and False as And A&B when both A and B & Not ~A when A ~ Or A B when either A or B Exclusive-Or (Xor) A^B when either A or B, but not both ^ 4 Relations Between Operations DeMorgan s Laws Express & in terms of, and vice-versa A & B ~(~A ~B)» A and B are true if and only if neither A nor B is false A B ~(~A & ~B)» A or B are true if and only if A and B are not both false Exclusive-Or using Inclusive Or A ^ B (~A & B) (A & ~B)» Exactly one of A and B is true A ^ B (A B) & ~(A & B)» Either A is true, or B is true, but not both 4 Page
12 General Boolean Algebras Operate on Bit Vectors Operations applied bitwise & ^ ~ Representation of Sets Width w bit vector represents subsets of {,, w } a j if j A {, 3, 5, 6 } {, 2, 4, 6 } & Intersection {, 6 } Union {, 2, 3, 4, 5, 6 } ^ Symmetric difference { 2, 3, 4, 5 } ~ Complement {, 3, 5, 7 } 42 Bit-Level Operations in C Operations &,, ~, ^ Available in C Apply to any integral data type long, int, short, char View arguments as bit vectors Arguments applied bit-wise Examples (Char data type) ~x4 --> xbe ~ 2 2 ~x --> xff ~ 2 2 x69 & x55 --> x4 2 & 2 --> 2 x69 x55 --> x7d > 2 43 Practice X x278 (2 bytes) Example X & xff Example 2 X & ~xff & & 45 Page 2
13 Practice X x ) Y x77 A) Y X ^ xff 2) Y x B) Y X ~xff 3) Y x3355 C) Y X & xff 4) Y xffffff77 D) Y X & ~xff 47 Contrast: Logic Operations in C Contrast to Logical Operators &&,,! View as False Anything nonzero as True Always return or Examples (char data type)!x4 --> x!x --> x!!x4 --> x x69 && x55 --> x x69 x55 --> x 48 Example Note that A&&B is not the same as A&B Assuming A 2 and B A & B & (FALSE) A && B TRUE & TRUE (TRUE) 49 Page 3
14 Shift Operations Left Shift: x << y Shift bit-vector x left y positions Throw away extra bits on left Fill with s on right Right Shift: x >> y Shift bit-vector x right y positions Throw away extra bits on right Logical shift Fill with s on left Arithmetic shift Replicate most significant bit on Useful with two s complement integer representation Argument x << 3 Log. >> 2 Arith. >> 2 Argument x << 3 Log. >> 2 Arith. >> 2 5 More on XOR Bitwise XOR is form of addition With extra property that every value is its own additive inverse A ^ A void funny(int *x, int *y) { *x *x ^ *y; /* # */ *y *x ^ *y; /* #2 */ *x *x ^ *y; /* #3 */ } Step *x *y Begin A B A^B B 2 A^B (A^B)^B A^(B^B) A^ A 3 (A^B)^A (B^A)^A A B^(A^A) B^ B End B A 5 Page 4
Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions
Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra Expressing
More informationBits and Bytes January 13, 2005
15-213 The Class That Gives CMU Its Zip! Topics Bits and Bytes January 13, 25 Why bits? Representing information as bits Binary / Hexadecimal Byte representations» Numbers» Characters and strings» Instructions
More informationWhy Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation
Lecture 2 Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra
More informationWhy Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation
Lecture 2 Bits and Bytes Topics! Why bits?! Representing information as bits " Binary/Hexadecimal " Byte representations» numbers» characters and strings» Instructions! Bit-level manipulations " Boolean
More informationICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2
ICS 2008 Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2 Data Representations Sizes of C Objects (in Bytes) C Data Type Compaq Alpha Typical 32-bit Intel IA32 int 4 4 4 long int 8 4 4
More informationLecture 5-6: Bits, Bytes, and Integers
CSCI-UA.0201-003 Computer Systems Organization Lecture 5-6: Bits, Bytes, and Integers Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Slides adapted from: Jinyang Li Bryant and O Hallaron
More informationHardware: Logical View
Hardware: Logical View CPU Memory Bus Disks Net USB Etc. 1 Hardware: Physical View USB I/O controller Storage connections CPU Memory 2 Hardware: 351 View (version 0) instructions? Memory CPU data CPU executes
More informationBits, Bytes, and Integers
Bits, Bytes, and Integers with contributions from Dr. Bin Ren, College of William & Mary 1 Bits, Bytes, and Integers Representing information as bits Bit-level manipulations Integers Representation: unsigned
More informationTopics of this Slideset. CS429: Computer Organization and Architecture. It s Bits All the Way Down. Why Binary? Why Not Decimal?
Topics of this Slideset CS429: Computer Organization and Architecture There are 10 kinds of people in the world: those who understand binary, and those who don t! Dr. Bill Young Department of Computer
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: September 11, 2017 at 08:58 CS429 Slideset 2: 1 Topics of this Slideset
More informationCS 33. Data Representation, Part 1. CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Data Representation, Part 1 CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Number Representation Hindu-Arabic numerals developed by Hindus starting in
More informationBits, Bytes and Integers
Bits, Bytes and Integers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran
More informationCarnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition
Carnegie Mellon 1 Bits, Bytes and Integers Part 1 15-213/18-213/15-513: Introduction to Computer Systems 2 nd Lecture, Aug. 31, 2017 Today s Instructor: Randy Bryant 2 Announcements Recitations are on
More informationComputer Organization: A Programmer's Perspective
A Programmer's Perspective Bits, Bytes, Nibbles, Words and Strings Gal A. Kaminka galk@cs.biu.ac.il Topics Why bits? Why 0/1? Basic terms: Bits, Bytes, Nibbles, Words Representing information as bits Characters
More informationBits, Bytes, and Integers Part 2
Bits, Bytes, and Integers Part 2 15-213: Introduction to Computer Systems 3 rd Lecture, Jan. 23, 2018 Instructors: Franz Franchetti, Seth Copen Goldstein, Brian Railing 1 First Assignment: Data Lab Due:
More informationBits and Bytes: Data Presentation Mohamed Zahran (aka Z)
CSCI-UA.0201 Computer Systems Organization Bits and Bytes: Data Presentation Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted and modified from: Clark Barrett Jinyang
More informationBits, Bytes, and Integers August 26, 2009
15-213 The Class That Gives CMU Its Zip! Bits, Bytes, and Integers August 26, 2009 Topics Representing information as bits Bit-level manipulations Boolean algebra Expressing in C Representations of Integers
More informationArithmetic and Bitwise Operations on Binary Data
Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Boolean Algebra Developed by
More informationCSCI2467: Systems Programming Concepts
CSCI2467: Systems Programming Concepts Slideset 2: Information as Data (CS:APP Chap. 2) Instructor: M. Toups Spring 2018 Course updates datalab out today! - due after Mardi gras... - do not wait until
More informationBITS, BYTES, AND INTEGERS
BITS, BYTES, AND INTEGERS CS 045 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition ORIGINS
More informationArithmetic and Bitwise Operations on Binary Data
Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides
More informationBits, Bytes and Integers Part 1
Bits, Bytes and Integers Part 1 15-213/18-213/15-513: Introduction to Computer Systems 2 nd Lecture, Jan. 18, 2018 Instructors: Franz Franchetti Seth Copen Goldstein Brian Railing 1 Announcements Waitlist
More informationJin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019
Jin-Soo Kim (jinsoo.kim@snu.ac.kr) Systems Software & Architecture Lab. Seoul National University Integers Spring 2019 4190.308: Computer Architecture Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) 2 A
More informationBits, Bytes, and Integers
Bits, Bytes, and Integers B&O Readings: 2.1-2.3 CSE 361: Introduc=on to Systems So@ware Instructor: I- Ting Angelina Le e Note: these slides were originally created by Markus Püschel at Carnegie Mellon
More informationComputer Systems CEN591(502) Fall 2011
Computer Systems CEN591(502) Fall 2011 Sandeep K. S. Gupta Arizona State University 4 th lecture Data representation in computer systems (Slides adapted from CSAPP book) Announcements Programming assignment
More informationMemory, Data, & Addressing II CSE 351 Spring
Memory, Data, & Addressing II CSE 351 Spring 2018 http://xkcd.com/138/ Review Questions 1) If the word size of a machine is 64-bits, which of the following is usually true? (pick all that apply) a) 64
More informationData III & Integers I
Data III & Integers I CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun
More informationFoundations of Computer Systems
18-600 Foundations of Computer Systems Lecture 3: Bits, Bytes, and Integers September 6, 2017 Required Reading Assignment: Chapter 2 of CS:APP (3 rd edition) by Randy Bryant & Dave O Hallaron Assignments
More informationByte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Byte Ordering Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Memory Model Physical memory DRAM chips can read/write 4, 8, 16 bits DRAM modules
More informationCS140 Lecture 08: Data Representation: Bits and Ints. John Magee 13 February 2017
CS140 Lecture 08: Data Representation: Bits and Ints John Magee 13 February 2017 Material From Computer Systems: A Programmer's Perspective, 3/E (CS:APP3e) Randal E. Bryant and David R. O'Hallaron, Carnegie
More informationComputer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2
Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up
More informationData III & Integers I
Data III & Integers I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Everyone has VM
More informationCSC 2400: Computer Systems. Bit- Level vs. Logical Opera<ons. Bit- Level Operators. Common to C and Java &,, ~, ^, <<, >>
CSC 2400: Computer Systems Bit- Level vs. Logical Opera
More informationByte Ordering. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Byte Ordering 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 informationRepresenting and Manipulating Integers Part I
Representing and Manipulating Integers Part I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Introduction The advent of the digital age Analog
More informationCourse overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine
Course overview Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18 with slides by Kip Irvine Logistics Meeting time: 9:10am-12:10pm, Monday Classroom: CSIE Room 102 Instructor: Yung-Yu
More informationRepresenting and Manipulating Integers. Jo, Heeseung
Representing and Manipulating Integers Jo, Heeseung Unsigned Integers Encoding unsigned integers B [ bw 1, bw 2,..., b0 ] x = 0000 0111 1101 0011 2 D( B) w 1 b i i 0 2 i D(x) = 2 10 + 2 9 + 2 8 + 2 7 +
More informationDigital Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Digital Systems 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 informationData III & Integers I
Data III & Integers I CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie
More informationSystems 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 1 3: Integers in C Computer Architecture and Systems
More informationMemory, Data, & Addressing II
Memory, Data, & Addressing II CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson
More informationCS 107 Lecture 2: Bits and Bytes (continued)
CS 107 Lecture 2: Bits and Bytes (continued) Friday, January 12, 2018 Computer Systems Winter 2018 Stanford University Computer Science Department Reading: Reader: Number Formats Used in CS 107 and Bits
More informationNumber Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers
Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We
More informationECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)
ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #3: Of Integers and Endians (pt. 2) Reading for Today: Davies Ch 2, MSP430 User's Guide Ch 6.1, 6.3 Reading for Next Class:
More informationManipulating Integers
Manipulating Integers 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 informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationCS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.
CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. 1 Part 1: Data Representation Our goal: revisit and re-establish fundamental of mathematics for the computer architecture course Overview: what are bits
More informationSystems 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 1 1: Introduction Systems Programming and Computer
More informationEE292: Fundamentals of ECE
EE292: Fundamentals of ECE Fall 2012 TTh 10:00-11:15 SEB 1242 Lecture 22 121115 http://www.ee.unlv.edu/~b1morris/ee292/ 2 Outline Review Binary Number Representation Binary Arithmetic Combinatorial Logic
More informationBitwise Data Manipulation. Bitwise operations More on integers
Bitwise Data Manipulation Bitwise operations More on integers bitwise operators ex Bitwise operators on fixed-width bit vectors. AND & OR XOR ^ NOT ~ 01101001 & 01010101 01000001 01101001 01010101 01101001
More informationCS 261 Fall Binary Information (convert to hex) Mike Lam, Professor
CS 261 Fall 2018 Mike Lam, Professor 3735928559 (convert to hex) Binary Information Binary information Topics Base conversions (bin/dec/hex) Data sizes Byte ordering Character and program encodings Bitwise
More informationInteger Encoding and Manipulation
CSE 2421: Systems I Low-Level Programming and Computer Organization Integer Encoding and Manipulation Presentation D Study: Bryant Chapter 2.1 2.3 Gojko Babić 01-24-2018 Unsigned & Signed Integer Encoding
More informationAnnouncements* Hardware:*Logical*View* Hardware:*SemiVLogical*View* Hardware:*Physical*View*
Announcements* Hardware:*Logical*View* On*the*website:*cs.uw.edu/351* Speedometer!** Anonymous*feedback*form* Make*sure*you*are*subscribed*to*the*mailing*list* Lecture*slides*on*the*web*schedule*(these*will*be*linked*1>2*days*prior)*
More informationComputer Organization & Systems Exam I Example Questions
Computer Organization & Systems Exam I Example Questions 1. Pointer Question. Write a function char *circle(char *str) that receives a character pointer (which points to an array that is in standard C
More informationSystems Programming and Computer Architecture ( )
(252-0061-00) Timothy Roscoe Herbstsemester 2013 Systems Group Department of Computer Science ETH Zürich 1 1: Introduction 252-0061-00, Herbstsemester 2013 Timothy Roscoe 2 This course covers in depth
More informationIntroduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C
Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation
More informationRepresentation of Information
Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept
More informationTopics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation
Computer Organization CS 231-01 Data Representation Dr. William H. Robinson November 12, 2004 Topics Power tends to corrupt; absolute power corrupts absolutely. Lord Acton British historian, late 19 th
More informationNumber Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example
Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,
More informationCourse overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2007/09/17. with slides by Kip Irvine
Course overview Computer Organization and Assembly Languages Yung-Yu Chuang 2007/09/17 with slides by Kip Irvine Logistics Meeting time: 2:20pm-5:20pm, Monday Classroom: CSIE Room 102 Instructor: Yung-Yu
More informationBeginning C Programming for Engineers
Beginning Programming for Engineers R. Lindsay Todd Lecture 6: Bit Operations R. Lindsay Todd () Beginning Programming for Engineers Beg 6 1 / 32 Outline Outline 1 Place Value Octal Hexadecimal Binary
More informationCSE351: Memory, Data, & Addressing I
CSE351: Memory, Data, & Addressing I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis http://xkcd.com/138/
More informationUnder the Hood: Data Representations, Memory and Bit Operations. Computer Science 104 Lecture 3
Under the Hood: Data Representations, Memory and Bit Operations Computer Science 104 Lecture 3 Homework #1 Due Feb 6 Reading TAs Finish Chapter 1 Start Chapter 2 Admin +1 UTA: Michael Zhou Lindsay is Head
More informationBits, Bytes, and Integers. Bits, Bytes, and Integers. The Decimal System and Bases. Everything is bits. Converting from Decimal to Binary
with contribtions from Dr. Bin Ren, College of William & Mary Addition, negation, mltiplication, shifting 1 Everything is bits The Decimal System and Bases Each bit is or 1 By encoding/interpreting sets
More informationBinary Values. CSE 410 Lecture 02
Binary Values CSE 410 Lecture 02 Lecture Outline Binary Decimal, Binary, and Hexadecimal Integers Why Place Value Representation Boolean Algebra 2 First: Why Binary? Electronic implementation Easy to store
More informationECE331: Hardware Organization and Design
ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Basics Midterm to cover Book Sections (inclusive) 1.1 1.5
More informationME 461 C review Session Fall 2009 S. Keres
ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help
More informationl l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers
198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book Computer Architecture What do computers do? Manipulate stored information
More informationInteger Representation Floating point Representation Other data types
Chapter 2 Bits, Data Types & Operations Integer Representation Floating point Representation Other data types Why do Computers use Base 2? Base 10 Number Representation Natural representation for human
More informationCOMP2121: Microprocessors and Interfacing. Number Systems
COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting
More informationInstruction Set Architecture
C Fortran Ada etc. Basic Java Instruction Set Architecture Compiler Assembly Language Compiler Byte Code Nizamettin AYDIN naydin@yildiz.edu.tr http://www.yildiz.edu.tr/~naydin http://akademik.bahcesehir.edu.tr/~naydin
More informationREMEMBER TO REGISTER FOR THE EXAM.
REMEMBER TO REGISTER FOR THE EXAM http://tenta.angstrom.uu.se/tenta/ Floating point representation How are numbers actually stored? Some performance consequences and tricks Encoding Byte Values Byte =
More informationBits, Words, and Integers
Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are
More informationCENG3420 Lecture 03 Review
CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less
More informationBut first, encode deck of cards. Integer Representation. Two possible representations. Two better representations WELLESLEY CS 240 9/8/15
Integer Representation Representation of integers: unsigned and signed Sign extension Arithmetic and shifting Casting But first, encode deck of cards. cards in suits How do we encode suits, face cards?
More informationComputer Systems Programming. Practice Midterm. Name:
Computer Systems Programming Practice Midterm Name: 1. (4 pts) (K&R Ch 1-4) What is the output of the following C code? main() { int i = 6; int j = -35; printf( %d %d\n,i++, ++j); i = i >
More informationChapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 1: Basic Concepts Chapter Overview Welcome to Assembly Language Virtual Machine Concept Data Representation Boolean Operations
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 1: Basic Concepts Slides prepared by Kip R. Irvine Revision date: 09/15/2002 Chapter corrections (Web) Printing a slide show
More informationComputer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers
Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can
More informationComputer Organization MIPS ISA
CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationLogic, Words, and Integers
Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits
More informationTopic Notes: Bits and Bytes and Numbers
Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for
More informationECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee
ECE 250 / CS 250 Computer Architecture C to Binary: Memory & Data Representations Benjamin Lee Slides based on those from Alvin Lebeck, Daniel Sorin, Andrew Hilton, Amir Roth, Gershon Kedem Administrivia
More informationlarge units some names for large numbers CIS 2107 Chapter 2 Notes Part 1
large units CIS 2107 Chapter 2 Notes Part 1 Representing and Manipulating Information kilo 10 3 1,000 mega 10 6 1,000,000 giga 10 9 1,000,000,000 tera 10 12 1,000,000,000,000 peta 10 15 1,000,000,000,000,000
More informationCIS 2107 Chapter 2 Notes Part 1. Representing and Manipulating Information
CIS 2107 Chapter 2 Notes Part 1 Representing and Manipulating Information large units kilo 10 3 1,000 mega 10 6 1,000,000 giga 10 9 1,000,000,000 tera 10 12 1,000,000,000,000 peta 10 15 1,000,000,000,000,000
More informationLecture 4: Instruction Set Architecture
Lecture 4: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation Reading: Textbook (5 th edition) Appendix A Appendix B (4 th edition)
More informationA few examples are below. Checking your results in decimal is the easiest way to verify you ve got it correct.
CS107 Handout 22S Spring 2007 May 4, 2007 Assignment 5 Solution Brought to you by Julie Zelenski and Jerry Cain. Problem 1: Binary numbers and bit operations A few examples are below. Checking your results
More informationCS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation
CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;
More informationProgramming refresher and intro to C programming
Applied mechatronics Programming refresher and intro to C programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2018 Outline 1 C programming intro 2
More information2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).
2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode
More informationCPSC 213. Introduction to Computer Systems. Numbers and Memory. Unit 1a
CPSC 213 Introduction to Computer Systems Unit 1a Numbers and Memory 1 The Big Picture Build machine model of execution for Java and C programs by examining language features and deciding how they are
More informationData Representa+on in Memory
Data Representa+on in Memory CSCI 2400 / ECE 3217: Computer Architecture Instructor: Prof. Jason FriAs Slides adapted from Bryant & O Hallaron s slides 1 Data Representa+on in Memory Basic memory organiza+on
More informationCS 33. Data Representation, Part 2. CS33 Intro to Computer Systems VIII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Data Representation, Part 2 CS33 Intro to Computer Systems VIII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Numeric Ranges Unsigned Values UMin = 0 000 0 UMax = 2 w 1 111 1 Two s Complement
More informationLow-Level Programming
Programming for Electrical and Computer Engineers Low-Level Programming Dr. D. J. Jackson Lecture 15-1 Introduction Previous chapters have described C s high-level, machine-independent features. However,
More informationA flow chart is a graphical or symbolic representation of a process.
Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of
More informationCS107, Lecture 3 Bits and Bytes; Bitwise Operators
CS107, Lecture 3 Bits and Bytes; Bitwise Operators reading: Bryant & O Hallaron, Ch. 2.1 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution
More informationCS 61C: Great Ideas in Computer Architecture. (Brief) Review Lecture
CS 61C: Great Ideas in Computer Architecture (Brief) Review Lecture Instructor: Justin Hsia 7/16/2013 Summer 2013 Lecture #13 1 Topic List So Far (1/2) Number Representation Signed/unsigned, Floating Point
More information17. Instruction Sets: Characteristics and Functions
17. Instruction Sets: Characteristics and Functions Chapter 12 Spring 2016 CS430 - Computer Architecture 1 Introduction Section 12.1, 12.2, and 12.3 pp. 406-418 Computer Designer: Machine instruction set
More informationNumber Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:
N Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as: a n a a a The value of this number is given by: = a n Ka a a a a a
More information