EasyManuals Logo
Home>Texas Instruments>Calculator>TI-92+

Texas Instruments TI-92+ User Manual

Texas Instruments TI-92+
507 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #106 background imageLoading...
Page #106 background image
We can simultaneously test several status flags by using a mask. A mask is simply an integer with
certain bits set or cleared, as needed to perform some desired operation. We will use the built-in
boolean operators and, or, xor and not to perform mask operations. For example, suppose we want to
execute a block of code if flags 0, 4 and 7 are all set. The mask to test these flags would be
0b10010001, and the code would look like this:
if status and 0b10010001=0b1001 0001 then
... {block} ...
endif
The result of and-ing the mask with status will only equal the mask if the mask bits are set. This
method also provide more flexibility than the corresponding test with separate boolean variables,
because the mask can be a variable, which can be changed depending on program requirements.
We can also use masks to perform other manipulations and tests. First, these truth tables show the
operation of the built-in boolean operators.
011111111
101101001
110110010
000000000
a xor bbaa or bbaa and bba
You can use these truth tables to determine the mask values and boolean operators needed to perform
different tests and manipulations, as shown:
flags = 0b0101
mask = 0b0110
flags and mask =
0b0100
result = true
flags and mask 00: ignore the flag bit in
the test.
1: include the flag bit in
the test
Return true if any of a
group of flags are set
flags = 0b0111
mask = 0b0110
flags and mask =
0b0110
result = true
flags and mask = mask0: ignore the flag bit in
the test.
1: include the flag bit in
the test
Return true if all of a
group of flags are set
flags = 0b1010
result = 0b0101
not flags(none)Invert all the flags
Invert flags 1 and 2:
flags = 0b0011
mask = 0b0110
result = 0b0101
flags xor mask0: the corresponding
flag bit is unchanged.
1: the corresponding
flag bit is inverted
Invert a group of flags
Clear flags 0 and 3:
flags = 0b0111
mask = 0b1001
result = 0b0001
flags and mask0: the corresponding
flag bit is cleared.
1: the corresponding
flag bit is unchanged
Clear a group of flags
Set flags 2 and 3:
flags = 0b0001
mask = 0b1100
result = 0b1101
flags or mask0: the corresponding
flag bit is unchanged.
1: The corresponding
flag bit is set.
Set a group of flags
ExampleOperationMask bit descriptionDescription
Masks can be used with lists of integers, as well as with individual integers. For example, suppose that
flags = {0b0110,0b1100} and mask = {0b1111,0b1000}, then
3 - 24

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TI-92+ and is the answer not in the manual?

Texas Instruments TI-92+ Specifications

General IconGeneral
BrandTexas Instruments
ModelTI-92+
CategoryCalculator
LanguageEnglish

Related product manuals