Lecture A2: X-TOY Programming

Size: px
Start display at page:

Download "Lecture A2: X-TOY Programming"

Transcription

1 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 = von Neumann architecture. Data representation. Binary and he. X-TOY instruction set architecture. 6 instruction types. Sample X-TOY machine language programs. Arithmetic. Loops. DEC PDP 2 2 Manipulate addresses. Arrays. Function calls. Pointers. What We Do Today Ballistic Tables Store table of f() = - 2 +b + c for various values of. Note: can t afford to multiply. Use "differencing method." Represent data other than positive integers. Negative numbers. f() = Standard input, standard output. Bitwise operations. XOR, AND. f() f() f()

2 Static addressing. Memory Indirection Until now, all load/store addresses hardwired in instruction. E. 8A34: R[A] mem[34] More fleibility needed to implement arrays. Indirect (dynamic) addressing. Work with names of data. Want to access variable memory location like, instead of hardwiring 34. Solution. delta = f() Put memory address in register. (C "pointer") Use CONTENTS of register as address. Use store indirect, load indirect instructions to access. t = - 2 f() ballistic.c int t = 2; int y = c, = ; int delta = b-; while (y > ) { y += delta; delta += t; a[] = y; ++; } 5 Ballistic ballistic.toy B: 6 b C: 7 c : 7 R[] : 722 R[2] 2 t 2 2: 7A2 R[A] 2 a[] 3: 73 R[3] 4: 84B R[4] mem[b] 5: 244 R[4] R[4] - R[] delta b- 6: 85C R[5] mem[c] y c 7: B5A mem[r[a]] R[5] a[] f() 8: 554 R[5] R[5] + R[4] y += delta 9: 2442 R[4] R[4] - R[2] delta += t A: 33 R[3] R[3] + R[] ++ B: 7A3 R[7] R[A] + R[3] address of a[] C: B57 mem[r[7]] R[5] a[] y D: D58 if (R[5] > ) goto 8 E: halt 6 Representing Other Primitive Data Types Negative integers. X-TOY uses two s complement integers. Done in precept. Big integers. Can use "multiple precision." Use two 6-bit words per integer. Real numbers. Can use "floating point" (like scientific notation). Double word for etra precision. Characters. Can use ASCII code (7 bits / character). Can pack two characters into one 6-bit word. Standard input. Standard Input, Standard Output Loading from memory address FF loads one (headecimal) integer from X-TOY stdin. 8AFF means: read an integer from standard input, and store it in register A scanf("%hx", &a); Standard output. Writing to memory location FF. 5 stdin-stdout.toy : 8AFF read R[A] : 9AFF write R[A] 2: halt ? 8 6 A 6 F 6 F 6 opcode dest d addr 7 8

3 Standard Input, Standard Output Enables computer to process more information than fits in memory. Arbitrary amounts of input. ma.c Bitwise AND. (opcode 3) Bitwise XOR. (opcode 4) Bitwise Operations int, ma = ; while (scanf("%d", &)!= EOF) { if ( > ma) ma = ; } printf("maimum = %d\n", ma); Arbitrary amounts of output. dragon curve void dragon(int m) { int k; F(); for (k = ; k <= m-; k++) { if (k & ((k^(k-))+)) R(); } } dragon-nonrecursive.c else L(); F(); check bit to the left of rightmost 9 Logic operations are BITWISE: & FAD2 6 = 2 6 Bitwise AND y AND Logic operations are BITWISE: ^ FAD2 6 = E8E6 6 Bitwise XOR y XOR? &? F 6 A 6 D =? ? ^? F 6 A 6 D =? E E

