CSC201, SECTION 002, Fall 2000: Homework Assignment #1

Similar documents
CSC201, SECTION 002, Fall 2000: Homework Assignment #2

CSC201, SECTION 002, Fall 2000: Homework Assignment #3

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 1/19/2018 At the BEGINNING of class)

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

You must pass the final exam to pass the course.

ECE2049 HW #1-- C programming and Binary Number Representations (DUE Friday 8/31/2018 At the BEGINNING of class)

Microcomputer Architecture..Second Year (Sem.2).Lecture(2) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات

Macros in Pentium. Assembly Language. October 25

Assembly Language LAB

Programming language components

Variables, Data Types, and Arithmetic Expressions Learning Objectives:

Xosdev Chapter 1 [The Bootloader] by mr. xsism

Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 2 Assembly Language Fundamentals

Comp 11 Lectures. Mike Shah. June 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures June 26, / 57

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

EEM336 Microprocessors I. Data Movement Instructions

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 9/1/2017 At the BEGINNING of class)

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

Intro. Scheme Basics. scm> 5 5. scm>

ELEC 242 Time Delay Procedure

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

CS50 Supersection (for those less comfortable)

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

CC411: Introduction To Microprocessors

Lecture 9. INC and DEC. INC/DEC Examples ADD. Arithmetic Operations Overflow Multiply and Divide

Assembly Language Lab # 4 Data Transfer & Arithmetic (1)

assembler Machine Code Object Files linker Executable File

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

ECE 463/521: Fall 2002 Project #1: Data-Cache System Design Due: Monday, Sept. 30, 11:00 PM

CS2630: Computer Organization Project 2, part 1 Register file and ALU for MIPS processor

CSE 5A Introduction to Programming I (C) Homework 4

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 1: Assembly Language Terms & Directives

Intel Architecture Segment:Offset Memory Addressing

By: Dalbir Singh, Computer Science Dep't

The statement above assumes that the PCMAC.INC file is in the current directory. The full path of the file can also be given:

MySQL: an application

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Operating Systems. Objective

Bits and Bytes. Here is a sort of glossary of computer buzzwords you will encounter in computer use:

Operating Systems. Project #2: System Calls

Important Project Dates

EL2310 Scientific Programming

Basic Assembly SYSC-3006

17. Instruction Sets: Characteristics and Functions

First Java Program - Output to the Screen

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Exercise: Inventing Language

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

CS1 Lecture 3 Jan. 18, 2019

Data Types Literals, Variables & Constants

How to write an assembly language program.

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

Transfer of Control. Lecture 10 JMP. JMP Formats. Jump Loop Homework 3 Outputting prompts Reading single characters

CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

CS2630: Computer Organization Project 2, part 1 Register file and ALU for MIPS processor Due July 25, 2017, 11:59pm

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

BASIC ELEMENTS OF A COMPUTER PROGRAM

ECE2049 E17 Lecture 2: Data Representations & C Programming Basics

Carnegie Mellon University Database Applications Fall 2009, Faloutsos Assignment 5: Indexing (DB-internals) Due: 10/8, 1:30pm, only

Parts A and B both refer to the C-code and 6-instruction processor equivalent assembly shown below:

There are functions to handle strings, so we will see the notion of functions itself in little a detail later. (Refer Slide Time: 00:12)

ELEC 242 Using Library Procedures

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

Understand the factors involved in instruction set

CSC-105 Exam #1 October 10, 2013

CS61C Machine Structures. Lecture 13 - MIPS Instruction Representation I. 9/26/2007 John Wawrzynek. www-inst.eecs.berkeley.

CSCI-1200 Data Structures Fall 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

Under the Hood: Data Representations, Memory and Bit Operations. Computer Science 104 Lecture 3

Solve only 2 out of 3 questions

INTRODUCTION TO MICROPROCESSORS

Important From Last Time

Arrays. Lecture 9 COP 3014 Fall October 16, 2017

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

CSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic

CSC258: Computer Organization. Memory Systems

MITOCW watch?v=se4p7ivcune

Today s class. Operating System Machine Level. Informationsteknologi. Friday, November 16, 2007 Computer Architecture I - Class 12 1

COMP 105 Homework: Type Systems

Java Programming. Computer Science 112

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

Assembly Language. Dr. Esam Al_Qaralleh CE Department Princess Sumaya University for Technology. Overview of Assembly Language

EC 333 Microprocessor and Interfacing Techniques (3+1)

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

How Computers Work. Processor and Main Memory. Roger Young

First Visual Basic Lab Paycheck-V1.0

