Dec 152017
 
QuickBasic 4.5 Bit Manipulation routines.
File QB45BITS.ZIP from The Programmer’s Corner in
Category BASIC Language
QuickBasic 4.5 Bit Manipulation routines.
File Name File Size Zip Size Zip Type
BITSTUF2.ASM 3485 1605 deflated
BITSTUF2.OBJ 339 311 deflated
BITSTUFF.ASM 1412 656 deflated
BITSTUFF.DOC 2443 1135 deflated
BITSTUFF.OBJ 267 225 deflated
BITSTUFF.QLB 5036 3186 deflated
BITTEST.BAS 1078 486 deflated
TPCREAD.ME 199 165 deflated

Download File QB45BITS.ZIP Here

Contents of the BITSTUFF.DOC file


Aug 12, 1989

This ARC contains the MASM source, .OBJ and .QLB for a set of bit-level
manipulation routines to use with QB/BC. If you make modifications, you'll
need MASM 5.1 to reassemble.

Routines are included to set, clear, toggle and examine the state of any
single bit in a 16-bit word. These allows the programmer to maintain 16
separate flags in a single integer, with quick access to any flag. If you
use global flags, you'll find these fast and convenient.

Also included are routines to convert between numeric values and binary
strings, for example "10011".

Uploaded to MSSYS for the free use of its members. Not copyrighted.
If you find these useful, drop me a note. Likewise, if you encounter any
problems or have comments or questions, please let me know at once:

Jim Mack [76630,2012] via MSSYS

Detailed descriptions follow. Also see the MASM source and the QB test
program for more information.



DECLARE SUB SetBit (bitnumber%, word%)
DECLARE SUB ClearBit (bitnumber%, word%)
DECLARE SUB ToggleBit (bitnumber%, word%)

WORD% is the 16-bit quantity where the selected bit resides.
Set, Clear and ToggleBit alter WORD% directly.

BITNUMBER% ranges from 1 to 16. If you exceed 16, what happens
depends on what processor you're using. Zero affects no bits.



DECLARE FUNCTION BitState% (bitnumber%, word%)

Returns a logical "true" (-1) if the selected bit is set in WORD%, or a
logical "false" (0) otherwise. WORD% is not altered.



DECLARE FUNCTION BitStr$ (word%)

Returns a 16-character string of ASCII ones and zeros with a "1" in
each position where a bit is set in WORD%. For example, passing 12
returns the string "0000000000001100".



DECLARE FUNCTION BitVal& (binar$)

Returns a long integer quantity reflecting the value of a passed string
of ASCII ones and zeroes. BINAR$ can contain any number of digits, but
only the first 16 are evaluated. If it contains fewer than 16 digits,
they are considered as the less significant bits (i.e. "01" is taken to
mean "0000000000000001" and evaluates to 1). Strings which contain
*any* other character in the first 16 positions are rejected, and a
value of zero returned.




 December 15, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)