12/11/ The TOY Machine II. Data Representation. What We've Learned About TOY. What We Do Today. Adding and Subtracting Binary Numbers
|
|
- Joy Atkinson
- 6 years ago
- Views:
Transcription
1 // What We've Learned About TOY. The TOY Machine II TOY machine. Box with switches and lights. 6-bit memory locations, 6-bit registers, 8-bit pc. 4,38 bits = ( 6) + ( 6) + (8) = 4 bytes! von Neumann architecture. TOY programming. TOY instruction set architecture: 6 instruction types. Variables, arithmetic, loops. Laboratory Instrument Computer (LINC) Introduction to Computer Science: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright // :9:46 What We Do Today Data representation. Negative numbers. Data Representation Input and output. Standard input, standard output. Manipulate addresses. References (pointers) and arrays. TOY simulator in Java. 3 4 Digital World Adding and Subtracting Binary Numbers Data is a sequence of bits. (interpreted in different ways) Integers, real numbers, characters, strings, Documents, pictures, sounds, movies, Java programs, Decimal and binary addition. carries Ex. As binary integer: = 7. As character: 7 th Unicode character = 'u'. As music: 7/6 position of speaker. As grayscale value: 4.7% black Subtraction. Add a negative integer. e.g., 6-4 = 6 + (-4)) Q. How to represent negative integers? 6
2 // Representing Negative Integers Two's Complement Integers TOY words are 6 bits each. We could use 6 bits to represent to 6 -. We want negative integers too. Reserving half the possible bit-patterns for negative seems fair. Highly desirable property. If x is an integer, then the representation of -x, when added to x, is zero. To compute -x from x: Start with x. leading bit +4 Flip bits.? -? x +(-x) +???????? Add one. -4? flip bits and add x + +(-x) Two's Complement Integers Properties of Two's Complement Integers Properties Leading bit (bit ) signifies sign. dec hex binary Addition and subtraction are easy FFF? represents zero. Checking for arithmetic overflow is easy ?? Negative integer -x represented by 6 - x. Not symmetric: can represent -3,768 but not 3,768. +? FFFF??? Java. Java's int data type is a 3-bit two's complement integer. Ex equals FFFE? -3 FFFD? -4 FFFC? ? 9 Representing Other Primitive Data Types in TOY Bigger integers. Use two 6-bit TOY words per 3-bit Java int. Standard Input and Output Real numbers. Use IEEE floating point (like scientific notation). Use four 6-bit TOY words per 64-bit Java double. Characters. Use one 6-bit TOY word per 6-bit Java Unicode char. M = = 4D 6 O = = 4F 6 M = = 4D 6 Note. Real microprocessors add hardware support for int and double.
3 // Standard Output Standard Input Standard output. Writing to memory location FF sends one word to TOY stdout. Ex. 9AFF writes the integer in register A to stdout. : : : 8A RA mem[] a = : 8B RB mem[] b = : 9AFF write RA to stdout print a 3: AAB RA RA + RB a = a + b 4: BAB RB RA - RB b = a - b : DA if (RA > ) goto } while (a > ) 6: halt fibonacci.toy 3 8 D E DB 63D A8 A6D AC 4F 6FF Standard input. Loading from memory address FF loads one word from TOY stdin. Ex. 8AFF reads an integer from stdin and store it in register A. Ex: read in a sequence of integers and print their sum. In Java, stop reading when EOF. In TOY, stop reading when user enters. while (!StdIn.isEmpty()) { a = StdIn.readInt(); sum = sum + a; } StdOut.println(sum); : : 8C RC <- mem[] : 8AFF read RA from stdin : CA if (RA == ) pc 3: CCA RC RC + RA 4: C pc : 9CFF write RC 6: halt AE 46 3 F7 3 4 Standard Input and Output: Implications Standard input and output enable you to: Get information out of machine. Put information from real world into machine. Process more information than fits in memory. Interact with the computer while it is running. Pointers redirected from punchcard by default: flip switch, press button by default: LED redirected to punchcard 6 Load Address (a.k.a. Load Constant) Arrays in TOY Load address. [opcode 7] Loads an 8-bit integer into a register. 7A3 means load the value 3 into register A. Applications. Load a small constant into a register. Load a 8-bit memory address into a register. register stores "pointer" to a memory cell a = x3; Java code TOY main memory is a giant array. Can access memory cell 3 using load and store. 8C3 means load mem[3] into register C. Goal: access memory cell i where i is a variable. a variable index Load indirect. [opcode A] AC6 means load mem[r6] into register C D TOY memory Store indirect. [opcode B] BC6 means store contents of register C into mem[r6]. a variable index ? for (int i = ; i < N; i++) a[i] = StdIn.readInt(); 7 6 A opcode dest d addr for (int i = ; i < N; i++) StdOut.println(a[N-i-]); 7 8 3
4 // TOY Implementation of Reverse TOY Implementation of Reverse TOY implementation of reverse. Read in a sequence of integers and store in memory 3, 3, 3, until reading. Print sequence in reverse order. TOY implementation of reverse. Read in a sequence of integers and store in memory 3, 3, 3, until reading. Print sequence in reverse order. : 7 R constant : 7A3 RA 3 a[] : 7B RB n while(true) { 3: 8CFF read RC c = StdIn.readInt(); 4: CC9 if (RC == ) goto 9 if (c == ) break; : 6AB R6 RA + RB memory address of a[n] 6: BC6 mem[r6] RC a[n] = c; 7: BB RB RB + R n++; 8: C3 goto 3 } 9: CB if (RB == ) goto while (n > ) { A: 6AB R6 RA + RB address of a[n] B: 66 R6 R6 R address of a[n-] C: AC6 RC mem[r6] c = a[n-]; D: 9CFF write RC StdOut.println(c); E: BB RB RB R n--; F: C9 goto 9 } : halt print in reverse order read in the data 9 Unsafe Code at any Speed What Can Happen When We Lose Control (in C or C++)? Q. What happens if we make array start at instead of 3? A. Self modifying program; can overflow buffer and run arbitrary code! : 7 R constant : 7A RA a[] : 7B RB n Buffer overflow. Array buffer[] has size. User might enter characters. Might lose control of machine behavior. Consequences. Viruses and worms. #include <stdio.h> int main(void) { char buffer[]; scanf("%s", buffer); printf("%s\n", buffer); return ; } unsafe C program while(true) { 3: 8CFF read RC c = StdIn.readInt(); 4: CC9 if (RC == ) goto 9 if (c == ) break; : 6AB R6 RA + RB address of a[n] 6: BC6 mem[r6] RC a[n] = c; 7: BB RB RB + R n++; 8: C3 goto 3 } % more crazy8.txt FF C Java enforces security. Type safety. Array bounds checking. Not foolproof. shine W bulb at DRAM [Appel-Govindavajhala '3] Buffer Overflow Attacks Buffer Overflow Example: JPEG of Death Stuxnet worm. [July ] Step. Natanz centrifuge fuel-refining plant employee plugs in USB flash drive. Step. Data becomes code by exploiting Window buffer overflow; machine is wned. Step 3. Uranium enrichment in Iran stalled. Microsoft Windows JPEG bug. [September, 4] Step. User views malicious JPEG in IE or Outlook. Step. Machine is wned. Data becomes code by exploiting buffer overrun in GDI+ library. More buffer overflow attacks: Morris worm, Code Red, SQL Slammer, iphone unlocking, Xbox softmod, JPEG of death, Fix. Update old library with patched one. but many applications install independent copies of GDI library Lesson. Not easy to write error-free software. Embrace Java security features. Keep your OS patched. Moral. Not easy to write error-free software. Embrace Java security features. Don't try to maintain several copies of the same file. Keep your OS patched
5 // Dumping Booting Q. Work all day to develop operating system in mem[] to mem[ff]. How to save it? A. Write short program dump.toy and run it to dump contents of memory onto tape. Q. How do you get it back? A. Write short program boot.toy and run it to read contents of mem[] to mem[ff] from tape. : 7 R : 7 R i = : 73FF R3 FF 3: AA RA mem[r] a = mem[i] 4: 9AFF write RA print a : R R + R i++ 6: 43 R4 R3 - R 7: D43 if (R4 > ) goto 3 } while (i < ) 8: halt : 7 R : 7 R i = : 73FF R3 FF 3: 8AFF read RA read a 4: BA mem[r] RA mem[i] = a : R R + R i++ 6: 43 R4 R3 - R 7: D43 if (R4 > ) goto 3 } while (i < ) 8: halt dump.toy boot.toy 6 Two's Complement Arithmetic Extra Slides Addition is carried out as if all integers were positive. It usually works. -3? + 4? =? 4 4 Two's Complement Arithmetic Java and TOY Addition is carried out as if all integers were positive. It usually works. But overflow can occur. Correspondence between Java constructs and TOY mechanisms. Java TOY carry into sign (left most) bit with no carry out or carry out out of sign bit with no carry in assignment load, store +3,767? arithmetic expressions logical expressions add, subtract xor, and, shifts + loops (for, while) jump absolute, branch branches (if-else, switch) branch if zero, positive? arrays, linked lists indirect addressing = function call recursion jump and link, jump indirect implement stack with arrays -3,767? whitespace no-op
5. The TOY Machine II
5. The TOY Machine II Laboratory Instrument Computer (LINC) Introduction to Computer Science: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2011 2/18/2013 9:52:08 AM What
More informationTOY II LINC LINC. !1 Introduction to Computer Science Sedgewick and Wayne Copyright 2007
TOY II Introduction to Computer Science Sedgewick and Wayne Copyright 27 http://www.cs.princeton.edu/introcs 2 LINC LINC 5 6 What We've Learned About TOY Quick Review: Multiply Data representation. Binary
More information! Binary and hex. ! Box with switches and lights. ! 4,328 bits = (255 " 16) + (15 " 16) + (8) = 541 bytes! ! von Neumann architecture.
What We've Learned About TOY TOY II Data representation. Binary and hex. TOY: what's in it, how to use it. Box with switches and lights. 4,328 bits = (255 " 6) + (5 " 6) + (8) = 54 bytes von Neumann architecture.
More informationLecture A2: X-TOY Programming
Lecture A2: X-TOY Programming What We ve Learned About X-TOY X-TOY: what s in it, how to use it. Bo with switches and lights. 436 bits = 256 6 + 6 6 + 8. von Neumann architecture. Data representation.
More informationWhat is TOY? An imaginary machine similar to: ! Ancient computers. ! Today's microprocessors.
5. The TOY Machine Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 3// 5:3 AM! What is TOY? An imaginary machine similar to:! Ancient computers.!
More information11. A Computing Machine
COMPUTER SCIENCE S E D G E W I C K / W A Y N E Computer Science Including Programming in Java 11. A Computing Machine Section 5.1 http://introcs.cs.princeton.edu COMPUTER SCIENCE S E D G E W I C K / W
More information! Ancient computers. ! Today's microprocessors. Memory. ! Stores data and programs. ! 256 "words." (16 bits each) ! Special word for stdin / stdout.
What is TOY?. The TOY Machine An imaginary machine similar to:! Ancient computers.! Today's microprocessors. Introduction to Computer Science Sedgewick and Wayne Copyright http://www.cs.princeton.edu/introcs
More informationChapter. Computer Architecture
Chapter 4 Computer Architecture Figure 4.1 Input device Central processing unit Main memory Output device Bus Data flow Control Figure 4.2 Central processing unit () Status bits ( ) Accumulator ( ) Index
More informationCOS 126 Midterm 1 Written Exam Spring 2015
COS 126 Midterm 1 Written Exam Spring 2015 There are 9 questions on this exam, weighted as indicated below. The exam is closed book, though you are allowed to use a single-page one-sided hand-written cheatsheet.
More informationComputer Architecture /
Computer Architecture 02-201 / 02-601 The Conceptual Architecture of a Computer PC CPU register 0 register 1 register 2 registers hold small amounts of data for processing by the CPU Reading / writing
More informationCOS 126 General Computer Science Fall Midterm 1
COS 126 General Computer Science Fall 2001 Midterm 1 This test has 11 questions worth a total of 50 points. You have 120 minutes. The exam is closed book, except that you are allowed to use a one page
More informationCIS 110 Introduction to Computer Programming. 17 December 2012 Final Exam
CIS 110 Introduction to Computer Programming 17 December 2012 Final Exam Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of
More informationCOS 126 General Computer Science Fall Exam 1
COS 126 General Computer Science Fall 2005 Exam 1 This test has 9 questions worth a total of 50 points. You have 120 minutes. The exam is closed book, except that you are allowed to use a one page cheatsheet,
More informationCOS 126 General Computer Science Spring Written Exam 1
COS 126 General Computer Science Spring 2014 Written Exam 1 This exam is closed book, except that you are allowed to use a one-page single-sided cheatsheet. No calculators or other electronic devices are
More informationComputer Science. 18. von Neumann Machines. Computer Science COMPUTER SCIENCE. Sections
COMPUTER SCIENCE S E D G E W I C K / W A Y N E PA R T I I : A L G O R I T H M S, M A C H I N E S, a n d T H E O R Y Computer Science Computer Science An Interdisciplinary Approach ROBERT SEDGEWICK K E
More information6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )
6. Combinational Circuits George Boole (85 864) Claude Shannon (96 2) Signals and Wires Digital signals Binary (or logical ) values: or, on or off, high or low voltage Wires. Propagate digital signals
More informationVirtual machines. Virtual machines. Abstractions for computers. Abstractions for computers. Virtual machines
1 2 Problems with programming using machine code Difficult to remember instructions Difficult to remember variables Hard to calculate addresses/relocate variables or functions Need to handle instruction
More informationFull file at
Chapter Two DATA MANIPULATION Formatted Chapter Summary This chapter introduces the role of a computer's CPU. It describes the machine cycle and the various operations (or, and, exclusive or, add, shift,
More informationCOS 126 General Computer Science Fall Exam 1
COS 126 General Computer Science Fall 2008 Exam 1 This test has 11 questions worth a total of 50 points. You have 120 minutes. The exam is closed book, except that you are allowed to use a one page cheatsheet,
More informationWednesday, February 4, Chapter 4
Wednesday, February 4, 2015 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/8 Features of the system Operational cycle Program trace Categories of
More informationCS.17.A.MachineI.Overview
P R T I I : L G O R I T H M S, M H I N E S, a n d T H E O R Y P R T I I : L G O R I T H M S, M H I N E S, a n d T H E O R Y omputer Science 7. omputing Machine omputer Science 7. omputing Machine Overview
More informationCourse Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation
Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep
More informationSIGNED AND UNSIGNED SYSTEMS
EE 357 Unit 1 Fixed Point Systems and Arithmetic Learning Objectives Understand the size and systems used by the underlying HW when a variable is declared in a SW program Understand and be able to find
More informationCOSC 6385 Computer Architecture. Instruction Set Architectures
COSC 6385 Computer Architecture Instruction Set Architectures Spring 2012 Instruction Set Architecture (ISA) Definition on Wikipedia: Part of the Computer Architecture related to programming Defines set
More informationC++ to assembly to machine code
IBCM 1 C++ to assembly to machine code hello.cpp #include int main() { std::cout
More informationWednesday, September 13, Chapter 4
Wednesday, September 13, 2017 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/9 Features of the system Operational cycle Program trace Categories of
More informationThe CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:
The CPU and Memory How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram: 1 Registers A register is a permanent storage location within
More informationMore Programming Constructs -- Introduction
More Programming Constructs -- Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and
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 informationPage 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions
Structure of von Nuemann machine Arithmetic and Logic Unit Input Output Equipment Main Memory Program Control Unit 1 1 Instruction Set - the type of Instructions Arithmetic + Logical (ADD, SUB, MULT, DIV,
More information18. Machine Language. Computer Systems. COMP1917: Computing 1. Machine Language Programming. History of Computer Technology
COMP1917 13s2 18. Machine Language 1 COMP1917: Computing 1 18. Machine Language Computer Systems Recall: modern computer systems are layered. Applications Programming Language Operating System Assembly
More informationDigital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand
Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary
More informationIntroduction to Computer Science. Homework 1
Introduction to Computer Science Homework. In each circuit below, the rectangles represent the same type of gate. Based on the input and output information given, identify whether the gate involved is
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 informationEE 109 Unit 6 Binary Arithmetic
EE 109 Unit 6 Binary Arithmetic 1 2 Semester Transition Point At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is
More informationCIS 110 Introduction to Computer Programming. 7 May 2012 Final Exam
CIS 110 Introduction to Computer Programming 7 May 2012 Final Exam Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania
More informationMachine Arithmetic 8/31/2007
Machine Arithmetic 8/31/2007 1 Opening Discussion Let's look at some interclass problems. If you played with your program some you probably found that it behaves oddly in some regards. Why is this? What
More informationCOMP1917 Computing 1 Written Exam Sample Questions
COMP1917 Computing 1 Written Exam Sample Questions Note: these sample questions are intended to provide examples of a certain style of question which did not occur in the tutorial or laboratory exercises,
More informationSOEN228, Winter Revision 1.2 Date: October 25,
SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003 1 Contents Flags Mnemonics Basic I/O Exercises Overview of sample programs 2 Flag Register The flag register stores the condition flags that retain
More informationCOSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)
COSC 243 Instruction Sets And Addressing Modes 1 Overview This Lecture Source Chapters 12 & 13 (10 th editition) Textbook uses x86 and ARM (we use 6502) Next 2 Lectures Assembly language programming 2
More informationCPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e Feb 11, 13, 15, and 25. Winter Session 2018, Term 2
CPSC 213 Introduction to Computer Systems Winter Session 2018, Term 2 Unit 1e Feb 11, 13, 15, and 25 Procedures and the Stack Overview Reading Companion: 2.8 Textbook: 3.7, 3.12 Learning Goals explain
More informationBuffer overflows (a security interlude) Address space layout the stack discipline + C's lack of bounds-checking HUGE PROBLEM
Buffer overflows (a security interlude) Address space layout the stack discipline + C's lack of bounds-checking HUGE PROBLEM x86-64 Linux Memory Layout 0x00007fffffffffff not drawn to scale Stack... Caller
More informationThe Design of C: A Rational Reconstruction"
The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby
More informationPrinceton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation
Princeton University Computer Science 27: Introduction to Programming Systems Goals of this Lecture and Number Representation Help you learn (or refresh your memory) about: The binary, hexadecimal, and
More informationGoals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers
CSC 2400: Computer Systems Bits, Bytes and Data Types 1 Goals for this Week Binary number system Why binary? Converting between decimal and binary and octal and hexadecimal number systems Finite representations
More informationComputer Organization II CMSC 3833 Lecture 33
Term MARIE Definition Machine Architecture that is Really Intuitive and Easy 4.8.1 The Architecture Figure s Architecture Characteristics: Binary, two s complement Stored program, fixed word length Word
More informationMath 230 Assembly Programming (AKA Computer Organization) Spring 2008
Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 MIPS Intro II Lect 10 Feb 15, 2008 Adapted from slides developed for: Mary J. Irwin PSU CSE331 Dave Patterson s UCB CS152 M230 L10.1
More informationCSE 12 Spring 2016 Week One, Lecture Two
CSE 12 Spring 2016 Week One, Lecture Two Homework One and Two: hw2: Discuss in section today - Introduction to C - Review of basic programming principles - Building from fgetc and fputc - Input and output
More informationInf2C - Computer Systems Lecture 2 Data Representation
Inf2C - Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack
More informationNotes: The Marie Simulator
The Accumulator (AC) is the register where calculations are performed. To add two numbers together, a) load the first number into the accumulator with a Load instruction b) Add the second number to the
More information2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks
Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include injection of malicious code Reasons for runtime attacks
More informationNumber Systems and Number Representation
Princeton University Computer Science 217: Introduction to Programming Systems Number Systems and Number Representation Q: Why do computer programmers confuse Christmas and Halloween? A: Because 25 Dec
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 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 informationThe Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Op. Use Description + x + y adds x and y x y
More informationThe Arithmetic Operators
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Examples: Op. Use Description + x + y adds x
More informationInteger Representation
Integer Representation Announcements assign0 due tonight assign1 out tomorrow Labs start this week SCPD Note on ofce hours on Piazza Will get an email tonight about labs Goals for Today Introduction to
More informationE3940 Microprocessor Systems Laboratory. Introduction to the Z80
E3940 Microprocessor Systems Laboratory Introduction to the Z80 Andrew T. Campbell comet.columbia.edu/~campbell campbell@comet.columbia.edu E3940 Microprocessor Systems Laboratory Page 1 Z80 Laboratory
More informationCSE 351 Midterm - Winter 2015 Solutions
CSE 351 Midterm - Winter 2015 Solutions February 09, 2015 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 informationCOS 126 Midterm 1 Written Exam, Fall 2009
NAME: login ID: precept: COS 126 Midterm 1 Written Exam, Fall 2009 This test has 8 questions, weighted as indicated. The exam is closed book, except that you are allowed to use a one page cheatsheet. No
More information10.1. Unit 10. Signed Representation Systems Binary Arithmetic
0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system
More informationLecture V Toy Hardware and Operating System
2. THE Machine Lecture V Page 1 Lecture V Toy Hardware and Operating System 1. Introduction For use in our OS projects, we introduce THE Machine where THE is an acronym 1 for Toy HardwarE. We also introduce
More informationMark II Aiken Relay Calculator
Introduction to Embedded Microcomputer Systems Lecture 6.1 Mark II Aiken Relay Calculator 2.12. Tutorial 2. Arithmetic and logical operations format descriptions examples h 8-bit unsigned hexadecimal $00
More informationCPSC213/2014W1 Midterm EXTRA Practice
CPSC213/2014W1 Midterm EXTRA Practice DEC/HEX/BIN NUMERACY 1. Convert into decimal: 1a. 0x33 1b. 0x57 1c. 0xaf 1d. 0x7a 1e. 0x1234 1f. 0x69bd 1g. 0x1a64 1h. 0xdead 2. Convert into hex numbers of the specified
More informationBetriebssysteme und Sicherheit Sicherheit. Buffer Overflows
Betriebssysteme und Sicherheit Sicherheit Buffer Overflows Software Vulnerabilities Implementation error Input validation Attacker-supplied input can lead to Corruption Code execution... Even remote exploitation
More informationChapter 5. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 5 <1>
Chapter 5 Digital Design and Computer Architecture, 2 nd Edition David Money Harris and Sarah L. Harris Chapter 5 Chapter 5 :: Topics Introduction Arithmetic Circuits umber Systems Sequential Building
More informationCOMP2611: Computer Organization. Data Representation
COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How
More informationCOS 126 Written Exam 2 Spring 18
COS 126 Written Exam 2 Spring 18 Instructions. This exam has 7 questions, worth 10 points each. You have 50 minutes. Resources. You may reference your optional two-sided 8.5-by-11 handwritten "cheat sheet"
More informationLevels of Programming. Registers
Levels of Programming COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1. Arithmetic Instructions 2.
More informationThe Design of C: A Rational Reconstruction
The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby
More informationPage 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?
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
More informationHarry H. Porter, 2006
The SPARC Computer Architecture Harry Porter Portland State University 1 CS-321 Lexer Parser Type Checking Intermediate Code Generation All semantic error checking finished in this phase IR - Intermediate
More informationIntroduction to Assembly language
Introduction to Assembly language 1 USING THE AVR MICROPROCESSOR Outline Introduction to Assembly Code The AVR Microprocessor Binary/Hex Numbers Breaking down an example microprocessor program AVR instructions
More informationCOMPUTER ORGANIZATION & ARCHITECTURE
COMPUTER ORGANIZATION & ARCHITECTURE Instructions Sets Architecture Lesson 5a 1 What are Instruction Sets The complete collection of instructions that are understood by a CPU Can be considered as a functional
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 information4.3 Stacks, Queues, and Linked Lists
4.3 Stacks, Queues, and Linked Lists Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 3/21/2013 8:59:11 PM Data Types and Data Structures
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 informationCOSC345 Software Engineering. Basic Computer Architecture and The Stack
COSC345 Software Engineering Basic Computer Architecture and The Stack Outline Architectural models A little about the 68HC11 Memory map Registers A little bit of assembly (never did us any harm) The program
More information1.5 Input and Output. Input and Output. Digital Michelangelo Project. Input and Output. Input devices. Output devices.
Input and Output 1.5 Input and Output Input devices. Keyboard Mouse Hard drive Network Digital camera Speakers Hard drive Network Printer Microphone Output devices. Display MP3 Player Goal. Java programs
More informationThe Design of C: A Rational Reconstruction" Jennifer Rexford!
The Design of C: A Rational Reconstruction" Jennifer Rexford! 1 Goals of this Lecture"" Number systems! Binary numbers! Finite precision! Binary arithmetic! Logical operators! Design rationale for C! Decisions
More informationLecture 4: MIPS Instruction Set
Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software
More information11/22/1999 7pm - 9pm. Name: Login Name: Preceptor Name: Precept Number:
Login Preceptor Precept Number: Computer Science 126 Second Midterm Exam 11/22/1999 7pm - 9pm This exam has 10 questions. The weight of each question is printed in the table below and next to each question.
More informationMicrocontroller Systems
µcontroller systems 1 / 43 Microcontroller Systems Engineering Science 2nd year A2 Lectures Prof David Murray david.murray@eng.ox.ac.uk www.robots.ox.ac.uk/ dwm/courses/2co Michaelmas 2014 µcontroller
More informationCOSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)
COSC 243 Data Representation 3 Lecture 3 - Data Representation 3 1 Data Representation Test Material Lectures 1, 2, and 3 Tutorials 1b, 2a, and 2b During Tutorial a Next Week 12 th and 13 th March If you
More informationCOMP Overview of Tutorial #2
COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,
More informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
More informationCOSC 243. Assembly Language Techniques. Lecture 9. COSC 243 (Computer Architecture)
COSC 243 Assembly Language Techniques 1 Overview This Lecture Source Handouts Next Lectures Memory and Storage Systems 2 Parameter Passing In a high level language we don t worry about the number of parameters
More informationBuffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Buffer Overflow Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu x86-64/linux Memory Layout Stack Runtime stack (8MB limit) Heap Dynamically allocated
More informationLecture 2: The Instruction Set Architecture
Lecture 2: The Instruction Set Architecture COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David August 1 2 Quiz 0 3 Quiz 0 CD 3 Miles of Music 4 Pits and Lands
More information3. Instruction Set Architecture The MIPS architecture
3. Instruction Set Architecture The MIPS architecture EECS 370 Introduction to Computer Organization Winter 2007 Prof. Valeria Bertacco & Prof. Scott Mahlke EECS Department University of Michigan in Ann
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 informationAssembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College
Assembly Language Programming CPSC 252 Computer Organization Ellen Walker, Hiram College Instruction Set Design Complex and powerful enough to enable any computation Simplicity of equipment MIPS Microprocessor
More informationIECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.
Subject code - CCP01 Chapt Chapter 1 INTRODUCTION TO C 1. A group of software developed for certain purpose are referred as ---- a. Program b. Variable c. Software d. Data 2. Software is classified into
More informationBuffer Overflow. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Buffer Overflow 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 information211: Computer Architecture Summer 2016
211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Data Representation I/O: - (example) cprintf.c Memory: - memory address - stack / heap / constant space - basic data layout Pointer:
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 information9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System
For Your Amusement Number Systems and Number Representation Jennifer Rexford Question: Why do computer programmers confuse Christmas and Halloween? Answer: Because 25 Dec = 31 Oct -- http://www.electronicsweekly.com
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 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 informationIntroduction to programming Tasks
Introduction to programming Tasks Imre Varga University of Debrecen, Faculty of Informatics For internal use only! 11 February 2017 Computer system Put the following things into the appropriate set: CPU,
More information