Embedded Systems - FS 2018

Size: px
Start display at page:

Download "Embedded Systems - FS 2018"

Transcription

1 Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Lab 0 Date : Prelab Filling the gaps Goals of this Lab You are expected to be already familiar with C programming. If not, your are strongly invited to carefully read through the C Programming Crash Course part of the Embedded System Companion 1. You will need basic C knowledge to succefully go through the labs. The goal of this Prelab is to cover the additional background necessary for the forthcoming Embedded Systems labs. The first part of the lab is a crash course on the following topics: Numeral systems C operators Ordering and Endianness Overflows Generics types The second part of the lab is set of short programming tasks designed to highlight the specific problems and pitfalls one may fall into when working with embedded systems. Once you will have completed these tasks, you will be good to go for the rest of the labs! 1 C programming for embedded systems Warning 1: Basic C programming You should be already familiar with C programming. If not, your are strongly invited to have a look at the C Programming Crash Course a. You will need basic C knowledge to succefully go through the labs. a Task 1: Warm-up In programming (like for many things) it is important to be precise with the terms one uses, otherwise it is difficult to understand one another. As a warm-up, let s have a look at the simplest C program one can write: HelloWorld.c 1 1

2 1 # include <stdio.h> 2 # include < stdlib.h> 3 4 int main () 5 { 6 printf (" Hello world!\ n"); 7 return 0; 8 } Clicker Questions #1 Which lines the lines in this program that are (a) processor instructions? (b) preprocessor directives? (c) function prototypes? (d) part of a function definition? Many embedded system programmers use C. Once again, you should be generaly familiar with the language (if not, go read up the C Programming Crash Course 2!). However, embedded system programmeing also requires some low-level features of C which you may not know. The rest of this section gives a quick overview of what you should know. Some clicker questions at the end will verify that you understand the main concepts. 1.1 Numeral systems A number can be represented in different numeral systems, corresponding to different bases (i.e., the number of different symbols usable). In embedded system programming, three systems are used: binary, decimal, and hexadecimal. Table 1: Main numberal systems for embedded programming Numeral system Base Symbols Interpretation of 11 Binary Decimal Hexadecimal a b c d e f 17 The binary symbols (0 and 1) are also called bits. Recap 1: Bits and Symbols All numeral systems work similarly. Each symbol correspond to a power of the base. The symbol s value is a multiplication factor. For example with an arbitrary base b: 153 b = 3 b b b

3 In the decimal format, when reading 153, you interpret it as This is base 10. It works exactly the same for the hexadecimal and binary systems = = = = = = 9 In C, one can use any of those systems to work on numbers, as long as you inform the compiler with a header before the number: 0x for hexadecimal, 0b for binary. Without precision, all numbers are interpreted as decimal. 1 /* Equivalent definitions of the same number */ 2 int mynumber = 339; // mynumber in decimal 3 int mynumber = 0 x153 ; // mynumber in hexedecimal 4 int mynumber = 0 b ; // mynumber in binary Why can t we just use decimal? Computers only understand 0 and 1. Therefore, binary is the natural numberal system of a computer. Moreover, embedded systems programmers often have to work at the bit-level (e.g., when dealing with registers). In practice, you may have a 8-bit register connected to GPIO pins. To set the third pin to high, one must set the register equal to an integer value such that, in binary, the third bit equals 1. We will practice this in Task 5. Relation between binary and hexadecimal The hexadeximal system is extreamly common in programming, for a simple reason: it is compact, converts easily to binary and is easier to read. The idea is simple. One hexadecimal symbol can take 16 different values (from 0 to 15), which is the same as a 4-symbol binary number. For example in decimal b x 4 d 6 f 0b = 0x4d6f Thus, two hexadecimal symbols encode one Byte, i.e., 8 bits. 1.2 Ordering consideration Most and least significant bits The most significant bit (MSB) is the bit of a binary number having the greatest value (which depends on the number of bits: (2 N 1 for a N-bit number), i.e., the left-most one. Conversely, the least significant bit (LSB) is the bit of a binary number having the smallest value, which is always 1, i.e., the right-most one. 1 // 0b 2 // ^ ^ 3 // MSB LSB Endianness The endianness refers to the sequential order in which Bytes are arranged into larger numerical values when stored in memory or when transmitted (over a bus, the radio, etc.). In big-endian format, the most significant Byte (i.e., the Byte containing the MSB) is stored/sent first. In little-endian format, the most significant Byte (i.e., the Byte containing the LSB) is stored/sent first. 3