Today s lecture is all about the System Unit, the Motherboard, and the Central Processing Unit, Oh My!

EE 314 Spring 2003 Microprocessor Systems

Pointers in C/C++ 1 Memory Addresses 2

Please refer to the turn-in procedure document on the website for instructions on the turn-in procedure.

Homework #3 CS2255 Fall 2012

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals.

Assembly Fundamentals

Transcription:

1 of 6 11/8/2003 7:34 PM CSC201, SECTION 002, Fall 2000: Homework Assignment #1 DUE DATE Monday, September 11, at the start of class. INSTRUCTIONS FOR PREPARATION Neat, in order, answers easy to find. Staple the pages together at the upper left corner. Fold lengthwise. On the outside write the course number, the assignment number, the date, and your name. Thanks for your help. PROBLEMS (2) (4) If someone tells you about a fancy new set of instructions that their processor implements, are they talking about computer organization, architecture, or design? If someone shows you a detailed diagram of how the ALU on their processor is built, are they talking about computer organization, architecture, or design? If processor performance keeps improving at a rate of 50% / year, how long will it take before processors are 10 times more powerful than they are today? If disk prices keep dropping by 40% / year and a gigabyte costs approximately $10 today, how long will it be before a gigabyte costs $1? 3. (4) How much faster is a Pentium II than the 80386 of 10 years ago (based purely on clock speed), and how much more complex is a Pentium II than an 80386 (based purely on transistor count)? 4. (2) Why do you think there are there multiple buses in a computer system (i.e., why isn't there just one set of wires that connects everything together)?

2 of 6 11/8/2003 7:34 PM 5. (6) If a memory system is byte-addressable, and the memory has n address lines, how big (in bytes) is the maximum addressable size of the memory if n is: 16 24 3. 32 6. (2) What is an example of something that might be stored in a ROM of a computer system? 7. (4) Suppose the instruction cycle takes 5 ticks of the clock, 1 tick for each of the 5 steps. How long does it take to execute 100 instructions if they are not overlapped (i.e., one instruction goes through all 5 steps before the next instruction is begun)? Suppose instruction execution is overlapped, so that every clock tick a new instruction is started (i.e., instruction 1 begins on the first clock tick and ends on the fifth clock tick; instruction 2 begins on the second clock tick and ends on the sixth clock tick; etc.). How many clock ticks does it take to execute 100 instructions to completion under this assumption? 8. (6) Below is a SASM program with five errors (syntax errors, or necessary things that are missing). Identify the errors..486 /* use the Intel 486 instruction set */.model flat, stdcall.stack 1000h include sasmacros.inc title hello program ;;; this file defines the SASM instructions.data num1 dd 1234h num2 dd 5678 string1 db Hello, world!, 0ah, 0dh, 0.code add num1, num2 put_i num1 ; put_i num2 put_str string1 end 9. (6) Which of the following are reserved words which you should not use as labels in your programs? bnqz bx 3. bound 4. else 5. groups 6. if 7. mom 8. pop 9. rash

3 of 6 11/8/2003 7:34 PM 10. sp2 1 while 1 whynot 10. (8) Write the data definition statements (DB or DD) that define the following variables: a byte-sized integer labeled "var1" with no specific initial value a doubleword-sized integer labeled "var2" with initial value of -258 3. a doubleword-sized floating-point (real) number labeled "var3" with value -.02681 4. a null-terminated character string labeled "var4" with value equal to the last 4 letters of the alphabet (all lower case; do not include any carriage return or newline characters) 5. a null-terminated character string labeled "var5" with value equal to the digits 1 through 3, followed by the newline (0ah) and carriage return (odh) characters, followed by the digits 4 through 8, followed by the carriage return and newline characters (and then null-terminated) 6. an array of 8 byte-sized integers labeled "arr1", all initialized to 0 7. an array of 100 character strings, each of length 5, and each with value "abcd", 0 (i.e., each is null terminated) 1 (4) For each of the following questions, assume that a, b, and c are doubleword-sized integers, with initial values 10, 25, and -4 (respectively) what is the value of b after executing the instruction "mov b, c"? what is the value of a after executing the instruction "iadd b, a"? 3. what is the value of b after executing the instruction "irem b, c"? 1 13. 14. (6) Which of the following are "legal" arithmetic instructions? Assume that a and b are doubleword-sized integers, while x and y are doubleword-sized floating point numbers. iadd a, 25 isub b, 3.14159 3. fpmult x, 35.1e-8 4. ineg b 5. fpadd x, a 6. imult 25, a (4) What value will the condition codes (SF and ZF) have after executing each of the instructions below? Assume for each problem that the doubleword-sized integers g and h are initialized to 35 and 6, respectively. iadd g, h isub h, h 3. compare h, g 4. irem h, g (4) What value will a have after executing the instruction "irem a, b", if the doubleword-sized integers a and b have the initial values shown? a = 100, b = 7 a = -100, b = -7