4 Dragon in XTOY Standard Input, Standard Output: Booting Impress your Yale friends with these lines of code! Connect stdout to turtle. Booting. Work all day to develop operating system. L if zero R if nonzero Keeps going until turtle runs out of energy. dragon.toy : 7 R[] <- : 72 R[2] <- k How do you save it for tomorrow? leave computer on?! Tubes would blow up. write short program dump.toy to dump contents of memory onto tape run dump.toy How do you get it back? dump.toy F: 7 R[] F: 72EF R[2] EF F2: A32 R[3] mem[r[2]] F3: 93FF write R[3] F4: 222 R[2] R[2] - R[] F5: D2F2 if (R[2] > ) goto F2 2: 232 R[3] <- R[2] - R[] k - 3: 4423 R[4] <- R[2] ^ R[3] k ^ (k-) 4: 54 R[5] <- R[4] + R[] (k^(k-))+ 5: 3552 R[5] <- R[5] & R[2] k & ((k^(k-))+) 6: 95FF write R[5] 7: 22 R[2] <- R[2] + R[] 8: C2 goto 2 9: halt 3 turn on computer, old memory values gone key in short program boot.toy to read contents of memory from tape run boot.toy use operating system 4 Function Call: A Failed Attempt Multiplication Function Goal: y z. Need two multiplications: y, ( y) z.! Solution : write multiply code 2 times.! Solution 2: write an X-TOY function. A failed attempt: Write multiply loop at Calling program agrees to store arguments in register A and B. Function agrees to leave result in register C. Call function with jump absolute to 3. Return from function with jump absolute. Reason for failure.! Need to return to a VARIABLE memory address. function? : 8AFF : 8BFF 2: C3 3: AC 4: 8BFF 5: C3 6: 9CFF 7: 3: 7 3: CA36 32: CCB 33: 2AA 34: C3 35: C3 Calling convention. Jump to line 3. Store a and b in registers A and B. Return address in register F. Put result c = a b in register C. Register is scratch. Overwrites registers A and B. function.toy 3: 7C R[C] 3: 7 R[] 32: CA36 if (R[A] == ) goto 36 33: CCB R[C] += R[B] 34: 2AA R[A]-- 35: C32 goto 32 36: EF pc R[F] return opcode E jump register function : 8AFF : 8BFF 2: FF3 3: AC 4: 8BFF 5: FF3 6: 9CFF 7: 3: 7C 3: 7 32: CA36 33: CCB 34: 2AA 35: C32 36: EF 5 6

