POLYTECH CLERMONT-FERRAND. Application Note. Implementation of a SPEEX decoder on RX62N RENESAS microcontroller 22/01/2012

Size: px
Start display at page:

Download "POLYTECH CLERMONT-FERRAND. Application Note. Implementation of a SPEEX decoder on RX62N RENESAS microcontroller 22/01/2012"

Transcription

1 POLYTECH CLERMONT-FERRAND Application Note Implementation of a SPEEX decoder on RX62N RENESAS microcontroller 22/01/2012 Author : Sébastien PINNETERRE Engineering student in electrical engineering /embedded systems

2 1

3 Table of Contents Preface... 4 Chapter 1: Introduction SPEEX s features... 5 Application example... 5 Chapter 2: pre-necessary Required hardware... 6 Required software... 6 Software installation... 6 Chapter 3: Implementation of a Speex decoder Get back Speex codec source code... 7 Project creation... 7 Setup the KPIT GNURX tool chain... 7 Project organization... 8 Modification of source code

4 Illustration table Figure 1: Quality versus bit-rate... 5 Figure 2: Example of application... 5 Figure 3 : KPIT GNURX Configuration... 7 Figure 4: library configuration... 8 Figure 5: library configuration... 8 Figure 6: Section configuration... 8 Figure 7: List of Speex files

5 Preface This document provides all the necessary elements to implement a SPEEX decoder on RX62N RENESAS microcontroller on its RSK2+RX62N development board. 4

6 Chapter 1: Introduction 1.1 SPEEX s features The Speex codec is an open source speech codec. Speex is designed for packet networks and voice over IP (VoIP) applications. The Speex codec is designed to be very flexible and support a wide range of speech quality and bit-rate. Support for very good quality speech also means that Speex can encode wideband speech (16 khz sampling rate) in addition to narrowband speech (telephone quality, 8 khz sampling rate). The table below shows the quality versus the bit-rate in narrowband mode. Figure : Quality versus bit-rate 1.2 Application example Computer Speex file (.spx) Communication network Speex decoder Figure : Example of application This example shows an use of the Speex codec. The Speex file corresponding to a speech which has been recorded and encoded in Speex file before. This Speex file, stored on a computer is sent though a communication network to a Speex decoder which restores the speech to a speaker. 5

7 Chapter 2: pre-necessary This chapter deals with the necessary hardware and software to implement the Speex decoder. 2.1 Required hardware The following hardware has to be used: RSK2+RX62N development board RENESAS Debugger E1 2.2 Required software In order to implement the Speex decoder, following software have to be used: High-performance Embedded Workshop (HEW) HEW is a RENESAS integrated development environment which permits to do debugging. The used version for demonstrations will be the version. - Downloadable at this link : 0u_full_update.exe GNURX GNURX is a free compiler which is integrated at HEW. The used version for demonstrations will be the version. - Downloadable at this link : Software installation It is necessary to respect an order of installation between HEW and GNURX. In first, HEW has to been installed. Once the installation is completed, GNURX may be installed. The GNURX tool chain will be automatically integrated in HEW. 6

8 Chapter 3: Implementation of a Speex decoder In this chapter, the procedure to implement the Speex decoder on RX62N microcontroller is enounced. Will be enounced, where find source code, how to create a new project to implement the Speex decoder, how the HEW software has to be configured etc 3.1 Get back Speex codec source code The first step consists in getting back Speex code source code on the official site web at this link: On the download section, several versions of the Speex codec can be found. The lasted version in date is the 1.2rc1 version which is also the recommended version. Download the speex-1.2rc1.tar.gz packet. It s also necessary to get back the ogg library which is not provided with Speex codec source code. This ogg library may be downloaded on the official site web at this link: On the download section, download the libogg zip packet which contains the ogg library. 3.2 Project creation Create a new project and choose the GNURX tool chain. It s also necessary to setup the data endian in little endian data and use following header files: ctype.h; math.h; stdio.h; stdlib.h; string.h. 3.3 Setup the KPIT GNURX tool chain This part explains how to setup the GNU compiler. First, once the project was created, click on KPIT GNURX in the Build menu in order to open the setup compiler s window and follow these instructions: Select debug configuration In the link/library tab, select input category then show entries for C/C++ library as the illustration below : Figure : KPIT GNURX Configuration 7