4 1.3 Generic integer types The C programming language provides four different data types, e.g., char (for characters), int (for integers), float and double (for fractionals). These types can be either signed or unsigned. A variable can contain any number within a range that depends on the number of bits reserved in memory for this variable. For example, with 8 bits, one can store any number within [0, 255] for an unsigned integer or [ 127, +127] for a signed one. In C, the number of bits used to encode interger types is not fixed. This varies between implementations (e.g., depending on the platform or the CPU). The problem is that when you declare an int variable in C, it is not clear how many bits are then reserved in memory. Thus, if you run the same program on different platforms, the size on an int can change, which may lead e.g., to overflows. To avoid this problem, embedded programmers use generic integer types (also called fixed-width intergers). The idea is simple: the type uintn_t is used to store an unsigned interger number encoded with N bits. N can generally be 8, 16, 32, or 64. The following table summarizes these types and their value range. Table 2: Ranges of 8, 16, and 32-bits fixed-width interger types Unsigned types Signed types Type Min value Max value Type Min value Max value uint8_t int8_t uint16_t int16_t uint32_t int32_t Recap 2: Standart Integer library These generic types are defined in the stdint.h library. Don t forget to include it in your project, or the compiler will complain! 1.4 C Operators The C language provides a wide range of operators that you should know about. Arithmetic operators Addition (+) substraction (-) multiplication (*) division (/) and modulo (%). Recap 3: Integer division and modulo In normal calculation, 9/4 = However, in C, the result is 2. This is because the result of an operation on integers in also an integer. The compiler neglects the term after the decimal point. The modulo operator (%) computes the remainder. If a = 9 is divided by b = 4, the remainder is 1 (i.e., a%b = 1). The modulo operator can only be used with integers. Increment and Decrement A short-hand notation; e.g., a = a+1 and a + + are equivalent. Assignment operators Another short-hand notation (see Table 3). 4

5 Table 3: C Assignment Operators Operator Example Same as = a = b a = b += a += b a = a+b -= a -= b a = a-b *= a *= b a = a*b /= a /= b a = a/b %= a %= b a = a%b Tests Equal (==) Greater (>) Greater or equal (>=) Not equal (!=) Smaller (<) Smaller or equal (<=) Logical operators Logical AND (&&), OR ( ) and NOT (!) Bitwise operators Bitwise AND (&), OR ( ), XOR ( ) and complement ( ) See Snippet 1 Warning 2: Logical vs Bitwise Operators It is really important to understand the difference between logical and bitwise operators! A logical operator is global and returns a binary result (0 or 1). A bitwise operator operates on each bit individually and returns an integer (see Snippet 1) = ( In Binary ) 3 25 = ( In Binary ) Bitwise AND Operation of 12 and 25 Bitwise OR Operation of 12 and & = 8 ( In decimal ) = 29 ( In decimal ) Bitwise XOR Operation of 12 and 25 Bitwise complement Operation of ^ ~ = 21 ( In decimal ) = 243 ( In decimal ) Snippet 1: Example of bitwise operators Left- and right-shift The left- and right-shift operators (< < and > > respectively) shifts all bits by certain number of bits. It is rather easy to understand with examples: = // ( In binary ) > >2 = // ( In binary ) [ Right - shift by two bits ] > >7 = // ( In binary ) > >8 = // > >0 = // ( No Shift ) = // ( In binary ) < <1 = // ( In binary ) [ Left - shift by one bit ] < <0 = // ( Shift by 0) < <4 = // ( In binary ) = 3392 ( In decimal ) 5