5 Multiplication Function Call Function Call: One Solution Client program to compute y z. Read, y, z from standard input. Note: PC is incremented before instruction is eecuted. value stored in register F is correct return address function.toy (cont) : 82FF read R[2] : 83FF read R[3] y 2: 84FF read R[4] z 3: A2 R[A] R[2] 4: B3 R[B] R[3] y 5: FF3 R[F] pc; goto 3 * y 6: AC R[A] R[C] ( * y) 7: B4 R[B] R[4] z 8: FF3 R[F] pc; goto 3 ( * y) * z 9: 9CFF write R[C] A: halt opcode F jump and link R[F] 6 Contract between calling program and function: Calling program stores function parameters in specific registers. Calling program stores return address in a specific register. jump-and-link Calling program sets PC to address of function. Function stores return value in specific register. Function sets PC to return address when finished. jump register What if you want a function to call another function?! Use a different register for return address.! More general: store return addresses on a stack. 7 8 An Efficient Multiplication Algorithm Binary Multiplication Inefficient multiply. Load in integers a and b, and store c = a b. Brute-force algorithm: initialize c = add b to c, a times "Grade-school" binary multiplication. Grade school binary multiplication algorithm. Initialize c =. Loop over i bits of b. if b i =, do nothing if b i =, shift a left i bits and add to c b i = ith bit of b Implement with built-in TOY shift instructions. * Decimal * Binary * multiply-fast.c int c = ; for (i = 5; i >= ; i--) { if ((b >> i) & ) c += (a << i); 9 2

6 Shift left. (opcode 5) Shift Left Move bits to the left, padding with zeros as needed. Shift left. (opcode 6) Shift Right Move bits to the right, padding with sign bit as needed << 7 6 = 6 6 discard >> 7 6 = 24 6 discard? sign bit? << 7 = pad with s pad with s >> 7 =? ? Fast Multiplication Function multiply-fast.toy // Input: R[A] contains a, R[B] contains b // Output: R[C] contains a * b Lecture A2: Etra Slides 3: 7 R[] <- 3: 72 R[2] <- i = 6 32: 7C R[C] <- result 6-bit integers 33: C23B if (R[2] == ) goto 3B while (i > ) { 34: 222 R[2]-- i-- 35: 53A2 R[3] R[A] << R[2] a left shifted i 36: 64B2 R[4] R[B] >> R[2] 37: 344 R[4] R[4] & R[] b_i = i th bit of b 38: C43A if (R[4] == ) goto 3A 39: CC3 R[C] += R[3] add to result 3A: C33 goto 33 } 3B: EF goto R[F] return 23

7 Dec He FFF FFFF FFFE FFFD FFFC Two s Complement Integers Binary?????????? Two s Complement Integers Properties: Leading bit (bit 5) signifies sign. Negative integer -N represented by 2 6 -N. Trick to compute -N:. Start with N ? 2. Flip bits.? 3. Add. -4? ? Properties of Two s Complement Integers Nice properties: represents. - and + are the same. Addition is easy (see net slide). Checking for arithmetic overflow is easy. Not-so-nice properties. - N = ~N + Can represent one more negative integer than positive integer (-32,768 = 5 but not 32,768 = 2 5 ). Two s Complement Arithmetic Addition is carried out as if all integers were positive. It usually works: -3? + 4? =? 27 28

8 Two s Complement Arithmetic Addition is carried out as if all integers were positive. It usually works. But overflow / underflow can occur:! Carry into sign (left most) bit with no carry out. +32,767? + 2? = -32,767? Shift Right Shift right. (opcode 6) Move bits to the right, padding with sign bit as needed. FFCA 6 >> 2 6 = FFF >> 2 = -3 discard sign bit? F 6 F 6 C 6 A 6 pad with s >> 2 =? F 6 F 6 F Jump absolute. Useful X-TOY Idioms Jump to a fied memory address. branch if zero with destination register Register assignment. No instruction that transfers contents of one register into another. Pseudo-instruction that simulates assignment: add with register as one of two source registers Register assignment No-op. Instruction that does nothing. Plays the role of whitespace in C programs. numerous other possibilities! Jump absolute 7: C4 pc 4 7: 23 R[2] R[3] No-op 7: no-op Other Logical Operations Any logical operation can be implemented with AND and XOR. See Boolean circuit lecture. Build OR from AND and XOR. ( & y) ^ ( ^ y ) Build NOT from XOR. ^ = FFFF ^ = (bitwise NOT) y a & y b ^ y ^ a ^ b NOT OR 3 32

12/11/ The TOY Machine II. Data Representation. What We've Learned About TOY. What We Do Today. Adding and Subtracting Binary Numbers

12/11/ The TOY Machine II. Data Representation. What We've Learned About TOY. What We Do Today. Adding and Subtracting Binary Numbers // 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.

More information

5. The TOY Machine II

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 information

TOY II LINC LINC. !1 Introduction to Computer Science Sedgewick and Wayne Copyright 2007

TOY 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

11. A Computing Machine

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

! Binary and hex. ! Box with switches and lights. ! 4,328 bits = (255 " 16) + (15 " 16) + (8) = 541 bytes! ! von Neumann architecture.

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

What is TOY? An imaginary machine similar to: ! Ancient computers. ! Today's microprocessors.

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

! Ancient computers. ! Today's microprocessors. Memory. ! Stores data and programs. ! 256 "words." (16 bits each) ! Special word for stdin / stdout.

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

Virtual machines. Virtual machines. Abstractions for computers. Abstractions for computers. Virtual machines

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

Computer Architecture /

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

Chapter. Computer Architecture

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

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

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

COS 126 Midterm 1 Written Exam Spring 2015

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

CIS 110 Introduction to Computer Programming. 17 December 2012 Final Exam

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

COS 126 General Computer Science Fall Exam 1

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

CS.17.A.MachineI.Overview

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

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10 Instruction Sets Ch 9-10 Characteristics Operands Operations Addressing Instruction Formats 1 Instruction Set (käskykanta) Collection of instructions that CPU understands Only interface to CPU from outside

More information

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10 Instruction Sets Ch 9-10 Characteristics Operands Operations Addressing Instruction Formats 1 Instruction Set (käskykanta) Collection of instructions that CPU understands Only interface to CPU from outside

More information

Wednesday, February 4, Chapter 4

Wednesday, 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 information

Mark II Aiken Relay Calculator

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

COS 126 Written Exam 2 (Spring 2015)

COS 126 Written Exam 2 (Spring 2015) COS 126 Written Exam 2 (Spring 2015) There are 8 questions on this exam, weighted as indicated below. This exam is closed book. You may use a single-page two-sided hand-written cheatsheet. There is a blank

More information

Arithmetic and Bitwise Operations on Binary Data

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

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types Instruction Sets Ch 10-11 Characteristics Operands Operations Addressing Instruction Formats Instruction Set Collection of instructions that CPU understands Only interface to CPU from outside CPU executes

More information

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

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

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

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

C++ to assembly to machine code

C++ to assembly to machine code IBCM 1 C++ to assembly to machine code hello.cpp #include int main() { std::cout

More information

Computer Organization CS 206 T Lec# 2: Instruction Sets

Computer Organization CS 206 T Lec# 2: Instruction Sets Computer Organization CS 206 T Lec# 2: Instruction Sets Topics What is an instruction set Elements of instruction Instruction Format Instruction types Types of operations Types of operand Addressing mode

More information

11/22/1999 7pm - 9pm. Name: Login Name: Preceptor Name: Precept Number:

11/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 information

Computer Architecture

Computer Architecture Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

More information

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019

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

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

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

COS 126 General Computer Science Spring Written Exam 1

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

Wednesday, September 13, Chapter 4

Wednesday, 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 information

COMPUTER ORGANIZATION & ARCHITECTURE

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

Instruction Sets: Characteristics and Functions Addressing Modes

Instruction Sets: Characteristics and Functions Addressing Modes Instruction Sets: Characteristics and Functions Addressing Modes Chapters 10 and 11, William Stallings Computer Organization and Architecture 7 th Edition What is an Instruction Set? The complete collection

More information

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

Number 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

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

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

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

Shift and Rotate Instructions

Shift and Rotate Instructions Shift and Rotate Instructions Shift and rotate instructions facilitate manipulations of data (that is, modifying part of a 32-bit data word). Such operations might include: Re-arrangement of bytes in a

More information

The Assembly Language of the Boz 5

The Assembly Language of the Boz 5 The Assembly Language of the Boz 5 The Boz 5 uses bits 31 27 of the IR as a five bit opcode. Of the possible 32 opcodes, only 26 are implemented. Op-Code Mnemonic Description 00000 HLT Halt the Computer

More information

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction 1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floating-point numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in

More information

EC-801 Advanced Computer Architecture

EC-801 Advanced Computer Architecture EC-801 Advanced Computer Architecture Lecture 5 Instruction Set Architecture I Dr Hashim Ali Fall 2018 Department of Computer Science and Engineering HITEC University Taxila!1 Instruction Set Architecture

More information

Instruction Set Architecture

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

CS33 Project Gear Up. Data

CS33 Project Gear Up. Data CS33 Project Gear Up Data Project Overview You will be solving a series of puzzles using your knowledge of data representations. IMPORTANT: Collaboration This project has a different collaboration policy

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1 CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB

More information

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix

More information

Midterm 1 topics (in one slide) Bits and bitwise operations. Outline. Unsigned and signed integers. Floating point numbers. Number representation

Midterm 1 topics (in one slide) Bits and bitwise operations. Outline. Unsigned and signed integers. Floating point numbers. Number representation Midterm 1 topics (in one slide) CSci 2021: Review Lecture 1 Stephen McCamant University of Minnesota, Computer Science & Engineering Number representation Bits and bitwise operators Unsigned and signed

More information

COS 126 Written Exam 2 Spring 18

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

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1 Instructions: MIPS ISA Chapter 2 Instructions: Language of the Computer 1 PH Chapter 2 Pt A Instructions: MIPS ISA Based on Text: Patterson Henessey Publisher: Morgan Kaufmann Edited by Y.K. Malaiya for

More information

Part 1 (70% of grade for homework 2): MIPS Programming: Simulating a simple computer

Part 1 (70% of grade for homework 2): MIPS Programming: Simulating a simple computer CS 465 - Homework 2 Fall 2016 Profs. Daniel A. Menasce and Yutao Zhong Team Allowed: maximum of two per team. State clearly team member names and GMU IDs as comments in source code and each page of submitted

More information

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation Complement Number Systems A complement number system is used to represent positive and negative integers A complement number system is based on a fixed length representation of numbers Pretend that integers

More information

18. Machine Language. Computer Systems. COMP1917: Computing 1. Machine Language Programming. History of Computer Technology

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

Instructions: Language of the Computer

Instructions: Language of the Computer CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction

More information

Instructions: Language of the Computer

Instructions: Language of the Computer CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction

More information

COMP2611: Computer Organization. Data Representation

COMP2611: 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 information

COS 126 General Computer Science Fall Midterm 1

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

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

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

EC 413 Computer Organization

EC 413 Computer Organization EC 413 Computer Organization Review I Prof. Michel A. Kinsy Computing: The Art of Abstraction Application Algorithm Programming Language Operating System/Virtual Machine Instruction Set Architecture (ISA)

More information

The Arithmetic Operators

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

Computer Organization MIPS ISA

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

Arithmetic Logic Unit

Arithmetic Logic Unit Arithmetic Logic Unit A.R. Hurson Department of Computer Science Missouri University of Science & Technology A.R. Hurson 1 Arithmetic Logic Unit It is a functional bo designed to perform "basic" arithmetic,

More information

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store. IT 3123 Hardware and Software Concepts February 11 and Memory II Copyright 2005 by Bob Brown The von Neumann Architecture 00 01 02 03 PC IR Control Unit Command Memory ALU 96 97 98 99 Notice: This session

More information

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017 4/8/17 Admin! Assignment 5 BINARY David Kauchak CS 52 Spring 2017 Diving into your computer Normal computer user 1 After intro CS After 5 weeks of cs52 What now One last note on CS52 memory address binary

More information

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning 4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

More information

Full file at

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

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

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

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29 CS 31: Introduction to Computer Systems 03: Binary Arithmetic January 29 WiCS! Swarthmore Women in Computer Science Slide 2 Today Binary Arithmetic Unsigned addition Subtraction Representation Signed magnitude

More information

Inf2C - Computer Systems Lecture 2 Data Representation

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

Bits, Bytes, and Integers Part 2

Bits, 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 information

3. Instruction Set Architecture The MIPS architecture

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

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions

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 information

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.

More information

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

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

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

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

CIS 110 Spring 2014 Introduction to Computer Programming 12 May 2014 Final Exam Answer Key

CIS 110 Spring 2014 Introduction to Computer Programming 12 May 2014 Final Exam Answer Key CIS 110 Spring 2014 Final Exam 1 CIS 110 Spring 2014 Introduction to Computer Programming 12 May 2014 Final Exam Answer Key 0.) THE EASY ONE (1 point total) Check coversheet for name, recitation #, PennKey,

