Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training.

Slides:



Advertisements
Similar presentations
2007 Pearson Education, Inc. All rights reserved C Structures, Unions, Bit Manipulations and Enumerations.
Advertisements

Chapter 10 C Structures, Unions, Bit Manipulations and Enumerations Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc.
Chapter 10 C Structures, Unions, Bit Manipulations, and Enumerations.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Slides created by: Professor Ian G. Harris Efficient C Code  Your C program is not exactly what is executed  Machine code is specific to each ucontroller.
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 3 GETTING THE MOST OUT OF C.
Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training.
Union, bitfield, typedef, enum union nama_u{ }; union nama_u{ struct nama_s byte; }; enum{ }; Tipedef var BYTE.
Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training.
Introduction to C Programming CE Lecture 8 Bitwise Operations.
24/06/2015CSE1303 Part B lecture notes 1 Words, bits and pieces Lecture B05 Lecture notes section B05.
13.5 Arranging data on disk Meghna Jain ID-205CS257 ‏Prof: Dr. T.Y.Lin.
Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training.
Programming C/C++ on Eclipe C Training Trình bày : Ths HungNM.
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
1 Bitwise Operators. 2 Bits and Constants 3 Bitwise Operators Bitwise "and" operator & Bitwise "or" operator | Bitwise "exclusive or" operator ^ Bitwise.
1 Bitwise Operators. 2 Bitwise Operators (integers) Bitwise "and" operator & Bitwise "or" operator | Bitwise "exclusive or" operator ^ Bitwise "ones complement"
Data Type. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common.
Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to use the bitwise logical operators in programs ❏ To be able to use.
Operators Using Java operators An operator takes one or more arguments and produces a new value. All operators produce a value from their.
Bit Manipulation when every bit counts. Questions on Bit Manipulation l what is the motivation for bit manipulation l what is the binary, hexadecimal,
Chapter 20: Low-Level Programming Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 20 Low-Level Programming.
Bitwise operators. Representing integers We typically think in terms of decimal (base 10) numbers.  Why?  A decimal (or base 10) number consists of.
Bitwise operators. Representing integers We typically think in terms of decimal (base 10) numbers.  Why?  A decimal (or base 10) number consists of.
Bitwise Operators Fall 2008 Dr. David A. Gaitros
These notes were originally developed for CpSc 210 (C version) by Dr. Mike Westall in the Department of Computer Science at Clemson.
 2007 Pearson Education, Inc. All rights reserved C Structures, Unions, Bit Manipulations and Enumerations.
