Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training."— Presentation transcript:

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

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

3 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

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

5 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.

6 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

7 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 :

8 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.

9 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;

10 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

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

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

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

14 Training C/C++ EcoSoftware 14 Thank You End


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

Similar presentations


Ads by Google