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

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

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

ECE2049: Homework 1. Consider the following code to compute the average of your exam grades: #define NUM_EXAMS (3)

ECE2049: Homework 1. Due: Thursday, 25 May 2017 by 7pm

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

ECE2049-E17 Lecture 6 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

ECE2049: Embedded Systems in Engineering Design Lab Exercise #3 C Term Making a Time and Temperature Display

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17, MSP430F5529 Launchpad User's Guide

ECE2049 E17 Lecture 2: Data Representations & C Programming Basics

Computer Systems Programming. Practice Midterm. Name:

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

Byte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

ECE2049 Embedded Computing in Engineering Design. Lab #0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

Time (self-scheduled): Location Schedule Your Exam: What to bring:

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17

Byte Ordering. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

World Inside a Computer is Binary

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

SIGNED AND UNSIGNED SYSTEMS

LING 388: Computers and Language. Lecture 5

UNIT 7A Data Representation: Numbers and Text. Digital Data

COMP2611: Computer Organization. Data Representation

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

C Programming Language. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

COMP2121: Microprocessors and Interfacing. Number Systems

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

CHAPTER 5 VARIABLES AND OTHER BASIC ELEMENTS IN JAVA PROGRAMS

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name: ID:

ECE2049 Homework #4 Analog-to-Digital Conversion and the ADC12 (Due Thursday 2/15/2018 to box outside AK-011 by 9 am)

(Refer Slide Time: 00:23)

17. Instruction Sets: Characteristics and Functions

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

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

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

EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

EE 109 Unit 2. Binary Representation Systems

Do not start the test until instructed to do so!

The type of all data used in a C++ program must be specified

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.

Binary Representations and Arithmetic

Copy: IF THE PROGRAM or OUTPUT is Copied, then both will have grade zero.

Introduction to Computers and Programming. Numeric Values

MICROPROCESSORS A (17.383) Fall Lecture Outline

N.B. These pastpapers may rely on the knowledge gained from the previous chapters.

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

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

Midterm Exam Answers Instructor: Randy Shepherd CSCI-UA.0201 Spring 2017

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04

Lab 03 - x86-64: atoi

CpSc 1111 Lab 4 Formatting and Flow Control

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

CS16 Exam #1 7/17/ Minutes 100 Points total

M1 Computers and Data

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Few reminders and demos

Integers II. CSE 351 Autumn 2018

Question 4: a. We want to store a binary encoding of the 150 original Pokemon. How many bits do we need to use?

University of California, Berkeley College of Engineering

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Chapter 2 Bits, Data Types, and Operations

Bits and Bytes January 13, 2005

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #7: More Digital IO

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

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

Representation of Information

Chapter 2 Bits, Data Types, and Operations

Arithmetic and Bitwise Operations on Binary Data

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

HW2: MIPS ISA Profs. Daniel A. Menasce, Yutao Zhong, and Duane King Fall 2017 Department of Computer Science George Mason University

Variables and Data Representation

University of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza

Week 3 Lecture 2. Types Constants and Variables

CS-211 Fall 2017 Test 1 Version A Oct. 2, Name:

Overview. ELEC2041 Microprocessors and Interfacing. Lecture 7: Number Systems - II. March 2006.

The type of all data used in a C (or C++) program must be specified

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

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Chapter 2 Bits, Data Types, and Operations

Lesson 7. Reading and Writing a.k.a. Input and Output

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

: Principles of Imperative Computation Victor Adamchik. Practice Exam - I

Computer Organization & Systems Exam I Example Questions

Lab 2 EECE473 Computer Organization & Architecture University of Maine

These are reserved words of the C language. For example int, float, if, else, for, while etc.

Part 2,Number Systems Questions

mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut

Transcription:

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 1/19/2018 At the BEGINNING of class) Your homework should be neat and professional looking. You will loose points if your HW is not properly submitted (by properly I mean legible and stapled with a cover sheet including your ECE box number). Any code must be typed to be graded. Please, no papers with ripped or ruffly edges! Always review lecture notes and reading assignments before attempting the homework Show all of your work. No work = No points! Clearly indicate results. Always write neatly. The grader can not be expected to GUESS what you meant to do! Reading -- Davies Ch 1&2, class notes, see Useful Links Problem #1 (25 pts) a) How many times would each of the following loops actually iterate on the MSP430F5529? Explain your reasoning. (10 pts) Also, what are the values of kk, mm and inval (in decimal) at the start and end of the first loop and at the start and end of the final loop?? Note: Code does nothing useful. unsigned char count = 1; unsigned int inval, out, kk=1, mm=32767; while (kk > 0) inval = (mm + kk)/kk; out = myfunction(inval); mm /= 2; kk = kk << 1; ----------------------------------------------------------------- ii. What is the value of count in the last 3 loops while (count > 0) /* Do some things. */ count++;

