13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

You can then access the value of EXPR as single bits, by extracting theelements of MAGIC.BITS. For instance, MAGIC.BITS[13] will be TRUE if the14th bit of the value of EXPR is a 1; FALSE if it is a 0. You can change thevalue of MAGIC.BITS by operating logically on its bit elements, and thenuse MAGIC.DAT A as an expression of type DTYPE with the new value.Or, you can access the value of EXPR as a sequence of 16-bit patterns byextracting the elements of MAGIC.WORDS. You can operate on thesepatterns logically, as described below under "Bit Pattern Logic." You canthen assign the resulting new patterns back to MAGIC.WORDS and useMAGIC.DATA as their DTYPE equivalent.Bit Pattern logicAlthough the logical operators NOT, AND, and OR nominally affect only theleast significant bit of a boolean value, they actually operate on all the bits.Thus they can be used on the entire 16-bit patterns of data words whenthose words are typed as boolean.Applying NOT to a bit pattern complements all the bits; it changes l's to O'sand O's to l's.The operator AND between two bit patterns lets you mask out certain bits.You create a fixed mask pattern by setting certain bits to 1; when combinedwith a data pattern using AND, only the data bits in those positions will"drop through" to the result. AND also lets you clear bits; those that don't"drop through" are in effect set to 0.The operator OR between two bit patterns lets you set bits. You create afixed pattern in which certain bits are set to l; when combined with a datapattern using OR, the data bits in those positions will be set to 1 in theresult.The exclusive-or operation between two bit patterns lets you determine ifthey are identical by checking whether the result is all O's. You can also useexclusive-or to complement selected bits. To apply this operation tobooleans X and Y, writeCCX AND NOT Y) DR CNDT X AND Y>>III-102Chapter 6: Operations on Data

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!