BitManipulation - Bit Manipulation Bit Manipulation 5.1...

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

View Full Document Right Arrow Icon
Bit Manipulation Beta Draft - Do not distribute © 2001, By Randall Hyde Page 909 Bit Manipulation Chapter Five 5.1 Chapter Overview Manipulating bits in memory is, perhaps, the thing that assembly language is most f amous for . Indeed, one of the reasons people claim that the “C” programming language is a “medium-le v el” language rather than a high le v el language is because of the v ast array of bit manipulation operators that it pro vides. Ev en with this wide array of bit manipulation operations, the C programming language doesn’ t pro vide as com - plete a set of bit manipulation operations as assembly language. This chapter will discuss ho w to manipulate strings of bits in memory and re gisters using 80x86 assem - bly language. This chapter be gins with a re vie w of the bit manipulation instructions co v ered thus f ar and it also introduces a fe w ne w instructions. This chapter re vie ws information on packing and unpacking bit strings in memory since this is the basis for man y bit manipulation operations. Finally , this chapter dis - cusses se v eral bit-centric algorithms and their implementation in assembly language. 5.2 What is Bit Data, Anyway? Before describing ho w to manipulate bits, it might not be a bad idea to defi ne e xactly what this te xt means by “bit data. Most readers probably assume that “bit manipulation programs” twiddle indi vidual bits in memory . While programs that do this are defi nitely “bit manipulation programs, ” we’ re not going to limit this title to just those programs. F or our purposes, bit manipulation refers to w orking with data types that consist of strings of bits that are non-contiguous or are not an e v en multiple of eight bits long. Generally , such bit objects will not represent numeric inte gers, although we will not place this restriction on our bit strings. A bit string is some contiguous sequence of one or more bits (this term e v en applies if the bit string’ s length is an e v en multiple of eight bits). Note that a bit string does not ha v e to start or end at an y special point. F or e xample, a bit string could start in bit se v en of one byte in memory and continue through to bit six of the ne xt byte in memory . Lik e wise, a bit string could be gin in bit 30 of EAX, consume the upper tw o bits of EAX, and then continue from bit zero through bit 17 of EBX. In memory , the bits must be ph ysically contiguous (i.e., the bit numbers are al w ays increasing e xcept when crossing a byte boundary , and at byte boundaries the byte number increases by one). In re gisters, if a bit string crosses a re gister boundary , the application defi nes the continuation re gister b ut the bit string al w ays continues in bit zero of that second re g - ister . A
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/08/2011 for the course CS 101 taught by Professor Jitenderkumarchhabra during the Summer '11 term at National Institute of Technology, Calicut.

Page1 / 26

BitManipulation - Bit Manipulation Bit Manipulation 5.1...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online