EasyManua.ls Logo

Texas Instruments TI-92+

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
Loading...
The code for the four bit manipulation functions is shown below, and some explanation follows the
listings.
Code for bitset() - set a bit
bitset(x,b)
Func
©(wordOrList,bit#) set bit#
©18may01/dburkett@infinet.com
local k,msg,type
"bitset() err"msg
gettype(x)type
when(type="NUM",when(b<0 or b>31,msg,exact(x or 2^b)),when(type="LIST",when(b<0
or b>32*dim(x)-1,msg,augment(left(x,k-1),augment({exact(x[k] or
2^(b-(k-1)*32))},right(x,dim(x)-k)))|k=1+intdiv(b,32)),msg))
EndFunc
Code for bitclr() - clear a bit
bitclr(x,b)
Func
©(wordOrList,bit#) clear bit#
©21may01/dburkett@infinet.com
local k,msg,type
"bitclr() err"msg
gettype(x)type
when(type="NUM",when(b<0 or b>31,msg,exact(x and not 2^b)),when(type="LIST",
when(b<0 or b>32*dim(x)-1,msg,augment(left(x,k-1),augment({exact(x[k] and not
2^(b-(k-1)*32))},right(x,dim(x)-k)))|k=1+intdiv(b,32)),msg))
EndFunc
Code for bitnot() - invert a bit
bitnot(x,b)
Func
©(wordOrList,bit#) invert bit#
©21may01/dburkett@infinet.com
local k,msg,type
"bitnot() err"msg
gettype(x)type
when(type="NUM",when(b<0 or b>31,msg,exact(x xor 2^b)),when(type="LIST",when(b<0
or b>32*dim(x)-1,msg,augment(left(x,k-1),augment({exact(x[k] xor
2^(b-(k-1)*32))},right(x,dim(x)-k)))|k=1+intdiv(b,32)),msg))
EndFunc
Code for bittst() - test bit status
bittst(x,b)
3 - 26

Table of Contents

Related product manuals