9 Next, add these two following libraries at the list: rx-elf\rx-elf\optlibinc and rx-elf\bin\newlib\libc\common relative to tool chain install directory. See the illustration below : Figure : library configuration Figure : library configuration In the link/library tab, select section category, then configure section as following : Figure : Section configuration Valid configuration when it s finished 3.4 Project organization In this part is enounced what files are necessary to the project. For implementation of the decoder, source file of Speex codec downloaded are required plus ogg library files. From the speex- 1.2rc1.tar.gz packet, use the files from the folder include,libspeex and src. From the libogg zip packet, use the files from the include/ogg. 8

10 The list of necessary files is listed below: -Speex sources: Figure : List of Speex files -Ogg library sources: ogg.h ; os_types.h 3.5 Modification of source code In this part is explained the main changes of source code to implement the speex decoder on the RX62N. os_types.h file This header file defines types for ogg format, they are defined depending on different systems which may exist. However these systems do not correspond to the RX62N, so lines which define type ogg_int16_t, ogg_uint16_t, ogg_int32_t, ogg_uint32_t, ogg_int64_t may be deleted and replaced by these lines below: typedef signed short ogg_int16_t; typedef unsigned short ogg_uint16_t; typedef signed int ogg_int32_t; typedef unsigned int ogg_uint32_t; typedef signed long long ogg_int64_t; typedef unsigned long long ogg_uint64_t; 9

11 speex_types.h file : This file defines types for Speex codec, as previously they are defined depending on different systems which may exist. So lines which define spx_int16_t, spx_uint16_t, spx_int32_t et spx_uint32_t type may be deleted and replaced by these lines below: typedef short spx_int16_t; typedef unsigned short spx_uint16_t; typedef int spx_int32_t; typedef unsigned int spx_uint32_t; Source codes are designed for operating systems which have graphic interface and used unnecessary functions for the application because they are not supported. Among these functions, there are printf and fprintf which may be deleted or commented. Decoding function : The main decoding function is located in speexdec.c file and corresponding to the main function. By default, it has int main(int argc, char **argv) as prototype. Indeed, the source code is designed for being used as a program that explains the use of argc and argv. These arguments are used to setup names of input and output files, and also to setup some options. To implement this decoding function to the RX62N, this function can be defined as a function without argument (void). For example: int speexdec(void) Now, there are different important points on which we have to work. The Speex decoder can be simplify as below: Start Reading option Opening input file Initialization of the decoder End Decoding loop Reading ogg packet from input file Decoding ogg packet loop Decoding speex packet Opening output file at first time Writing data in output file End of decoding ogg packet loop End of decoding loop Destruction of the decoder Closing files 10

12 To implement the decoder, follow instructions below: 1) Files don t have to be used and may be replaced by buffers. So file pointer, all function concerning the opening and the closing of files can be deleted. 2) The functions which managed options can be deleted because the options will be frozen. 3) The functions which managed Wave header can be deleted because we don t need to use Wave output file. 4) The fread function which is used to read the input file has to be replaced. Below, the prototype of this function: size_t fread (void *ptr, size_t size, size_t nmemb, FILE *stream); The fread function read nmemb elements of data of size octets of length, from the stream pointed by stream, and store its in location pointed by ptr. fread return the number of correct read elements. Below, the original code of the reading operation: while (1) { char *data; int i, j, nb_read; /*Get the ogg buffer for writing*/ data = ogg_sync_buffer(&oy, 200); /*Read bitstream from input file*/ nb_read = fread(data, sizeof(char), 200, fin); ogg_sync_wrote(&oy, nb_read); /*Loop for all complete pages we got (most likely only one)*/ while (ogg_sync_pageout(&oy, &og)==1) { Code details: Mainly the ogg_sync_buffer() function reserves a new memory area of 200 Bytes in a structure named oy and it returns the address of this memory area. The fread function permits to copy, by packet of 200 Bytes, data from the input file in the memory area of the oy structure pointed by data. nb_read saves the number of data read. 11

13 Mainly, the ogg_sync_wrote() function synchronizes data read depending on nb_read. Then, if read data from an ogg packet, so we enter in the decoding loop of ogg packet. The fread function can be replaced by the code below: memcpy(data, &buffer_in[cpt_buf_in], sizeof(char)*nb_read) ; cpt_buf_in = (cpt_buf_in + nb_read) % BUFFER_IN_SIZE; The memcpy function permits to copy memory areas. Here, nb_read is equal to 200 and permits to copy blocs of 200 Bytes from an input buffer named buffer_in to the memory area pointed by data. 5) The fwrite function which is used to write in the output file has to be replaced. Below, the prototype of this function: size_t fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); The fwrite function writes nmemb elements of data of size octets of length, into the stream pointed by stream, from the location pointed by ptr. The fwrite function returns the number of correct written elements. Below, the original code of the writing operation: fwrite(out+frame_offset*channels, sizeof(short), new_frame_size*channels, fout); Code details: - out corresponding to the output buffer of a Speex decoded packet - channel corresponding to the number of channel (mono / stereo) - new_frame_size corresponding to the size of the data frame for one Speex packet (160 by default) The fwrite function can be replaced by the code below: for (i=0;i<frame_size*channels;i++) { } buffer_out_1[i]=( output[i+frame_offset] + 0x7fff) >> 6 ; We copy elements per elements data from output Speex decoding buffer to the buffer_out_1 buffer. Then these data can be converted by an analogic to digital converter (ADC). 12

