lecture29-apr9

# lecture29-apr9 - Lecture 29 Announcements Monday lectures...

This preview shows pages 1–2. Sign up to view the full content.

4/9/10 1 Lecture 29 Announcements Monday lectures cancelled • Exam 2 - back – High = 99 – Low = 17.5 – Median = 74.5 – Average = 73.5 • Assignment 6 Last time we learned how to: Shift bit values left and right Set, clear, toggle and test Single bits within a value Bit Felds within a value Topics of the day More Low level programming Bit structure operations Examples – parity checker Swap the bytes example unsigned short int i , high_byte, low_byte; scanf (“%hu”, &i); high_byte = i << 8; low_byte = i >> 8; i = high_byte | low_byte; Other ways??? Rotate i by 8 bits (left or right) ?? unsigned short int rotate(unsigned short int value, int numbits, char direction); How do you swap the upper and lower bytes of a 16 bit value ? Bit-±ields in Structures A structure may contain bit-Felds—members whose size is speciFed as some number of bits. E.g. some OS’s stores Fle dates as struct Fle_date { unsigned int day: 5; unsigned int month: 4; unsigned int year: 7; /* last 2 digits of year – e.g. 2010 -> 10 */ }; The order in which bit-Felds are allocated within a storage unit depends on the implementation (e.g.Visual C/C++ allocates right to left). – Basic storage units are typically bytes and words A bit-Feld can be used just like any other element of a structure: struct Fle_date fd;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 08/30/2010 for the course EE 312 taught by Professor Shafer during the Spring '08 term at University of Texas.

### Page1 / 3

lecture29-apr9 - Lecture 29 Announcements Monday lectures...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online