4 of 6 11/8/2003 7:34 PM 15. (6) For each of the expressions shown below, write the code to evaluate the expression. All a + (b - c) (w * x) + (y / z) 3. e + f * g - 3 16. (6) What will be the result of executing each of the following instructions? Assume the variables are initialized before each problem as follows: a db? b db 'b' c db '001234', 0ah, 0dh, 0 d dw 001234 x dd 3.14159 3. 4. 5. 6. get_ch a put_ch c put_str c put_fp x put_i c put_i d 17. 18. (8) Write the code to implement the following C language statements. Assume all variables are doubleword-sized integers, except for j and k, which are byte-sized integers. 3. 4. if (a == b) c = 3; if (j < k) d = e; if ((w > x) (y == z)) x = x + 1; if ((z < 3) &&!(y == 5)) z = x - y; (6) Write the SASM code to implement the following C language statements. Assume all if (a == b) c = 2; else c = 3; if (x == y) c = 2; else if (w < z) c = 3; 19. (6) Write the SASM code to implement the following C language statements. Assume all while (1) { a = a + 1; c = c / 2; while (a > 15) { d = d + e;

5 of 6 11/8/2003 7:34 PM a = a - d; 20. (6) Write the SASM code to implement the following C language statements. Assume all for (i = 0; i < 10; i++) { putc(c); for (j = b; j > 0; j = j / 2) { a = a * 3; PROGRAMMING In class we will review how to use the Microsoft programming tools. Things to remember: Create a directory with nothing in it except your Assembly Language program file. Copy the sample makefile, and sasmacros.inc, into this directory. Suppose you call this file "hw1a.asm". Do NOT name your makefile "hw1a.mak"; name it something else, like "test.mak". You will need to edit the makefile so that all references to a program name are "hw1a". It's also not a bad idea to give your program the title "hw1a" in the assembly language file. Start up Visual C/C++. Once running Visual C++, you want to OPEN the file test.mak (or whatever you called your makefile). You'll need to find the directory (folder) where you put the files. In the right directory, list files of type All Files, and open as type AUTO (the default). You will get a dialog box that says something to the point that this make file was not generated by the Developer's Studio, and continuing will "wrap" the makefile. You want to "wrap" this make file, so click on YES. You will get another dialog box that assigns the Win32 platform. Click on OK. When it asks what you want to save this as, type "hw1a.dsp". You are now ready to work on the assembly language program. If you want, OPEN the file hw1a.asm as type AUTO (the default), to see what is in it. Before you can execute (run) a program, you need to assemble and link the program. (This is similar to when you compiled a C++ program.) Your makefile together with the Visual C++ tool will do this for you. To do this, under BUILD, do either BUILD ALL or BUILD hw1a.exe. You will see a window pop up that tells you what is being built, and if there were errors, you would see them here. If there were errors, then you would iterate on the steps of modifying your source code (the file with the.asm extension), save the file, and again BUILD, until your program makes it through the build with no errors and no warnings. At this point, you can execute the program. Do this by choosing EXECUTE hw1a.exe under the BUILD menu. I encourage you to use the source debugging tool to see what your program is doing during execution. You may choose instead simply to use print statements to output the state of variables in your program; in this case, you do not need to use Visual Studio for executing

6 of 6 11/8/2003 7:34 PM or debugging your program. (50) Write a SASM program (named "hw1a.asm") that outputs the message "Enter two 2-digit decimal numbers, each followed by a carriage return", then allows a user to type in two numbers and outputs the message A is greater than B where A is the larger of the two numbers. Some additional constraints: each of the two numbers entered by the user will be two decimal digits long, followed by a carriage return typed by the user. Any messages output by your program should end with newline and carriage return characters (0ah and 0dh, respectively). Your program ends normally after outputting the messages shown above. I will give instructions for submitting your program electronically at a later time. WARNING! Keep all your program files strictly in your EOS locker space, with no access given to other users. Do not put your files on the local machine, such as in temp space! If you do, you are inviting someone else to use your code, since files on the local PC file system are not protected. GRADING This homework is graded on a scale of 150 points; the points for each problem are shown above. The homework score will be weighted to contribute 5% of your course grade. Problems will be graded according to the following interpretation: All right = full credit halfway to mostly right = half credit Not much or none right = no credit