SPEEX CODEC IMPLEMENTATION ON THE RPB RX210

SPEEX CODEC IMPLEMENTATION ON THE RPB RX210 APPLICATION NOTE SPEEX CODEC IMPLEMENTATION ON THE RPB RX210 Author: César MAKAMONA MBUMBA SHÉALTIEL January 2013 Abstract Codec is a compound word derived from Coder-decoder or Compressor-decompressor.

More information

CSC209H Lecture 3. Dan Zingaro. January 21, 2015

CSC209H Lecture 3. Dan Zingaro. January 21, 2015 CSC209H Lecture 3 Dan Zingaro January 21, 2015 Streams (King 22.1) Stream: source of input or destination for output We access a stream through a file pointer (FILE *) Three streams are available without

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Processes. Johan Montelius KTH

Processes. Johan Montelius KTH Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other

More information

A process. the stack

A process. the stack A process Processes Johan Montelius What is a process?... a computation KTH 2017 a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other processes

More information

Approximately a Test II CPSC 206

Approximately a Test II CPSC 206 Approximately a Test II CPSC 206 Sometime in history based on Kelly and Pohl Last name, First Name Last 5 digits of ID Write your section number(s): All parts of this exam are required unless plainly and

More information

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty.

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty. ECE 264 Exam 2 6:30-7:30PM, March 9, 2011 I certify that I will not receive nor provide aid to any other student for this exam. Signature: You must sign here. Otherwise you will receive a 1-point penalty.

More information

File (1A) Young Won Lim 11/25/16

File (1A) Young Won Lim 11/25/16 File (1A) Copyright (c) 2010-2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

Experiment 6 The Real World Interface

Experiment 6 The Real World Interface Experiment 6 The Real World Interface Instructions You are required to design, code, test and document the C program from the experiment listed below. You should prepare the pseudocode for the program

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 12

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 12 BIL 104E Introduction to Scientific and Engineering Computing Lecture 12 Files v.s. Streams In C, a file can refer to a disk file, a terminal, a printer, or a tape drive. In other words, a file represents

More information

82V391x / 8V893xx WAN PLL Device Families Device Driver User s Guide

82V391x / 8V893xx WAN PLL Device Families Device Driver User s Guide 82V391x / 8V893xx WAN PLL Device Families Device Driver Version 1.2 April 29, 2014 Table of Contents 1. Introduction... 1 2. Software Architecture... 2 2.1. Overview... 2 2.2. Hardware Abstraction Layer

More information

File I/O. Preprocessor Macros

File I/O. Preprocessor Macros Computer Programming File I/O. Preprocessor Macros Marius Minea marius@cs.upt.ro 4 December 2017 Files and streams A file is a data resource on persistent storage (e.g. disk). File contents are typically

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the

More information

25.2 Opening and Closing a File

25.2 Opening and Closing a File Lecture 32 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 32: Dynamically Allocated Arrays 26-Nov-2018 Location: Chemistry 125 Time: 12:35 13:25 Instructor:

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

File Handling. Reference:

File Handling. Reference: File Handling Reference: http://www.tutorialspoint.com/c_standard_library/ Array argument return int * getrandom( ) static int r[10]; int i; /* set the seed */ srand( (unsigned)time( NULL ) ); for ( i

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