6 Note that, as shown in the last example, a left-shift can lead to increase the number of bits. However, keep in mind that this may happen only if there are room left in memory. Consider the following example: 1 uint8_t b = 255 ; // b = ( In binary ) 2 printf ("%u\n", b); // Prints : printf ("% u\ n", b << 4); // Creates a temporary variable of 12 bits and prints it. 4 // -> Prints : b = b << 4 ; // Left - shifts and assigns back to b, which is 8- bit long. 7 // -> b = ( In binary ) 8 printf ("%u\n", b); // Prints : 240 In line 6, the bits of b are left-shifted by 4 bits then assigned back to b, which is only 8-bit long. Thus, only the least 8 bits are stored in b and eventually printed in line 8. Shifts are extreamly useful when one needs to work on specific bits, e.g., on registers, like in the following example. 1 REG = ( REG (0 x01 << 2 )); // Sets the third bit of REG to 1 2 // without modifying any of the other bits sizeof The sizeof operator returns the size of data (constant, variables, array, structure etc) in Bytes, as illustrate below. 1 struct student { // the structure name 2 char name [80]; // first variable : an array of characters 3 float size ; // second variable : an decimal value 4 int8_t age ; // third variable : an integer 5 }; 6 printf ("%d bytes ",sizeof ( struct student )); // Prints 82 bytes 1.5 Variable overflow Standard computers dispose of plenty of memory and processing power. Contrarily, embedded systems are limited. It is therfore important to carefully choose the integer types one uses: storing a counter value expected to range between 0 and 10 in a uint64_t wastes a lot of memory! However, one must be carefull with overflows. A variable is said to overflow when it is assigned a value which is outside the range that its type can normally contain. For example, a uint8_t can contain any number between 0 and 255. What happens if you assign e.g., 300 to such variable? 1 uint8_t a = 300; // assign 300, even though the max value is printf ("%u", a); // Prints : 44 The problem is similar to the previous example with the left-shift: 300 requires 9 bits to be written in binary. As the variable a is only 8-bit long, only the least 8 bits of 300 will be assigned to a, that is , which is 44 in decimal; or put differently, 300%256. Be also careful with substractions on unsigned integers. Negative values are not defined! If you assign an negative value, the variable wraps-around, like in the following example. 1 uint8_t a = 0; 2 a - -; 3 printf ("%u", a); // Prints : 255 6

7 Clicker Questions #2 1. How is 0b0110 written in decimal? (a) 10 (b) 0d How is 0b1110 written in hexadecimal? (a) 0x0E (b) 0x10 3. How is 0xC written in binary? (a) 0b1010 (b) 0b How is 0xD3 written in binary? (a) 0b (b) 0b What is the output of the printf instruction (line 8)? 1 int main () 2 { 3 uint8_t counter = 10; 4 /* 5 * Some code... 6 */ 7 reset ( counter ); 8 printf ("%u", counter ); 9 10 return 0; 11 } 12 void reset ( uint8_t x) 13 { 14 x = 0; 15 } (c) 6 (d) 42 (c) 0xE (d) 0xF (c) 0b1100 (d) 0b1110 (c) 0b (d) 0b (a) 0 (b) What is the value of sizeof(int)? (a) 1 (b) 2 7. What is the value of sizeof(uint16_t)? (a) 1 (b) 2 8. Let us assume the following definition 1 uint16_t REG = 0 xc3 ; Which instructions lead to REG = 0b ? (a) REG = ( REG (0x01 > > 1)) (b) REG = ( REG (0x01 > > 1)) (c) 42 (d) Impossible to know (c) 16 (d) Impossible to know (c) 16 (d) Impossible to know (c) REG = ( REG (0x01 < < 1)) (d) REG = ( REG (0x01 < < 1)) 7

8 9. Consider the following program and select all correct statements among the following. 1 int main () 2 { 3 uint8_t * ptr ; 4 uint8_t x = 0; 5 ptr = &x; 6 7 printf ("%u", * ptr ); 8 printf ("%u", & ptr ); 9 printf ("%u", &x); return 0; 12 } (a) Line 7 prints the address of x. (b) Line 7 prints the value of x. (c) Line 7 prints the address of ptr. (d) Line 7 prints the value of prt. (e) Line 8 prints the address of x. (f) Line 8 prints the value of x. (g) Line 8 prints the address of ptr. (h) Line 8 prints the value of prt. (i) Line 9 prints the address of x. (j) Line 9 prints the value of x. (k) Line 9 prints the address of ptr. (l) Line 9 prints the value of prt. 8

9 2 Putting it to practice It is time to put all these notions into practice! We will start using the MSP-EXP432P401R LaunchPad Development Kit what you have been provided for the lecture. For now, you just need to know how to plug it in (see Figure 1). More details about what it is/what it contains will be given in Lab 1. Figure 1: A basic overview of the MSP-EXP432P401R LaunchPad Development Board (left) and connected to a laptop via USB (right). We use Code Composer Studio (CCS) as development environment. CCS can be started by typing ccstudio into a terminal. It allows easy integration of the LaunchPad, software, etc. Furthermore, it makes compiling of a whole project a one-click task by generating and executing the necessary makefiles, and features extensive debugging options (more details in the following labs). Task 2: Your first embedded system program Task 2.1: Flash your very first program! Download lab0.zip from the course website3. Open the CCS and import lab0.zip to your workspace (see Figure 4 in the Appendix). Connect the LaunchPad to the Computer. Build and flash the application (see Figure 5,6,7) Start the execution ( application? ) and observe the functionality of the program. What is the purpose of the Warning 3: Creating a delay within a program In this lab, we use an empty for-loop to create a delay. Note that this is not a good solution in practice. Timers should be used instead. We use this simple solution for now as timers will be later covered in Lab