More information

von Neumann Architecture Basic Computer System Early Computers Microprocessor Reading Assignment An Introduction to Computer Architecture

von Neumann Architecture Basic Computer System Early Computers Microprocessor Reading Assignment An Introduction to Computer Architecture Reading Assignment EEL 4744C: Microprocessor Applications Lecture 1 Part 1 An Introduction to Computer Architecture Microcontrollers and Microcomputers: Chapter 1, Appendix A, Chapter 2 Software and Hardware

More information

Basic Computer System. von Neumann Architecture. Reading Assignment. An Introduction to Computer Architecture. EEL 4744C: Microprocessor Applications

Basic Computer System. von Neumann Architecture. Reading Assignment. An Introduction to Computer Architecture. EEL 4744C: Microprocessor Applications Reading Assignment EEL 4744C: Microprocessor Applications Lecture 1 Part 1 An Introduction to Computer Architecture Microcontrollers and Microcomputers: Chapter 1, Appendix A, Chapter 2 Software and Hardware

More information

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

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

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

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

Instructions: Language of the Computer

Instructions: Language of the Computer Instructions: Language of the Computer Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class

More information

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring EE 260: Introduction to Digital Design Arithmetic II Yao Zheng Department of Electrical Engineering University of Hawaiʻi at Mānoa Overview n Integer multiplication n Booth s algorithm n Integer division