Reading compiler errors

Reading compiler errors Reading compiler errors ls2.c:1: error: expected =,,, ;, asm or attribute before : token In file included from /usr/include/stdio.h:75, from ls2.c:12: /usr/include/libio.h:332: error: expected specifier-qualifier-list

More information

PROGRAMMAZIONE I A.A. 2017/2018

PROGRAMMAZIONE I A.A. 2017/2018 PROGRAMMAZIONE I A.A. 2017/2018 INPUT/OUTPUT INPUT AND OUTPUT Programs must be able to write data to files or to physical output devices such as displays or printers, and to read in data from files or

More information

THE C STANDARD LIBRARY & MAKING YOUR OWN LIBRARY. ISA 563: Fundamentals of Systems Programming

THE C STANDARD LIBRARY & MAKING YOUR OWN LIBRARY. ISA 563: Fundamentals of Systems Programming THE C STANDARD LIBRARY & MAKING YOUR OWN LIBRARY ISA 563: Fundamentals of Systems Programming Announcements Homework 2 posted Homework 1 due in two weeks Typo on HW1 (definition of Fib. Sequence incorrect)

More information

AD5669R - Microcontroller No-OS Driver

AD5669R - Microcontroller No-OS Driver One Technology Way P.O. Box 9106 Norwood, MA 02062-9106 Tel: 781.329.4700 Fax: 781.461.3113 www.analog.com AD5669R - Microcontroller No-OS Driver Supported Devices AD5669R Evaluation Boards EVAL-AD5669RSDZ

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

CS 261 Fall Mike Lam, Professor. Structs and I/O

CS 261 Fall Mike Lam, Professor. Structs and I/O CS 261 Fall 2018 Mike Lam, Professor Structs and I/O Typedefs A typedef is a way to create a new type name Basically a synonym for another type Useful for shortening long types or providing more meaningful

More information

UNIT-V CONSOLE I/O. This section examines in detail the console I/O functions.

UNIT-V CONSOLE I/O. This section examines in detail the console I/O functions. UNIT-V Unit-5 File Streams Formatted I/O Preprocessor Directives Printf Scanf A file represents a sequence of bytes on the disk where a group of related data is stored. File is created for permanent storage

More information

Midterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee.

Midterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee. Midterm Exam Nov 8th, 2012 COMS W3157 Advanced Programming Columbia University Fall 2012 Instructor: Jae Woo Lee About this exam: - There are 4 problems totaling 100 points: problem 1: 30 points problem

More information

Today s class. Review of more C Operating system overview. Informationsteknologi

Today s class. Review of more C Operating system overview. Informationsteknologi Today s class Review of more C Operating system overview Monday, September 10, 2007 Computer Systems/Operating Systems - Class 3 1 Review of more C File handling Open a file using fopen Returns a file

More information

Arrays and Pointers in C. Alan L. Cox

Arrays and Pointers in C. Alan L. Cox Arrays and Pointers in C Alan L. Cox alc@rice.edu Objectives Be able to use arrays, pointers, and strings in C programs Be able to explain the representation of these data types at the machine level, including

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

Dynamic memory allocation

Dynamic memory allocation Dynamic memory allocation outline Memory allocation functions Array allocation Matrix allocation Examples Memory allocation functions (#include ) malloc() Allocates a specified number of bytes

More information

Application Note: AN00152 xscope - Bi-Directional Endpoint

Application Note: AN00152 xscope - Bi-Directional Endpoint Application Note: AN00152 xscope - Bi-Directional Endpoint This application note shows how to create a simple example which uses the XMOS xscope application trace system to provide bi-directional communication

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060 CS 2060 Files and Streams Files are used for long-term storage of data (on a hard drive rather than in memory). Files and Streams Files are used for long-term storage of data (on a hard drive rather than

More information

Opus Generated by Doxygen Thu May :22:05

Opus Generated by Doxygen Thu May :22:05 Opus 0.9.14 Generated by Doxygen 1.7.1 Thu May 17 2012 15:22:05 Contents 1 Opus 1 2 Module Index 3 2.1 Modules................................. 3 3 File Index 5 3.1 File List.................................

More information

Array Initialization

Array Initialization Array Initialization Array declarations can specify initializations for the elements of the array: int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ; initializes primes[0] to 2, primes[1] to 3, primes[2]

More information

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36 Department of Computer Science College of Engineering Boise State University August 25, 2017 1/36 Pointers and Arrays A pointer is a variable that stores the address of another variable. Pointers are similar

More information

Memory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)

Memory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables) Memory Allocation Memory What is memory? Storage for variables, data, code etc. How is memory organized? Text (Code) Data (Constants) BSS (Global and static variables) Text Data BSS Heap Stack (Local variables)