10 Task 2.2: Track the number of toggling operations We provide you with a custom uart_println function which prints to a terminal on your PC. Use this function exactly as you would use the standard printf function in C. This task consists in modifying task_2.c to keep track of the program execution by using a counter. Recap 4: Print statement on embedded systems Why do we need a custom funstion to print? Monitoring the execution of an embedded program is a complex task (covered in more details in Lab 2). For example, the standard printf function cannot be used. Think about it this way: the target is laying on your desk, and calls printf; where does the printed string go? Stop the execution of the program ( ). Open task_2.c. Declare a counter (uint32_t type) and initialize it to 0. Within the while loop, after toggling Print out the counter value using the uart_println function. Increment the counter. Build and debug your program. Open a terminal in CCS to see your prints (see Figure 9, 11 and 10) then start the program execution. Observe the print statements in the terminal. It should look similar to Figure 2. Figure 2: Expected output of Task 2.2. Task 3: Adaptive toggling delay We now modify the value of the delay between successive togglings, until 25 toggling operations have been executed. The program then prints a task completed message. In main.c, comment out task_2 and uncomment task_3. Open task_3 and observe the code provided. Build and flash the application. Observe that the program never executes the task completed print statement. What is the problem? Correct the code to obtain the desired behavior. It should look similar to Figure 3. What is the effect of defining the delay variable as static? What would happen if we don t? 10

11 Figure 3: Expected output of Task 3. Task 4: Use your own function In this task, we encapsulate the increment and print of the counter value in a function called print_and_increment. Like in Task 3, the program must eventually exit the while loop and print the task completed message. In main.c, comment out task_3 and uncomment task_4. Open task_4 and observe the code provided. The prototype of the print_and_increment function is given (see line 40). Complete the definition of the function (starts at line 77) to implement the increment and print of the input argument (called value). Call your function in the while-loop at the placeholder. Rebuild, run, and observe the task completed print statement. The output must be similar as for Task 3 (see Figure 3). In line 40, replace your function prototype by the following 1 void print_and_increment ( uint32_t * value ); Rewrite your function implementation and the call in the while-loop such that the program behavior remains the same. What is the difference between the two function techniques? How are they called? Task 5: Taking control of the LEDs This task consists in changing which LEDs are toggling. We will do this by using an 8-bit unsigned integer called activeled. The MSP432 Lauchpad has 2 LEDs. One red LED (which we have been using so far) and a RGB LED. An RGB LED has three inputs which can be activated separately to get red, green, blue or any mix of these three colours. Setting bits of activeled high and low controls which of the red LED and the RGB LED inputs toggles. The mapping to the bits of activeled is described below. 1 /* 2 * Define activeled 3 * 4 * activeled : ( MSB ) ( LSB ) 5 * ** unused bits ** RGB_BLUE RGB_GREEN RGB_RED LED_RED 6 * 7 * Set the bits in activeled to toggle the corresponding LEDs 8 */ 9 // led

12 Task 5.1: Static setup of the toggling LEDs In main.c, comment out task_4 and uncomment task_5. Open task_5 and observe the code provided. Build and flash the application. What happens? Modify the value of activeled to toggle both the red LED and the red RGB LED simultaneously. Do this in four different ways: - Using a decimal number, e.g., activeled = 65; - Using a hexadecimal number, e.g., activeled = 0x0001; - Using a binary number, e.g., activeled = 0b ; - Using predified macros, e.g., activeled = LED_RED; (Hint: use bitwise operators) Warning 4 These are just examples! It won t produce the expected output... Modify the value of activeled to toggle all the LEDs at once (i.e., the RGB LED should appear white). What LEDs will toggle if you set activeled to 137? To 257? Try to predict then verify. Task 5.2: Dynamic LED toggling In this final task, the goal is to dynamically change the toggling LEDs depending on the value of the counter, following the specification in Table 4. For example, if counter = 10, 10%3=1 thus the LED_RED and RGB_GREEN should toggle. Table 4: Specification of the expected toggling parttern of the LEDs. (counter % 3) = LED_RED RGB_RED RGB_GREEN RGB_BLUE Modify the code in task_5.c (where indicated by the placeholders) to execute the desired toggling pattern. Try doing this in two different ways: Using conditions (e.g., if statements). Without conditions (e.g., using shift operators). 12