b) Rewrite this code segment using a while loop and if else statements instead of the for loop and switch case statements. Note: The functions alphatouchpad() and led_on() are NOT one from our demo lab. (5 pts) unsigned char trial, tp_history[175];... for (trial = 0; trial < 175; trial++) tp = alphatouchpad(); // returns letter A-E for touch pad tp_history[trial] = tp; switch (tp) case 'A': led_on(0); case 'B': led_on(1); case 'C': led_on(2); case 'D': led_on(3); case 'E': led_on(4); default: led_all_off(); c) In the real world, the data collected from a sensor like a pressure sensor or a temperature sensor or a microphone are often noisy. That is, a single reading is often not reliable. Often the readings over time will be smoothed or averaged usually using an exponential averager. Assume we have an array of raw data points. If r[n] = raw data and we define 0<α<1 then a[n]=(1 α)r[n]+α a[n 1] = exponential average Write a complete C program that does the following. In main(), declare 2 arrays, one for the raw data and one for the exponential averages, and fill the raw data array with 400 random integers with values between -1000 and 500 exclusive (Hint: In this case you may use the C library function rand() random number generator to help generate the data). Use a compiler directive to define α as a constant equal to 0.9. Write code (within main) to form the exponential average of the data your r[] array storing the the results in the a[] array. How will you handle the first points in your average?

Problem #2 (15 pts) a) Express the following numbers as 16 bit unsigned integers 3005, 48010, 99. Show all your work. b) Express the following number as 16 bit signed (two's complement) integers -4, 9000, -32762. Show all your work. You are given the following 16-bit numbers 1B0Ch, A006h, and 800Dh. Each of these values could be interpreted as c. An unsigned number d. A sign-magnitude number e. A two's-complement number. Provide the base 10 equivalent of each value assuming each of these interpretations. Show all your work. Problem #3 (10 pts) a) Assume that the variable X is encoded in BCD. What is the decimal equivalent value of X if X = 0010011101011000b? b) Express the base 10 integer Y = 89506132 in BCD? Problem #4 (10 pts) a) What are the ASCII codes (in hex) for the characters '0', '1', '2', '3'.'9'? b) In lab you will regularly need to display numbers on the LCD screen. Therefore you will need to convert between integer digits and their ASCII representations and the reverse. What C code (variable declarations and 1 line of code) would you use convert a single decimal digit to its ASCII code? c) Assume the integer value D = 28531 has been converted for display into an array of ASCII values, declared as char D_asc[8]; What value (in hex) should stored in each array location so that the number would display properly (i.e. right justified with digits in left to right order) if printed on our Sharp LCD screen? Explain you reasoning. Hint: Check the Lab 0 demo code. D_asc[7] = D_asc[3] = D_asc[2] = D_asc[1] = D_asc[0] =

Problem #5 (25 pts) Convert the following numbers from decimal to IEEE 32-BIT floating point format. a) 28.5d b) -8.6d c) -21.38911 The following numbers are encoded using 32-bit IEEE floating point format. Find the decimal values that they represent. Problem #6 (15 pts) d) 44C40000h e) E0858000h In a table like the one below, show how the following variables would stored successively in memory by (a) a Little-endian microprocessor (b) a Big-endian microprocessor Show the values in hex (not binary) starting at address 02000 h. That is, variable ser_num is stored beginning at address 02000h. Label each address in your table. Remember each address in memory holds 1 byte. Is the MSP430F5529 big or little endian? // an unsigned 64-bit integer long long unsigned int ser_num = OxF53EDFCB9CB600A4; float ss = 28.5; // IEEE 32-bit floating pt (see 5a) char str[4] = Ack: ; // array of ASCII text // (No NULL terminator) int mm = -4; // a two's comp 16 bit integer (see 2b) long unsigned int pin = 131072; int arr[2] = -1, 32767; // 2 element array of integers Address Big Endian Little Endian... 02002 h 02001 h 02000 h

ECE2049 Homework #1 Submitted by: ECE Box #: << Be sure to include!! Date: Question 1-- 25 2 -- 15 3 -- 10 4 -- 10 5 -- 25 6 15 Total: 100 Grade YOU MUST ATTACH THIS COVER SHEET TO YOUR HW!!