Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm

Size: px
Start display at page:

Download "Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm"

Transcription

1 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm Notes to Winter 2005 ENCM 369 Students This handout contains the questions from an old midterm. Spaces for answers have been removed in order to save paper in printing. General Instructions You may not use electronic calculators or computers during the test. The test is closed-book. You may not refer to books or notes during the test, with one exception: you may refer to the Reference Material page that accompanies this test paper. You are not required to add comments to assembly language code you write, but you are strongly encouraged to do so, because writing good comments will improve the probability that your code is correct and will help you to check your code after it is finished. Some problems are relatively easy and some are relatively difficult. Go after the easy marks first. To reduce distraction to other students, you are not allowed to leave during the last ten minutes of the test. Write all answers on the question paper and hand in the question paper when you are done. Please print or write your answers legibly. What cannot be read cannot be marked. If you write anything you do not want marked, put a large X through it and write rough work beside it. You may use the backs of pages for rough work. PAGE 1 OF 5

2 PROBLEM 1 (total of 14 marks) The function proc_c is defined in the following C translation unit: int proc_a(int j, int k); int * proc_b(int *p, int *q); int proc_c(int x, int y, int *z) int a, b; a = proc_a(y, *z); b = *proc_b(&a, &x); return a * (b + y + *z); Part a. (3 marks) For each of the local variables a and b state whether the variable should be in a register or on the stack. Briefly give reasons to support your answer. Part b. (11 marks) Translate the definition of the function proc_c into SPIM assembly language. Follow the calling conventions used in lectures and labs, and use only instructions from the Midterm Instruction Subset described on the Reference Material page. Assume the following for integer multiplication: The 64-bit product of two 32-bit operands is computed, then bits 31 0 of the product are copied into the register or memory word corresponding to the result. PROBLEM 2 (16 marks) Here is a C program: void f1(int *a, int *b, int n); int f2(int k); int aaa[3] = 0x100, 0x200, 0x300 ; int main(void) int bbb[3]; int *p; for (p = bbb; p < bbb + 3; p++) *p = 0x150; f1(aaa, bbb, 3); return 0; void f1(int *a, int *b, int n) int i; for (i = 0; i < n; i++) b[i] += f2(i) + a[i]; int f2(int k) int x; x = k + k; /* point one */ return x + k; PAGE 2 OF 5

3 Below is a correct translation of that C program into SPIM assembly language. Note that it follows all calling conventions used in lectures and labs, and that each procedure uses $s0 as a local variable. (The listing starts on this page and continues on the next page.).data aaa aaa:.word 0x100, 0x200, 0x300 main: loop1: quit1:.text main addiu $sp, $sp, -20 sw $ra, 16($sp) sw $s0, 12($sp) addiu $s0, $sp, 0 addiu $t0, $sp, 12 # $t0 = bbb + 3 addiu $t1, $zero, 0x150 sltu $t2, $s0, $t0 beq $t2, $zero, quit1 sw $t1, ($s0) addiu $s0, $s0, 4 j loop1 la $a0, aaa addiu $a1, $sp, 0 addiu $a2, $zero, 3 jal f1 addiu $v0, $zero, 0 lw $s0, 12($sp) lw $ra, 16($sp) addiu $sp, $sp, 20 f1: loop2: f1 addiu $sp, $sp, -20 sw $a2, 16($sp) sw $a1, 12($sp) sw $a0, 8($sp) sw $ra, 4($sp) sw $s0, 0($sp) addiu $s0, $zero, 0 lw $t0, 16($sp) slt $t1, $s0, $t0 beq $t1, $zero, quit2 addu $a0, $s0, $zero jal f2 addu $t2, $s0, $s0 addu $t2, $t2, $t2 # $t2 = 4*i lw $t3, 12($sp) addu $t3, $t3, $t2 lw $t4, 8($sp) PAGE 3 OF 5