13 Appendix Figure 4: How to import a CCS project into your workspace in the CCS using the Import Wizard (File Import). If the source code should be copied to the workspace, the corresponding check mark has to be set. Figure 5: The standard view of the CCS. The button to build and start debugging a project is marked with a blue circle. 13

14 Figure 6: The debug view of the CCS. Figure 7: Control buttons for debugging in the CCS Debug View. From left to right: Start/Continue Execution, Pause Execution, Terminate Execution, Step In, Step Over, Step Out. 14

15 Figure 8: The context menu in CCS allows easy code browsing with searches (Declarations, References, Search Text) or other commands (i.e. Open Declaration). It opens by right-clicking a function or a variable. Alternatively, one can also use the sequence Ctrl+Left Click. Figure 9: To open the terminal view, go to View Terminal. 15

16 Figure 10: The terminal view opens in the lower right corner where a new terminal view can be opened. Figure 11: The menu opened after pressing the new terminal button allows the configuration of the serial connection. 16

Embedded Systems - FS 2018

Embedded Systems - FS 2018 Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Sample solution to Lab 0 Date : 28.2.2018 Prelab Filling the gaps Goals of this Lab You are expected

More information

Embedded Systems - FS 2018

Embedded Systems - FS 2018 Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Embedded System Companion Introduction As its name indicates, the Embedded System Companion has been

More information

Embedded Systems - FS 2018

Embedded Systems - FS 2018 Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Lab 1 Date : 14.3.2018 LaunchPad Basic Bare-Metal Programming Goals of this Lab Get to know the MSP-EXP432P401R

More information

Embedded Systems - FS 2018

Embedded Systems - FS 2018 Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Sample solution to Lab 1 Date : 14.3.2018 LaunchPad Basic Bare-Metal Programming Goals of this Lab

More information

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version: SISTEMI EMBEDDED The C Pre-processor Fixed-size integer types Bit Manipulation Federico Baronti Last version: 20180312 The C PreProcessor CPP (1) CPP is a program called by the compiler that processes

More information

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators CSE 351: The Hardware/Software Interface Section 2 Integer representations, two s complement, and bitwise operators Integer representations In addition to decimal notation, it s important to be able to

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

OBJECT ORIENTED PROGRAMMING

OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING LAB 1 REVIEW THE STRUCTURE OF A C/C++ PROGRAM. TESTING PROGRAMMING SKILLS. COMPARISON BETWEEN PROCEDURAL PROGRAMMING AND OBJECT ORIENTED PROGRAMMING Course basics The Object

More information

CS Programming In C

CS Programming In C CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs

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

ECE2049 E17 Lecture 2: Data Representations & C Programming Basics

ECE2049 E17 Lecture 2: Data Representations & C Programming Basics ECE2049 E17 Lecture 2: Data Representations & C Programming Basics Administrivia Lab 0 after class today! o Get your MSP430 board! Install instructions for CCS are on course website under Resources o You

More information

The C Programming Language Guide for the Robot Course work Module

The C Programming Language Guide for the Robot Course work Module The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version: SISTEMI EMBEDDED The C Pre-processor Fixed-size integer types Bit Manipulation Federico Baronti Last version: 20170307 The C PreProcessor CPP (1) CPP is a program called by the compiler that processes

More information

Survey. Motivation 29.5 / 40 class is required

Survey. Motivation 29.5 / 40 class is required Survey Motivation 29.5 / 40 class is required Concerns 6 / 40 not good at examination That s why we have 3 examinations 6 / 40 this class sounds difficult 8 / 40 understand the instructor Want class to

More information

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

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements. August 15, 2016 Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document Install SiLabs Instructions in Installing_SiLabs-SDCC- Drivers document Install SecureCRT On LMS, also

More information

Computer Organization & Systems Exam I Example Questions