More information

CSSE 332 Standard Library, Storage classes, and Make

CSSE 332 Standard Library, Storage classes, and Make CSSE 332 Standard Library, Storage classes, and Make 1 Provides a simple and efficient buffered I/O interface from man stdio Prototypes standard I/O functions (Mostly) system-independent (e.g.

More information

CSE 565 Computer Security Fall 2018

CSE 565 Computer Security Fall 2018 CSE 565 Computer Security Fall 2018 Lecture 15: Software Security II Department of Computer Science and Engineering University at Buffalo 1 Software Vulnerabilities Buffer overflow vulnerabilities account

More information

Fundamentals of Programming. Lecture 10 Hamed Rasifard

Fundamentals of Programming. Lecture 10 Hamed Rasifard Fundamentals of Programming Lecture 10 Hamed Rasifard 1 Outline File Input/Output 2 Streams and Files The C I/O system supplies a consistent interface to the programmer independent of the actual device

More information

Lecture 04 Introduction to pointers

Lecture 04 Introduction to pointers Lecture 04 Introduction to pointers A pointer is an address in the memory. One of the unique advantages of using C is that it provides direct access to a memory location through its address. A variable

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

Student Number: Instructor: Reid Section: L0101 (10:10-11:00am)

Student Number: Instructor: Reid Section: L0101 (10:10-11:00am) Midterm Test Duration 50 minutes Aids allowed: none Last Name: Student Number: First Name: Instructor: Reid Section: L0101 (10:10-11:00am) Do not turn this page until you have received the signal to start.

More information

libtheora Reference Manual

libtheora Reference Manual libtheora Reference Manual unreleased Generated by Doxygen 1.3.8 Wed Sep 15 22:40:11 2004 Contents 1 libtheora Main Page 1 1.1 Introduction........................................ 1 2 libtheora Data Structure

More information

Final Exam. Fall Semester 2016 KAIST EE209 Programming Structures for Electrical Engineering. Name: Student ID:

Final Exam. Fall Semester 2016 KAIST EE209 Programming Structures for Electrical Engineering. Name: Student ID: Fall Semester 2016 KAIST EE209 Programming Structures for Electrical Engineering Final Exam Name: This exam is open book and notes. Read the questions carefully and focus your answers on what has been

More information

System Programming. Standard Input/Output Library (Cont d)

System Programming. Standard Input/Output Library (Cont d) Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Binary I/O 2 3 4 5 Binary

More information

The C Programming Language

The C Programming Language The C Programming Language CS 025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario The C Programming Language A high-level language for writing low-level programs Allows machine-independent

More information

C PROGRAMMING. Characters and Strings File Processing Exercise

C PROGRAMMING. Characters and Strings File Processing Exercise C PROGRAMMING Characters and Strings File Processing Exercise CHARACTERS AND STRINGS A single character defined using the char variable type Character constant is an int value enclosed by single quotes

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

FUNCTIONS POINTERS. Pointers. Functions

FUNCTIONS POINTERS. Pointers. Functions Functions Pointers FUNCTIONS C allows a block of code to be separated from the rest of the program and named. These blocks of code or modules are called functions. Functions can be passed information thru

More information

Introduction to file management

Introduction to file management 1 Introduction to file management Some application require input to be taken from a file and output is required to be stored in a file. The C language provides the facility of file input-output operations.

More information

C File System File Functions EXPERIMENT 1.2

C File System File Functions EXPERIMENT 1.2 C File System File Functions EXPERIMENT 1.2 Propose of the experiment Continue from previous experiment to be familiar with CCS environment Write a C language file input / output (CIO) program to read

More information

Software Development With Emacs: The Edit-Compile-Debug Cycle

Software Development With Emacs: The Edit-Compile-Debug Cycle Software Development With Emacs: The Edit-Compile-Debug Cycle Luis Fernandes Department of Electrical and Computer Engineering Ryerson Polytechnic University August 8, 2017 The Emacs editor permits the

More information

CS61, Fall 2012 Section 2 Notes

CS61, Fall 2012 Section 2 Notes CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors

More information

Content. Input Output Devices File access Function of File I/O Redirection Command-line arguments

Content. Input Output Devices File access Function of File I/O Redirection Command-line arguments File I/O Content Input Output Devices File access Function of File I/O Redirection Command-line arguments UNIX and C language C is a general-purpose, high-level language that was originally developed by

More information

ECE264 Spring 2014 Exam 2, March 11, 2014

ECE264 Spring 2014 Exam 2, March 11, 2014 ECE264 Spring 2014 Exam 2, March 11, 2014 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ. C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,

More information

ESSENTIALS OF THE C PROGRAMMING LANGUAGE BY ISIDORO COUVERTIER REYES

ESSENTIALS OF THE C PROGRAMMING LANGUAGE BY ISIDORO COUVERTIER REYES ESSENTIALS OF THE C PROGRAMMING LANGUAGE BY ISIDORO COUVERTIER REYES OBJECTIVES AT THE END OF THIS TRAINING THE PARTICIPANTS WILL BE: ABLE TO RECOGNIZE AND UNDERSTAND THE MOST FUNDAMENTAL C LANGUAGE CONSTRUCTS.

More information

fopen() fclose() fgetc() fputc() fread() fwrite()

fopen() fclose() fgetc() fputc() fread() fwrite() The ability to read data from and write data to files is the primary means of storing persistent data, data that does not disappear when your program stops running. The abstraction of files that C provides

More information

Armide Documentation. Release Kyle Mayes

Armide Documentation. Release Kyle Mayes Armide Documentation Release 0.3.1 Kyle Mayes December 19, 2014 Contents 1 Introduction 1 1.1 Features.................................................. 1 1.2 License..................................................

More information

Bristol Institute of Technology

Bristol Institute of Technology Bristol Institute of Technology Academic Year: 09/10 Module Leader: Module Code: Title of Module: Ian Johnson UFCETS-20-1 Programming in C Examination Date: Monday 12 th January 2009 Examination Start

More information

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems Programs CSCI 4061 Introduction to Operating Systems C Program Structure Libraries and header files Compiling and building programs Executing and debugging Instructor: Abhishek Chandra Assume familiarity

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight HW2 Due Thursday, July 19 th Midterm on Monday, July 23 th 10:50-11:50 in TBD (And regular exercises in between) POSIX

More information

File IO and command line input CSE 2451

File IO and command line input CSE 2451 File IO and command line input CSE 2451 File functions Open/Close files fopen() open a stream for a file fclose() closes a stream One character at a time: fgetc() similar to getchar() fputc() similar to

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 15: Unix interface: low-level interface Cristina Nita-Rotaru Lecture 15/Fall 2013 1 Streams Recap Higher-level interface, layered on top of the primitive file descriptor

More information

Course organization. Course introduction ( Week 1)

Course organization. Course introduction ( Week 1) Course organization Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 2-9) Chapter 1: Overall Introduction (Week 1-3) Chapter 2: Types, operators and