4 quit2: f2: addu $t4, $t4, $t2 lw $t5, ($t3) lw $t6, ($t4) addu $t7, $v0, $t5 addu $t6, $t7, $t6 sw $t6, ($t3) addiu $s0, $s0, 1 j loop2 lw $s0, 0($sp) lw $ra, 4($sp) addiu $sp, $sp, 20 f2 addiu $sp, $sp, -4 sw $s0, 0($sp) addu $s0, $a0, $s0 # point one addu $v0, $s0, $a0 lw $s0, 0($sp) addiu $sp, $sp, 4 What To Do: Consider the third time that the program passes through point one. For this moment in time: make a diagram of the stack, clearly indicating the boundaries of each stack frame; list the contents of registers $a0, $s0, $sp, and $ra. Show the contents of the stack slots and registers as numbers. Assume the following: When main is called, $ra contains 0x0040_0018, $s0 contains 0, and $sp contains 0x7fff_ffcc. The address of aaa[0] is 0x1001_0000. The address of the instruction jal f1 is 0x0040_0058. The address of the instruction labeled loop2 is 0x0040_008c. PROBLEM 3 (total of 11 marks) Part a. (4 marks) Given the following values in MIPS general purpose registers: $t1 = 0x8000_0000, $t2 = 0x0000_0001 What values are in registers $t3 and $t4 after the following instructions are executed: slt $t3, $t2, $t1 subu $t4, $t1, $t2 PAGE 4 OF 5

5 Show or explain how you obtained your answers. Part b. (2 marks) In the subu instruction of part a, did overflow occur? Briefly explain how you obtained your answer. Part c. (2 marks) Two (of many) ways to load a 32-bit constant into a register are: to use SPIM instructions lui and addiu; to use SPIM instructions lui and ori. Suppose an assembly language wants to put 0x0001_8000 into $t0. Which of the above ways is preferable? Why? Part d. (3 marks) Write a sequence of SPIM instructions (not a complete procedure) to copy bits of register $s0 to bits 8 2 of register $s1 while making all other bits of $s1 equal to zero. Your instructions should not modify the contents of $s0. Modification of some t-registers contents is allowed (but not required). PROBLEM 4 (total of 18 marks) Part a. (12 marks) Consider the following C function, which returns the index of a maximum value among a[0], a[1],... a[n-1]: int index_of_max(const int *a, int n) const int *p; const int *q; int max; const int *x; p = a + 1; q = a; max = *a; x = a + n; while (p < x) if (*p > max) max = *p; q = p; p++; return q - a; Translate the function into SPIM assembly language. Follow the calling conventions used in lectures and labs, and use only instructions from the Midterm Instruction Subset described on the Reference Material page. You must allocate registers as follows: $s0 for p, $s1 for q, $s2 for max, and $s3 for x. Part b. (6 marks) Consider the following C function: void put_zero(char *a, int n) int i; for (i = n - 1; i >= 0; i--) a[i] = 0; Translate the function into SPIM assembly language. Follow the calling conventions used in lectures and labs, and use only instructions from the Midterm Instruction Subset described on the Reference Material page. You must allocate registers as follows: $s0 for i. PAGE 5 OF 5

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying

More information

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59 COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59 Overview: In the first projects for COMP 303, you will design and implement a subset of the MIPS32 architecture

More information

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9. Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables

More information

Typy danych. Data types: Literals:

Typy danych. Data types: Literals: Lab 10 MIPS32 Typy danych Data types: Instructions are all 32 bits byte(8 bits), halfword (2 bytes), word (4 bytes) a character requires 1 byte of storage an integer requires 1 word (4 bytes) of storage

More information

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I) Lecture Outline Code Generation (I) Stack machines The MIPS assembl language Adapted from Lectures b Profs. Ale Aiken and George Necula (UCB) A simple source language Stack- machine implementation of the

More information

MIPS Assembly Code Layout

MIPS Assembly Code Layout Learning MIPS & SPIM MIPS assembly is a low-level programming language The best way to learn any programming language is to write code We will get you started by going through a few example programs and

More information

More MIPS: Recursion. Computer Science 104 Lecture 9

More MIPS: Recursion. Computer Science 104 Lecture 9 More MIPS: Recursion Computer Science 104 Lecture 9 Admin Homework Homework 1: graded. 50% As, 27% Bs Homework 2: Due Wed Midterm 1 This Wed 1 page of notes 2 Last time What did we do last time? 3 Last

More information

Assembly Language Programming

Assembly Language Programming Assembly Language Programming Assemblers were the first programs to assist in programming. The idea of the assembler is simple: represent each computer instruction with an acronym (group of letters). Eg:

More information