Computer Organization & Systems Exam I Example Questions Computer Organization & Systems Exam I Example Questions 1. Pointer Question. Write a function char *circle(char *str) that receives a character pointer (which points to an array that is in standard C

More information

Work relative to other classes

Work relative to other classes Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language

More information

Course Outline Introduction to C-Programming

Course Outline Introduction to C-Programming ECE3411 Fall 2015 Lecture 1a. Course Outline Introduction to C-Programming Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,

More information

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2(a) Data Translation Binary patterns, signed and unsigned integers Today s topic Data Translation Code Translation

More information

The Design of C: A Rational Reconstruction

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

COMP2121: Microprocessors and Interfacing. Number Systems

COMP2121: Microprocessors and Interfacing. Number Systems COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting

More information

M1 Computers and Data

M1 Computers and Data M1 Computers and Data Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed

More information

Chapter 7. Basic Types

Chapter 7. Basic Types Chapter 7 Basic Types Dr. D. J. Jackson Lecture 7-1 Basic Types C s basic (built-in) types: Integer types, including long integers, short integers, and unsigned integers Floating types (float, double,

More information

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;

More information

But first, encode deck of cards. Integer Representation. Two possible representations. Two better representations WELLESLEY CS 240 9/8/15

But first, encode deck of cards. Integer Representation. Two possible representations. Two better representations WELLESLEY CS 240 9/8/15 Integer Representation Representation of integers: unsigned and signed Sign extension Arithmetic and shifting Casting But first, encode deck of cards. cards in suits How do we encode suits, face cards?

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

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio ECE2049 Embedded Computing in Engineering Design Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio In this lab, you will be introduced to the Code Composer Studio

More information

The Design of C: A Rational Reconstruction"

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

Special Topics for Embedded Programming

Special Topics for Embedded Programming 1 Special Topics for Embedded Programming ETH Zurich Fall 2018 Reference: The C Programming Language by Kernighan & Ritchie 1 2 Overview of Topics Microprocessor architecture Peripherals Registers Memory

More information

Types, Variables, and Constants

Types, Variables, and Constants , Variables, and Constants What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj Why Types No

More information

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version: SISTEMI EMBEDDED The C Pre-processor Fixed-size integer types Bit Manipulation Federico Baronti Last version: 20160302 The C PreProcessor CPP (1) CPP is a program called by the compiler that processes

More information

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

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 198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book Computer Architecture What do computers do? Manipulate stored information

More information

Programming refresher and intro to C programming

Programming refresher and intro to C programming Applied mechatronics Programming refresher and intro to C programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2018 Outline 1 C programming intro 2

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

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives: ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives: This lab will introduce basic embedded systems programming concepts by familiarizing the user with an embedded programming

More information

Internal representation. Bitwise operators

Internal representation. Bitwise operators Computer Programming Internal representation. Bitwise operators Marius Minea marius@cs.upt.ro 26 October 2015 Ideal math and C are not the same! In mathematics: integers Z and reals R have unbounded values

More information

Internal representation. Bitwise operators

Internal representation. Bitwise operators Computer Programming Internal representation. Bitwise operators Marius Minea marius@cs.upt.ro 23 October 2017 Ideal math and C are not the same! In mathematics: integers Z and reals R have unbounded values

More information

LAB A Translating Data to Binary

LAB A Translating Data to Binary LAB A Translating Data to Binary Create a directory for this lab and perform in it the following groups of tasks: LabA1.java 1. Write the Java app LabA1 that takes an int via a command-line argument args[0]

More information

Internal representation. Bitwise operators

Internal representation. Bitwise operators Computer Programming Internal representation. Bitwise operators Marius Minea marius@cs.upt.ro 24 October 2016 Ideal math and C are not the same! In mathematics: integers Z and reals R have unbounded values

More information

C Introduction. Comparison w/ Java, Memory Model, and Pointers

C Introduction. Comparison w/ Java, Memory Model, and Pointers CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language

More information

Integer Representation

Integer Representation Integer Representation Announcements assign0 due tonight assign1 out tomorrow Labs start this week SCPD Note on ofce hours on Piazza Will get an email tonight about labs Goals for Today Introduction to

More information

Time now to look at how main causes the three LaunchPad LEDs to flash in sequence.

Time now to look at how main causes the three LaunchPad LEDs to flash in sequence. Time now to look at how main causes the three LaunchPad LEDs to flash in sequence. Here is main again (Figure 1). Figure 1 main listing from Lab2 I ve already covered the #include statements and the basic

More information

Binary Representations and Arithmetic

Binary Representations and Arithmetic Binary Representations and Arithmetic 9--26 Common number systems. Base : decimal Base 2: binary Base 6: hexadecimal (memory addresses) Base 8: octal (obsolete computer systems) Base 64 (email attachments,

More information

Number Systems CHAPTER Positional Number Systems

Number Systems CHAPTER Positional Number Systems CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

More information

COSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14

COSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14 COSC 2P91 Introduction Part Deux Week 1b Brock University Brock University (Week 1b) Introduction Part Deux 1 / 14 Source Files Like most other compiled languages, we ll be dealing with a few different

More information

Bits, Bytes and Integers

Bits, Bytes and Integers Bits, Bytes and Integers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

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

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

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

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

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review ECE2049-E18 Lecture 6 Notes 1 ECE2049: Embedded Computing in Engineering Design E Term 2018 Lecture #6: Exam Review Administrivia Exam 1: Next Tuesday (6/5) HW4: Short assignment, due Tuesday Lab 1: Due

More information

(T) x. Casts. A cast converts the value held in variable x to type T

(T) x. Casts. A cast converts the value held in variable x to type T Several New Things 2 s complement representation of negative integers The data size flag in the conversion specification of printf Recast of &n to unsigned long to get the address 2 3 Casts (T) x A cast

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu Physics 2660: Fundamentals of Scientific Computing Lecture 3 Instructor: Prof. Chris Neu (chris.neu@virginia.edu) Announcements Weekly readings will be assigned and available through the class wiki home

More information

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

CS107, Lecture 3 Bits and Bytes; Bitwise Operators CS107, Lecture 3 Bits and Bytes; Bitwise Operators reading: Bryant & O Hallaron, Ch. 2.1 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

5.Coding for 64-Bit Programs

5.Coding for 64-Bit Programs Chapter 5 5.Coding for 64-Bit Programs This chapter provides information about ways to write/update your code so that you can take advantage of the Silicon Graphics implementation of the IRIX 64-bit operating

More information

World Inside a Computer is Binary

World Inside a Computer is Binary C Programming 1 Representation of int data World Inside a Computer is Binary C Programming 2 Decimal Number System Basic symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Radix-10 positional number system. The radix

More information

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

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions ECE2049: Embedded Computing in Engineering Design A Term Fall 2018 Lecture #9: Exam Review w/ Solutions Reading for Today: Review all reading and notes, Davies Ch 1, 2, 4,7, MSP430 User's Guide Ch 6.1,

More information

UNIVERSITY OF LIMERICK OLLSCOIL LUIMNIGH COLLEGE OF INFORMATICS & ELECTRONICS DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING

UNIVERSITY OF LIMERICK OLLSCOIL LUIMNIGH COLLEGE OF INFORMATICS & ELECTRONICS DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING UNIVERSITY OF LIMERICK OLLSCOIL LUIMNIGH COLLEGE OF INFORMATICS & ELECTRONICS DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING MODULE CODE: MODULE TITLE: ET4131 Introduction to Computer Programming SEMESTER:

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Data Types. Data Types. Integer Types. Signed Integers

Data Types. Data Types. Integer Types. Signed Integers Data Types Data Types Dr. TGI Fernando 1 2 The fundamental building blocks of any programming language. What is a data type? A data type is a set of values and a set of operations define on these values.

More information

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19 Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte

More information

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng. CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. 1 Part 1: Data Representation Our goal: revisit and re-establish fundamental of mathematics for the computer architecture course Overview: what are bits

More information

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships

More information

The Design of C: A Rational Reconstruction

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 2 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 11: Structures and Memory (yaseminb@kth.se) Overview Overview Lecture 11: Structures and Memory Structures Continued Memory Allocation Lecture 11: Structures and Memory Structures Continued Memory

More information

ECE2049-E17 Lecture 6 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-E17 Lecture 6 1 ECE2049: Embedded Computing in Engineering Design E Term 2017 Lecture #6: Exam Review Administrivia Exam 1: Next Tuesday (6/6) HW2: Due Tonight at 7pm Lab 1: Due next Tuesday (6/6),

More information

Programming. Elementary Concepts

Programming. Elementary Concepts Programming Elementary Concepts Summary } C Language Basic Concepts } Comments, Preprocessor, Main } Key Definitions } Datatypes } Variables } Constants } Operators } Conditional expressions } Type conversions

