Dec 122017
 
Bit-level routines for QuickBASIC, includes ASM source.
File QBBITS.ZIP from The Programmer’s Corner in
Category BASIC Language
Bit-level routines for QuickBASIC, includes ASM source.
File Name File Size Zip Size Zip Type
BITSTUF2.ASM 3485 1583 deflated
BITSTUF2.OBJ 339 302 deflated
BITSTUFF.ASM 1412 651 deflated
BITSTUFF.DOC 2443 1118 deflated
BITSTUFF.OBJ 267 225 deflated
BITSTUFF.QLB 5036 3082 deflated
BITTEST.BAS 1078 484 deflated
TPCREAD.ME 199 165 deflated

Download File QBBITS.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 12, 2017  Add comments

Leave a Reply