Translating C code to MIPS

Translating C code to MIPS Translating C code to MIPS why do it C is relatively simple, close to the machine C can act as pseudocode for assembler program gives some insight into what compiler needs to do what's under the hood do

More information

Computer Systems Architecture

Computer Systems Architecture Computer Systems Architecture http://cs.nott.ac.uk/ txa/g51csa/ Thorsten Altenkirch and Liyang Hu School of Computer Science University of Nottingham Lecture 10: MIPS Procedure Calling Convention and Recursion

More information

Introduction to MIPS Assembly Programming

Introduction to MIPS Assembly Programming 1 / 26 Introduction to MIPS Assembly Programming January 23 25, 2013 2 / 26 Outline Overview of assembly programming MARS tutorial MIPS assembly syntax Role of pseudocode Some simple instructions Integer

More information

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc

More information

PCSpim Tutorial. Nathan Goulding-Hotta 2012-01-13 v0.1

PCSpim Tutorial. Nathan Goulding-Hotta 2012-01-13 v0.1 PCSpim Tutorial Nathan Goulding-Hotta 2012-01-13 v0.1 Download and install 1. Download PCSpim (file PCSpim_9.1.4.zip ) from http://sourceforge.net/projects/spimsimulator/files/ This tutorial assumes you

More information

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek Instruction Set Architecture or How to talk to computers if you aren t in Star Trek The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture

More information

Review: MIPS Addressing Modes/Instruction Formats

Review: MIPS Addressing Modes/Instruction Formats Review: Addressing Modes Addressing mode Example Meaning Register Add R4,R3 R4 R4+R3 Immediate Add R4,#3 R4 R4+3 Displacement Add R4,1(R1) R4 R4+Mem[1+R1] Register indirect Add R4,(R1) R4 R4+Mem[R1] Indexed

More information

The Operating System and the Kernel

The Operating System and the Kernel The Kernel and System Calls 1 The Operating System and the Kernel We will use the following terminology: kernel: The operating system kernel is the part of the operating system that responds to system

More information

MIPS Assembler and Simulator

MIPS Assembler and Simulator MIPS Assembler and Simulator Reference Manual Last Updated, December 1, 2005 Xavier Perséguers (ing. info. dipl. EPF) Swiss Federal Institude of Technology xavier.perseguers@a3.epfl.ch Preface MIPS Assembler

More information

5 MIPS Assembly Language

5 MIPS Assembly Language 103 5 MIPS Assembly Language Today, digital computers are almost exclusively programmed using high-level programming languages (PLs), eg, C, C++, Java The CPU fetch execute cycle, however, is not prepared

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

Instruction Set Architecture

Instruction Set Architecture Instruction Set Architecture Consider x := y+z. (x, y, z are memory variables) 1-address instructions 2-address instructions LOAD y (r :=y) ADD y,z (y := y+z) ADD z (r:=r+z) MOVE x,y (x := y) STORE x (x:=r)

More information

Introduction to MIPS Programming with Mars

Introduction to MIPS Programming with Mars Introduction to MIPS Programming with Mars This week s lab will parallel last week s lab. During the lab period, we want you to follow the instructions in this handout that lead you through the process

More information

Lecture 8: Binary Multiplication & Division

Lecture 8: Binary Multiplication & Division Lecture 8: Binary Multiplication & Division Today s topics: Addition/Subtraction Multiplication Division Reminder: get started early on assignment 3 1 2 s Complement Signed Numbers two = 0 ten 0001 two

More information

Instruction Set Architecture (ISA) Design. Classification Categories

Instruction Set Architecture (ISA) Design. Classification Categories Instruction Set Architecture (ISA) Design Overview» Classify Instruction set architectures» Look at how applications use ISAs» Examine a modern RISC ISA (DLX)» Measurement of ISA usage in real computers

More information

Compilers I - Chapter 4: Generating Better Code

Compilers I - Chapter 4: Generating Better Code Compilers I - Chapter 4: Generating Better Code Lecturers: Paul Kelly (phjk@doc.ic.ac.uk) Office: room 304, William Penney Building Naranker Dulay (nd@doc.ic.ac.uk) Materials: Office: room 562 Textbook

More information

Lab Work 2. MIPS assembly and introduction to PCSpim