More information

Understanding Pointers

Understanding Pointers Division of Mathematics and Computer Science Maryville College Pointers and Addresses Memory is organized into a big array. Every data item occupies one or more cells. A pointer stores an address. A pointer

More information

Lecture 05 Pointers ctd..

Lecture 05 Pointers ctd.. Lecture 05 Pointers ctd.. Note: some notes here are the same as ones in lecture 04 1 Introduction A pointer is an address in the memory. One of the unique advantages of using C is that it provides direct

More information

Memory Corruption 101 From Primitives to Exploit

Memory Corruption 101 From Primitives to Exploit Memory Corruption 101 From Primitives to Exploit Created by Nick Walker @ MWR Infosecurity / @tel0seh What is it? A result of Undefined Behaviour Undefined Behaviour A result of executing computer code

More information

CSE 410: Systems Programming

CSE 410: Systems Programming CSE 410: Systems Programming Input and Output Ethan Blanton Department of Computer Science and Engineering University at Buffalo I/O Kernel Services We have seen some text I/O using the C Standard Library.

More information

Carnegie Mellon. C Boot Camp. Oct 6th, Jack Biggs Raghav Goyal Nikhil Jog

Carnegie Mellon. C Boot Camp. Oct 6th, Jack Biggs Raghav Goyal Nikhil Jog C Boot Camp Oct 6th, 2017 Jack Biggs Raghav Goyal Nikhil Jog Agenda C Basics Debugging Tools / Demo Appendix C Standard Library getopt stdio.h stdlib.h string.h C Basics Handout ssh @shark.ics.cs.cmu.edu