Programming III SPRING 2015 School of Computer and Information Sciences Francisco R. Ortega, Ph.D. McKnight Fellow and GAANN Fellow LECTURE #6 Structures,
Bit Fields & Bitwise Operations CS-2303, C-Term Bit Fields & Bitwise Operations CS-2303 System Programming Concepts (Slides include materials from.
Data Type. Syntax Rules Recap keywords breakdoubleifsizeofvoid caseelseintstatic..... Identifiers not#me123th scanfprintf _idso_am_igedd007 Constant ‘a’‘+’
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
Info stored in computer (memory) Numbers All in binaray – can be converted to octal, hex Characters ASCII – 1-byte/char Unicode – 2-byte/char Unicode-table.com/en.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
20. LOW-LEVEL PROGRAMMING. Bitwise Shift Operators The bitwise shift operators are: > right shift The expression i
Structures and Union. Review bitwise operations –you need them for performance in terms of space and time –shifts are equivalent to arithmetics enumeration.
Department of Electronic & Electrical Engineering Types and Memory Addresses Pointers & and * operators.
Free Ebooks Download Mba Ebooks By Edhole Mba ebooks Free ebooks download
Lecture 1 Data Structures Shafay Shamail September 05, 2006.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
Chapter 8 Bit Operations By C. Shing ITEC Dept Radford University.
Data Representation. Representation of data in a computer Two conditions: 1. Presence of a voltage – “1” 2. Absence of a voltage – “0”
Pointers as arrays C++ Programming Technologies. Pointers vs. Arrays Pointers and arrays are strongly related. In fact, pointers and arrays are interchangeable.
ME2008– W05 MID1- Reference 2016Q1- Source: Deitel /C- How To.
Integer VariablestMyn1 Integer Variables It must be possible to store data items in a program, and this facility is provided by variables. A variable is.
Overview Working directly with memory locations is beneficial. In C, pointers allow you to: change values passed as arguments to functions work directly.
Bitwise Operations C includes operators that permit working with the bit-level representation of a value. You can: - shift the bits of a value to the left.
CSE 220 – C Programming Bitwise Operators.
The Machine Model Memory
CISC/CMPE320 - Prof. McLeod
Bits and Bytes Hex Digit Bit Pattern
C Basics.
Data Type.
C Structures, Unions, Bit Manipulations and Enumerations
Data Type.
Chapter 14 Bitwise Operators Objectives
Bits and Bytes Topics Representing information as bits
Bits and Bytes Topics Representing information as bits
Bits and Bytes Topics Representing information as bits
Bits and Bytes Topics Representing information as bits
Bit Fields & Bitwise Operations
C Structures, Unions, Bit Manipulations and Enumerations
Comp Org & Assembly Lang
Bitwise operators.
Data Type.
Bitwise Operators.
C Language B. DHIVYA 17PCA140 II MCA.
Lecture 2: Bits, Bytes, Ints
Extra C Material Based on material in: The C Programming Language, Second Edition by Brian W. Kernighan and Dennis M. Ritchie. Prentice Hall, Inc., 1988. 
Presentation transcript:

Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training

Training C/C++ EcoSoftware 2 LOW-LEVEL PROGRAMMING o Bitwise operators. o Bitwise-Field structure o Other Low-Level Techniques

Training C/C++ EcoSoftware 3 Bitwise operators o Bitwise shift operators o Bitwise component And, Or o Using bitwise operators to access bits o Using bitwise operators to access Bit-Fields

Training C/C++ EcoSoftware 4 Bitwise operators o Bitwise shift operators o Using > (right shift). o Example :

Training C/C++ EcoSoftware 5 Bitwise component o List the remaining bitwise components. SymbolMeaning ~Bitwise component &Bitwise and ^Bitwise exclusive or |Bitwise inclusive or o Example.

Training C/C++ EcoSoftware 6 Using bitwise operator to access bits o Setting a bit  Example : Setting bit 4 for i; o Clearing a bit o Testing a bit

Training C/C++ EcoSoftware 7 Using bitwise operator to access Bit-Fields o Modifying a bit-field.  Using bitwise and, bitwise or for modifying a bit field. o Example : o Retrieving a bit-field  The bit-field at the right end of number (in the least significant bits),fetching its value easy.  Example :  Other you can first shift the bit-field to the end before extracting the field using & operator.  Example :

Training C/C++ EcoSoftware 8 Bit-Fields in structures o Using bit-fields we can define a C structure with identical layout.  Example : o The number after each member indicate it length of bit. o The type of bit-field must be either int, unsigned int, signed int.

Training C/C++ EcoSoftware 9 Other Low-Level Techniques o Defining Machine-Dependent Types  The char type –by definition – occupies one byte, We sometime treats character as bytes.  Using theme to store data that’s not necessarily in character form. typedef unsigned char BYTE;  Depend on the machine x86 architecture make extensive use of 16 bit words. That you can defines: typedef unsigned short WORD;

Training C/C++ EcoSoftware 10 Other Low-Level Techniques o Using pointer as address.  Create a pointer that represents is specific address easy.  We just cast an integer into a pointer. o Example :  BYTE *p;  p = (BYTE *)0x1000 // p content address 0x1000

Training C/C++ EcoSoftware 11 Example : View memory information

Training C/C++ EcoSoftware 12 Example : View memory information

Training C/C++ EcoSoftware 13 Example : View memory information o Using gcc test it on an x86 with linux.

Training C/C++ EcoSoftware 14 Thank You End