Lab Work 2. MIPS assembly and introduction to PCSpim Lab Work 2. MIPS assembly and introduction to PCSpim The goal of this work is for the student to become familiar with the data types and the programming in assembly (MIPS32). To realize this lab work you

More information

Computer Organization and Components

Computer Organization and Components Computer Organization and Components IS1500, fall 2015 Lecture 5: I/O Systems, part I Associate Professor, KTH Royal Institute of Technology Assistant Research Engineer, University of California, Berkeley

More information

Chapter 7D The Java Virtual Machine

Chapter 7D The Java Virtual Machine This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly

More information

Design of Pipelined MIPS Processor. Sept. 24 & 26, 1997

Design of Pipelined MIPS Processor. Sept. 24 & 26, 1997 Design of Pipelined MIPS Processor Sept. 24 & 26, 1997 Topics Instruction processing Principles of pipelining Inserting pipe registers Data Hazards Control Hazards Exceptions MIPS architecture subset R-type

More information

CSE 141 Introduction to Computer Architecture Summer Session I, 2005. Lecture 1 Introduction. Pramod V. Argade June 27, 2005

CSE 141 Introduction to Computer Architecture Summer Session I, 2005. Lecture 1 Introduction. Pramod V. Argade June 27, 2005 CSE 141 Introduction to Computer Architecture Summer Session I, 2005 Lecture 1 Introduction Pramod V. Argade June 27, 2005 CSE141: Introduction to Computer Architecture Instructor: Pramod V. Argade (p2argade@cs.ucsd.edu)

More information

COMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING

COMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING COMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING 2013/2014 1 st Semester Sample Exam January 2014 Duration: 2h00 - No extra material allowed. This includes notes, scratch paper, calculator, etc.

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority) Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the

More information

Figure 1: Graphical example of a mergesort 1.

Figure 1: Graphical example of a mergesort 1. CSE 30321 Computer Architecture I Fall 2011 Lab 02: Procedure Calls in MIPS Assembly Programming and Performance Total Points: 100 points due to its complexity, this lab will weight more heavily in your

More information

Before entering the lab, make sure that you have your own UNIX and PC accounts and that you can log into them.

Before entering the lab, make sure that you have your own UNIX and PC accounts and that you can log into them. 1 Objective Texas A&M University College of Engineering Computer Science Department CPSC 321:501 506 Computer Architecture Fall Semester 2004 Lab1 Introduction to SPIM Simulator for the MIPS Assembly Language

More information

Design of Digital Circuits (SS16)

Design of Digital Circuits (SS16) Design of Digital Circuits (SS16) 252-0014-00L (6 ECTS), BSc in CS, ETH Zurich Lecturers: Srdjan Capkun, D-INFK, ETH Zurich Frank K. Gürkaynak, D-ITET, ETH Zurich Labs: Der-Yeuan Yu dyu@inf.ethz.ch Website:

More information

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution 16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more

More information

CS 241 Data Organization Coding Standards

CS 241 Data Organization Coding Standards CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.

More information

Intel 8086 architecture

Intel 8086 architecture Intel 8086 architecture Today we ll take a look at Intel s 8086, which is one of the oldest and yet most prevalent processor architectures around. We ll make many comparisons between the MIPS and 8086

More information

CS 61C: Great Ideas in Computer Architecture Finite State Machines. Machine Interpreta4on

CS 61C: Great Ideas in Computer Architecture Finite State Machines. Machine Interpreta4on CS 61C: Great Ideas in Computer Architecture Finite State Machines Instructors: Krste Asanovic & Vladimir Stojanovic hbp://inst.eecs.berkeley.edu/~cs61c/sp15 1 Levels of RepresentaKon/ InterpretaKon High

More information

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 January 22, 2013 Name: Grade /10 Introduction: In this lab you will write, test, and execute a number of simple PDP-8

More information

csci 210: Data Structures Recursion

csci 210: Data Structures Recursion csci 210: Data Structures Recursion Summary Topics recursion overview simple examples Sierpinski gasket Hanoi towers Blob check READING: GT textbook chapter 3.5 Recursion In general, a method of defining

More information

CS352H: Computer Systems Architecture

CS352H: Computer Systems Architecture CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline - Hazards October 1, 2009 University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell Data Hazards in ALU Instructions