More information

BİL200 TUTORIAL-EXERCISES Objective:

BİL200 TUTORIAL-EXERCISES Objective: Objective: The purpose of this tutorial is learning the usage of -preprocessors -header files -printf(), scanf(), gets() functions -logic operators and conditional cases A preprocessor is a program that

More information

Do not turn the page until 5:00.

Do not turn the page until 5:00. University of Washington Computer Science & Engineering Spring 2018 Instructor: Justin Hsia 2018-05-04 Last Name: First Name: Student ID Number: Name of person to your Left Right All work is my own. I

More information

Final exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Dec 20, Student's name: Student ID:

Final exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Dec 20, Student's name: Student ID: Fall term 2012 KAIST EE209 Programming Structures for EE Final exam Thursday Dec 20, 2012 Student's name: Student ID: The exam is closed book and notes. Read the questions carefully and focus your answers

More information

Carnegie Mellon. C Boot Camp. September 30, 2018

Carnegie Mellon. C Boot Camp. September 30, 2018 C Boot Camp September 30, 2018 Agenda C Basics Debugging Tools / Demo Appendix C Standard Library getopt stdio.h stdlib.h string.h C Basics Handout ssh @shark.ics.cs.cmu.edu cd ~/private wget

More information

Library Functions. General Questions

Library Functions. General Questions 1 Library Functions General Questions 1. What will the function rewind() do? A. Reposition the file pointer to a character reverse. B. Reposition the file pointer stream to end of file. C. Reposition the

More information

CSC 270 Survey of Programming Languages. Input and Output

CSC 270 Survey of Programming Languages. Input and Output CSC 270 Survey of Programming Languages C Lecture 8 Input and Output Input and Output C supports 2 different I/O libraries: buffered (higher level functions supported by ANSI standards) unbuffered (lower-level

More information

OBJECTIVE QUESTIONS: Choose the correct alternative:

OBJECTIVE QUESTIONS: Choose the correct alternative: OBJECTIVE QUESTIONS: Choose the correct alternative: 1. Function is data type a) Primary b) user defined c) derived d) none 2. The declaration of function is called a) function prototype b) function call

More information

Course organization. Part I: Introduction to C programming language (Week 1-12) Chapter 1: Overall Introduction (Week 1-4)

Course organization. Part I: Introduction to C programming language (Week 1-12) Chapter 1: Overall Introduction (Week 1-4) Course organization 1 Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 1-12) Chapter 1: Overall Introduction (Week 1-4) C Unix/Linux Chapter 2: Types,

More information

Common Misunderstandings from Exam 1 Material

Common Misunderstandings from Exam 1 Material Common Misunderstandings from Exam 1 Material Kyle Dewey Stack and Heap Allocation with Pointers char c = c ; char* p1 = malloc(sizeof(char)); char** p2 = &p1; Where is c allocated? Where is p1 itself

More information

AIM Core and Enterprise Solutions

AIM Core and Enterprise Solutions TPF Users Group Grapevine, Texas IBM Software Group C/C++ single source APARs Languages Subcommittee Sarat Vemuri October 2004 AIM Core and Enterprise Solutions IBM z/transaction Processing Facility Enterprise

More information

Accessing Files in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts

Accessing Files in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts Accessing Files in C Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

Open AMR Initiative. Technical Documentation. Version 1.0 Revision

Open AMR Initiative. Technical Documentation. Version 1.0 Revision VoiceAge Corporation 750 Chemin Lucerne, Suite 250 Ville Mont-Royal (Quebec) H3R 2H6 Canada (514) 737-4940 Fax (514) 908-2037 www.voiceage.com Open AMR Initiative Technical Documentation Version 1.0 Revision

More information

CSI 402 Lecture 2 Working with Files (Text and Binary)

CSI 402 Lecture 2 Working with Files (Text and Binary) CSI 402 Lecture 2 Working with Files (Text and Binary) 1 / 30 AQuickReviewofStandardI/O Recall that #include allows use of printf and scanf functions Example: int i; scanf("%d", &i); printf("value