More information

The Design of C: A Rational Reconstruction" Jennifer Rexford!

The Design of C: A Rational Reconstruction Jennifer Rexford! The Design of C: A Rational Reconstruction" Jennifer Rexford! 1 Goals of this Lecture"" Number systems! Binary numbers! Finite precision! Binary arithmetic! Logical operators! Design rationale for C! Decisions

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

Beginning C Programming for Engineers

Beginning C Programming for Engineers Beginning Programming for Engineers R. Lindsay Todd Lecture 6: Bit Operations R. Lindsay Todd () Beginning Programming for Engineers Beg 6 1 / 32 Outline Outline 1 Place Value Octal Hexadecimal Binary

More information

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Ziad Matni Dept. of Computer Science, UCSB Adding this Class The class is full I will not be adding more ppl L Even if others

More information

211: Computer Architecture Summer 2016

211: Computer Architecture Summer 2016 211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Data Representation I/O: - (example) cprintf.c Memory: - memory address - stack / heap / constant space - basic data layout Pointer:

More information

CS240: Programming in C. Lecture 2: Overview

CS240: Programming in C. Lecture 2: Overview CS240: Programming in C Lecture 2: Overview 1 Programming Model How does C view the world? Stack Memory code Globals 2 Programming Model Execution mediated via a stack function calls and returns local