More information

Q. Consider a dynamic instruction execution (an execution trace, in other words) that consists of repeats of code in this pattern:

Q. Consider a dynamic instruction execution (an execution trace, in other words) that consists of repeats of code in this pattern: Pipelining HW Q. Can a MIPS SW instruction executing in a simple 5-stage pipelined implementation have a data dependency hazard of any type resulting in a nop bubble? If so, show an example; if not, prove

More information

Syscall 5. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

Syscall 5. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas Syscall 5 System call 5 allows input of numerical data from the keyboard while a program is running. Syscall 5 is a bit unusual, in that it requires the use of register $v0 twice. In syscall 5 (as for

More information

EE282 Computer Architecture and Organization Midterm Exam February 13, 2001. (Total Time = 120 minutes, Total Points = 100)

EE282 Computer Architecture and Organization Midterm Exam February 13, 2001. (Total Time = 120 minutes, Total Points = 100) EE282 Computer Architecture and Organization Midterm Exam February 13, 2001 (Total Time = 120 minutes, Total Points = 100) Name: (please print) Wolfe - Solution In recognition of and in the spirit of the

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Slide Set 8. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 8. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 8 for ENCM 369 Winter 2015 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2015 ENCM 369 W15 Section

More information

EE361: Digital Computer Organization Course Syllabus

EE361: Digital Computer Organization Course Syllabus EE361: Digital Computer Organization Course Syllabus Dr. Mohammad H. Awedh Spring 2014 Course Objectives Simply, a computer is a set of components (Processor, Memory and Storage, Input/Output Devices)

More information

SMIPS Processor Specification

SMIPS Processor Specification SMIPS Processor Specification 6.884 Spring 25 - Version: 25215 1 Introduction SMIPS is the version of the MIPS instruction set architecture (ISA) we ll be using for the processors we implement in 6.884.

More information

Instruction Set Design

Instruction Set Design Instruction Set Design Instruction Set Architecture: to what purpose? ISA provides the level of abstraction between the software and the hardware One of the most important abstraction in CS It s narrow,

More information

Parameter Passing. Parameter Passing. Parameter Passing Modes in Fortran. Parameter Passing Modes in C

Parameter Passing. Parameter Passing. Parameter Passing Modes in Fortran. Parameter Passing Modes in C Parameter Passing In this set of notes you will learn about: Parameter passing modes Call by Call by reference Call by sharing Call by result Call by /result Call by name Subroutine closures as parameters

More information

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE 1. Introduction 6.004 Computation Structures β Documentation This handout is

More information

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be: Lecture 7 Picking Balls From an Urn The problem: An urn has n (n = 10) balls numbered from 0 to 9 A ball is selected at random, its' is number noted, it is set aside, and another ball is selected from

More information

Modbus RTU Communications RX/WX and MRX/MWX

Modbus RTU Communications RX/WX and MRX/MWX 15 Modbus RTU Communications RX/WX and MRX/MWX In This Chapter.... Network Slave Operation Network Master Operation: RX / WX Network Master Operation: DL06 MRX / MWX 5 2 D0 Modbus Network Slave Operation

More information

Chapter 5 Instructor's Manual

Chapter 5 Instructor's Manual The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 5 Instructor's Manual Chapter Objectives Chapter 5, A Closer Look at Instruction

More information

CSI 333 Lecture 1 Number Systems

CSI 333 Lecture 1 Number Systems CSI 333 Lecture 1 Number Systems 1 1 / 23 Basics of Number Systems Ref: Appendix C of Deitel & Deitel. Weighted Positional Notation: 192 = 2 10 0 + 9 10 1 + 1 10 2 General: Digit sequence : d n 1 d n 2...

More information

Reusable Application-Dependent Machine Descriptions

Reusable Application-Dependent Machine Descriptions Reprinted from Workshop on Compiler Support for System Software, February 1996. Reusable Application-Dependent Machine Descriptions Mark W. Bailey Jack W. Davidson Department of Computer Science University

More information

2.2: Bitwise Logical Operations

2.2: Bitwise Logical Operations 2.2: Bitwise Logical Operations Topics: Introduction: logical operations in C/C++ logical operations in MIPS In 256 lecture, we looked at bitwise operations in C/C++ and MIPS. We ll look at some simple

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA) Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine

More information

PROBLEMS (Cap. 4 - Istruzioni macchina)

PROBLEMS (Cap. 4 - Istruzioni macchina) 98 CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS PROBLEMS (Cap. 4 - Istruzioni macchina) 2.1 Represent the decimal values 5, 2, 14, 10, 26, 19, 51, and 43, as signed, 7-bit numbers in the following binary

More information

TETRIX Add-On Extensions. Encoder Programming Guide (ROBOTC )

TETRIX Add-On Extensions. Encoder Programming Guide (ROBOTC ) Introduction: In this extension, motor encoders will be added to the wheels of the Ranger Bot. The Ranger Bot with Encoders will be programmed to move forward until it detects an object, turn 90, and move

More information

EECS 427 RISC PROCESSOR

EECS 427 RISC PROCESSOR RISC PROCESSOR ISA FOR EECS 427 PROCESSOR ImmHi/ ImmLo/ OP Code Rdest OP Code Ext Rsrc Mnemonic Operands 15-12 11-8 7-4 3-0 Notes (* is Baseline) ADD Rsrc, Rdest 0000 Rdest 0101 Rsrc * ADDI Imm, Rdest

More information

CS2210: Compiler Construction. Runtime Environment

CS2210: Compiler Construction. Runtime Environment Compiler s Role in Program Execution When a program is invoked 0x8000000 The OS allocates memory for the program The code is loaded into the main memory Program initializes runtime environment Program

More information

Supporting Data Set Joins in BIRT

Supporting Data Set Joins in BIRT Supporting Data Set Joins in BIRT Design Specification Draft 1: Feb 13, 2006 Abstract This is the design specification of the BIRT Data Set Join feature. Document Revisions Version Date Description of

More information

C Compiler Targeting the Java Virtual Machine

C Compiler Targeting the Java Virtual Machine C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the

More information

CSC 2405: Computer Systems II

CSC 2405: Computer Systems II CSC 2405: Computer Systems II Spring 2013 (TR 8:30-9:45 in G86) Mirela Damian http://www.csc.villanova.edu/~mdamian/csc2405/ Introductions Mirela Damian Room 167A in the Mendel Science Building mirela.damian@villanova.edu

More information

Analysis of Binary Search algorithm and Selection Sort algorithm

Analysis of Binary Search algorithm and Selection Sort algorithm Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to

More information

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015 CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Today Registration should be done. Homework 1 due 11:59 pm next Wednesday, January 14 Review math essential

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Recursion. Slides. Programming in C++ Computer Science Dept Va Tech Aug., 2001. 1995-2001 Barnette ND, McQuain WD

Recursion. Slides. Programming in C++ Computer Science Dept Va Tech Aug., 2001. 1995-2001 Barnette ND, McQuain WD 1 Slides 1. Table of Contents 2. Definitions 3. Simple 4. Recursive Execution Trace 5. Attributes 6. Recursive Array Summation 7. Recursive Array Summation Trace 8. Coding Recursively 9. Recursive Design

More information

2) Write in detail the issues in the design of code generator.

2) Write in detail the issues in the design of code generator. COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage

More information

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC Chapter 2 Topics 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC See Appendix C for Assembly language information. 2.4

More information

Analysis of a Search Algorithm

Analysis of a Search Algorithm CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

Part 1 Foundations of object orientation

Part 1 Foundations of object orientation OFWJ_C01.QXD 2/3/06 2:14 pm Page 1 Part 1 Foundations of object orientation OFWJ_C01.QXD 2/3/06 2:14 pm Page 2 1 OFWJ_C01.QXD 2/3/06 2:14 pm Page 3 CHAPTER 1 Objects and classes Main concepts discussed

More information

1 Description of The Simpletron

1 Description of The Simpletron Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

More information

Recursion vs. Iteration Eliminating Recursion

Recursion vs. Iteration Eliminating Recursion Recursion vs. Iteration Eliminating Recursion continued CS 311 Data Structures and Algorithms Lecture Slides Monday, February 16, 2009 Glenn G. Chappell Department of Computer Science University of Alaska

More information

Solutions. Solution 4.1. 4.1.1 The values of the signals are as follows:

Solutions. Solution 4.1. 4.1.1 The values of the signals are as follows: 4 Solutions Solution 4.1 4.1.1 The values of the signals are as follows: RegWrite MemRead ALUMux MemWrite ALUOp RegMux Branch a. 1 0 0 (Reg) 0 Add 1 (ALU) 0 b. 1 1 1 (Imm) 0 Add 1 (Mem) 0 ALUMux is the

More information

Fall 2006 CS/ECE 333 Lab 1 Programming in SRC Assembly

Fall 2006 CS/ECE 333 Lab 1 Programming in SRC Assembly Lab Objectives: Fall 2006 CS/ECE 333 Lab 1 Programming in SRC Assembly 1. How to assemble an assembly language program for the SRC using the SRC assembler. 2. How to simulate and debug programs using the

More information

Computer organization

Computer organization Computer organization Computer design an application of digital logic design procedures Computer = processing unit + memory system Processing unit = control + datapath Control = finite state machine inputs

More information

Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362

Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362 PURDUE UNIVERSITY Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362 Course Staff 1/31/2012 1 Introduction This tutorial is made to help the student use C language

More information

MECH 896 Professional Development for MEng Students. Homework Discussion. Scheduling Overview. Winter 2015: Lecture #5 Project Time Management

MECH 896 Professional Development for MEng Students. Homework Discussion. Scheduling Overview. Winter 2015: Lecture #5 Project Time Management MECH 896 Professional Development for MEng Students Mohamed Hefny and Brian Surgenor (hefny@cs.queensu.ca and surgenor@me.queensu.ca) Winter : Lecture # Project Time Management Homework Discussion Homework

More information

1 The Java Virtual Machine

1 The Java Virtual Machine 1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This

More information

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway Abstract High Level Languages (HLLs) are rapidly becoming the standard

More information

6. Control Structures

6. Control Structures - 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,

More information

Bi-8: Introduction to Molecular Biology by Prof. Angela Stathopoulos

Bi-8: Introduction to Molecular Biology by Prof. Angela Stathopoulos Division of Biology, California Institute of Technology Bi-8: Introduction to Molecular Biology by Prof. Angela Stathopoulos January-March, 2009 Tuesdays and Thursdays, from 1-2 pm, Kerckhoff 119 Recitation

More information

Calling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference?

Calling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference? Functions in C++ Let s take a look at an example declaration: Lecture 2 long factorial(int n) Functions The declaration above has the following meaning: The return type is long That means the function

More information

The Little Man Computer

The Little Man Computer The Little Man Computer The Little Man Computer - an instructional model of von Neuman computer architecture John von Neuman (1903-1957) and Alan Turing (1912-1954) each independently laid foundation for

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

Stacks. Linear data structures

Stacks. Linear data structures Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

More information

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis 1 1 Table of Contents 1 Table of Contents... 3 2 Overview... 5 3 Installation... 7 4 The CPU

More information

X86-64 Architecture Guide

X86-64 Architecture Guide X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int

More information

How To Write An Array In A Microsoft Zil

How To Write An Array In A Microsoft Zil Array Declaration and Storage Allocation The first step is to reserve sufficient space for the array: 1.data list:.space 1000 # reserves a block of 1000 bytes This yields a contiguous block of bytes of

More information

EC 362 Problem Set #2

EC 362 Problem Set #2 EC 362 Problem Set #2 1) Using Single Precision IEEE 754, what is FF28 0000? 2) Suppose the fraction enhanced of a processor is 40% and the speedup of the enhancement was tenfold. What is the overall speedup?

More information

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct Dr. Martin O. Steinhauser University of Basel Graduate Lecture Spring Semester 2014 Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct Friday, 7 th March

More information

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08 CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code

More information

EXERCISES FROM HULL S BOOK

EXERCISES FROM HULL S BOOK EXERCISES FROM HULL S BOOK 1. Three put options on a stock have the same expiration date, and strike prices of $55, $60, and $65. The market price are $3, $5, and $8, respectively. Explain how a butter

More information

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com CSCI-UA.0201-003 Computer Systems Organization Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified)

More information

Notetaking Accommodations

Notetaking Accommodations Notetaking Accommodations Based on documentation of disability, Disability Services will determine on a case- by- case/course- by- course basis the use of notetakers as an appropriate accommodation. Students

More information