More information

MIPS Functions and Instruction Formats

MIPS Functions and Instruction Formats MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other

More information

SN8F5000 Family Instruction Set

SN8F5000 Family Instruction Set SONiX Technology Co., Ltd. 8051-based Microcontroller 1 Overview SN8F5000 is 8051 Flash Type microcontroller supports comprehensive assembly instructions and which are fully compatible with standard 8051.

More information

The LC-3 Instruction Set Architecture. ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path

The LC-3 Instruction Set Architecture. ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path Chapter 5 The LC-3 Instruction Set Architecture ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path A specific ISA: The LC-3 We have: Reviewed data encoding

More information

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA. Today s topics CS/COE1541: Introduction to Computer Architecture MIPS operations and operands MIPS registers Memory view Instruction encoding A Review of MIPS ISA Sangyeun Cho Arithmetic operations Logic

More information

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014 B CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014 DUE : March 3, 2014 READ : - Related sections of Chapter 2 - Related sections of Chapter 3 - Related sections of Appendix A - Related sections

More information

COS 140: Foundations of Computer Science

COS 140: Foundations of Computer Science COS 140: Foundations of Computer Science CPU Organization and Assembly Language Fall 2018 CPU 3 Components of the CPU..................................................... 4 Registers................................................................

More information

EE 109 Unit 6 Binary Arithmetic

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