More information

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018 Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB Administrative Stuff The class is full I will not be adding more ppl

More information

Representation of Information

Representation of Information Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept

More information

Variables and literals

Variables and literals Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

Hacking in C. The C programming language. Radboud University, Nijmegen, The Netherlands. Spring 2018

Hacking in C. The C programming language. Radboud University, Nijmegen, The Netherlands. Spring 2018 Hacking in C The C programming language Radboud University, Nijmegen, The Netherlands Spring 2018 The C programming language Invented by Dennis Ritchie in the early 70s First Hello World program written

More information

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting) 2.1 Unit 2 Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting) 2.2 Skills & Outcomes You should know and be able to apply the following skills with confidence Perform addition & subtraction

More information

Chapter 3 Basic Data Types. Lecture 3 1

Chapter 3 Basic Data Types. Lecture 3 1 Chapter 3 Basic Data Types Lecture 3 1 Topics Scalar Types in C Integers Bit Operations Floating Point Types Conversions Lecture 4 2 Scalar Types in C The amount of memory available for a variable depends

More information

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation

More information

SIGNED AND UNSIGNED SYSTEMS

SIGNED AND UNSIGNED SYSTEMS EE 357 Unit 1 Fixed Point Systems and Arithmetic Learning Objectives Understand the size and systems used by the underlying HW when a variable is declared in a SW program Understand and be able to find

More information

More about Binary 9/6/2016

More about Binary 9/6/2016 More about Binary 9/6/2016 Unsigned vs. Two s Complement 8-bit example: 1 1 0 0 0 0 1 1 2 7 +2 6 + 2 1 +2 0 = 128+64+2+1 = 195-2 7 +2 6 + 2 1 +2 0 = -128+64+2+1 = -61 Why does two s complement work this

More information

Applied Computer Programming

Applied Computer Programming Applied Computer Programming Representation of Numbers. Bitwise Operators Course 07 Lect.eng. Adriana ALBU, PhD Politehnica University Timisoara Internal representation All data, of any type, processed

More information

CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II

CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II Example: Simple variables Handout written by Julie Zelenski and Nick Parlante A variable is a location in memory. When a variable

More information

Chapter 3: Operators, Expressions and Type Conversion

Chapter 3: Operators, Expressions and Type Conversion 101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

More information

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

ECE2049 Embedded Computing in Engineering Design. Lab #0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio ECE2049 Embedded Computing in Engineering Design Lab #0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio In this lab you will be introduced to the Code Composer Studio

More information

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers CSC 2400: Computer Systems Bits, Bytes and Data Types 1 Goals for this Week Binary number system Why binary? Converting between decimal and binary and octal and hexadecimal number systems Finite representations

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can

More information

Computer Organization

Computer Organization Computer Organization Register Transfer Logic Number System Department of Computer Science Missouri University of Science & Technology hurson@mst.edu 1 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5,

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

As stated earlier, the declaration

As stated earlier, the declaration The int data type As stated earlier, the declaration int a; is an instruction to the compiler to reserve a certain amount of memory to hold the values of the variable a. How much memory? Two bytes (usually,

More information

CHAPTER 1 Numerical Representation

CHAPTER 1 Numerical Representation CHAPTER 1 Numerical Representation To process a signal digitally, it must be represented in a digital format. This point may seem obvious, but it turns out that there are a number of different ways to

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

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

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode

More information

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,

More information

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,

More information

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras Numbers and Computers Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras 1 Think of a number between 1 and 15 8 9 10 11 12 13 14 15 4 5 6 7 12 13 14 15 2 3 6 7 10 11 14 15

More information