More information

upper and lower case English letters: A-Z and a-z digits: 0-9 common punctuation symbols special non-printing characters: e.g newline and space.

upper and lower case English letters: A-Z and a-z digits: 0-9 common punctuation symbols special non-printing characters: e.g newline and space. The char Type The C type char stores small integers. It is 8 bits (almost always). char guaranteed able to represent integers 0.. +127. char mostly used to store ASCII character codes. Don t use char for

More information

C: Pointers. C: Pointers. Department of Computer Science College of Engineering Boise State University. September 11, /21

C: Pointers. C: Pointers. Department of Computer Science College of Engineering Boise State University. September 11, /21 Department of Computer Science College of Engineering Boise State University September 11, 2017 1/21 Pointers A pointer is a variable that stores the address of another variable. Pointers are similar to

More information

Computer Systems C S Cynthia Lee

Computer Systems C S Cynthia Lee Computer Systems C S 1 0 7 Cynthia Lee 2 Topics ARRAYS AND POINTERS IN C: This will solidify and deepen your understanding of C strings They re just pointers/arrays of char! Pointers to arrays, Pointers

More information

Lecture 7: file I/O, more Unix

Lecture 7: file I/O, more Unix CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 7: file

More information

4) In C, if you pass an array as an argument to a function, what actually gets passed?

4) In C, if you pass an array as an argument to a function, what actually gets passed? Paytm Programming Sample paper: 1) What will be the output of the program? #include int main() } int y=128; const int x=y; printf("%d\n", x); return 0; a. 128 b. Garbage value c. Error d. 0 2)

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

Input/Output and the Operating Systems

Input/Output and the Operating Systems Input/Output and the Operating Systems Fall 2015 Jinkyu Jeong (jinkyu@skku.edu) 1 I/O Functions Formatted I/O printf( ) and scanf( ) fprintf( ) and fscanf( ) sprintf( ) and sscanf( ) int printf(const char*

More information

ID 321L: KPIT GNU compiler plug-ins for HEW / KPIT Eclipse IDE

ID 321L: KPIT GNU compiler plug-ins for HEW / KPIT Eclipse IDE ID 321L: KPIT GNU compiler plug-ins for HEW / KPIT Eclipse IDE Matt Newsome, Principal Engineer, Software Tools, Renesas Electronics Europe, UK Kaushik Phatak, Tech Lead, KPIT Cummins Infosystems, Pune,

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 13 si 14: Unix interface for working with files. Cristina Nita-Rotaru Lecture 13/Fall 2013 1 Working with Files (I/O) File system: specifies how the information is organized

More information

CSE 124 Discussion (10/3) C/C++ Basics

CSE 124 Discussion (10/3) C/C++ Basics CSE 124 Discussion (10/3) C/C++ Basics Topics - main() function - Compiling with gcc/makefile - Primitives - Structs/Enums - Function calls/loops - C++ Classes/stdtl - Pointers/Arrays - Memory allocation/freeing

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Adapted from the slides Revisões sobre Programação em C, Sérgio Crisóstomo Compilation #include int main()

More information

CS201 Lecture 2 GDB, The C Library

CS201 Lecture 2 GDB, The C Library CS201 Lecture 2 GDB, The C Library RAOUL RIVAS PORTLAND STATE UNIVERSITY Announcements 2 Multidimensional Dynamically Allocated Arrays Direct access support. Same as Multidimensional Static Arrays No direct

More information

Detecting Errors in the Dual Port TPU RAM (DPTRAM) Module

Detecting Errors in the Dual Port TPU RAM (DPTRAM) Module Freescale Semiconductor Order this document by: AN2192/D Detecting Errors in the Dual Port TPU RAM (DPTRAM) Module by Jeff Loeliger Rev. 0, 10 September 2001 1 Overview The integrity of the data in the

More information

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

More information

Lecture 17 Bit Operations

Lecture 17 Bit Operations Lecture 17 Bit Operations In this lecture Background Left Shifting Negative Numbers, one s complement and two s complement Right Shifting Bit Operators Masking the Bits Getting the Bits Setting the Bits

More information

Compile the Hello World program

Compile the Hello World program OS Project1 1 Hello World Writing a Hello World program #include header.h main ( int argc, char *argv[] ) { printf( Hello World!\n ); } Compile the Hello World program > gcc helloworld.c o helloworld 2

More information