COMPUTER ORGANIZATION

COMPUTER ORGANIZATION COMPUTER ORGANIZATION INDEX UNIT-II PPT SLIDES Srl. No. Module as per Session planner Lecture No. PPT Slide No. 1. Register Transfer language 2. Register Transfer Bus and memory transfers 3. Arithmetic

More information

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One

More information

THE MICROPROCESSOR Von Neumann s Architecture Model

THE MICROPROCESSOR Von Neumann s Architecture Model THE ICROPROCESSOR Von Neumann s Architecture odel Input/Output unit Provides instructions and data emory unit Stores both instructions and data Arithmetic and logic unit Processes everything Control unit

More information

Course Administration

Course Administration Fall 2018 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 4/4 Avinash Karanth Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701

More information

COMP1917 Computing 1 Written Exam Sample Questions

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

CO212 Lecture 10: Arithmetic & Logical Unit

CO212 Lecture 10: Arithmetic & Logical Unit CO212 Lecture 10: Arithmetic & Logical Unit Shobhanjana Kalita, Dept. of CSE, Tezpur University Slides courtesy: Computer Architecture and Organization, 9 th Ed, W. Stallings Integer Representation For

More information

The MIPS Instruction Set Architecture

The MIPS Instruction Set Architecture The MIPS Set Architecture CPS 14 Lecture 5 Today s Lecture Admin HW #1 is due HW #2 assigned Outline Review A specific ISA, we ll use it throughout semester, very similar to the NiosII ISA (we will use

More information

Instruction Set Design

Instruction Set Design Instruction Set Design software instruction set hardware CPE442 Lec 3 ISA.1 Instruction Set Architecture Programmer's View ADD SUBTRACT AND OR COMPARE... 01010 01110 10011 10001 11010... CPU Memory I/O

More information

Continued from previous lecture

Continued from previous lecture The Design of C: A Rational Reconstruction: Part 2 Jennifer Rexford Continued from previous lecture 2 Agenda Data Types Statements What kinds of operators should C have? Should handle typical operations

More information