Article View: comp.arch
Article #12919Re: Bit operations on 68K
From: gnu
Date: Sat, 31 Jan 1987 12:57
Date: Sat, 31 Jan 1987 12:57
35 lines
2282 bytes
2282 bytes
The 68020 introduced a new set of 8 instructions that operate on bit
FIELDS rather than BITS. The old BIT instructions were:
BTST, BSET, BCLR, BCHG
and they numbered bits in little endian order, modulo 32 in registers
or modulo 8 on a memory address. The little endian order was to avoid
confusing hardware engineers who knew that pin "D0" was the low order
pin; they could code "BTST #0" and get the same bit. Unfortunately it
confused the programmers who didn't know anything about pins but they
sure knew that the rest of the machine was big endian. These instructions
only operate on a single bit at a time.
In the 68020, these BIT FIELD instructions were added:
BFTST, BFSET, BFCLR, BFCHG, BFINS, BFEXTS, BFEXTU, BFFFO
(the last four are insert, extract signed, extract unsigned, and find
first one). These number bits big-endian and will accept any bit
number relative to a byte address and figure out where it really
belongs (e.g. you can ask for bit 1005 and it will find it.) Finally
the bit order is the same as the byte order. This makes arrays of bit
fields work just fine and is also nice for accessing bitmapped
displays. These instructions take both a starting bit number and a
width -- they operate on 1 to 32 bits, and are smart about 32 bit
fields lying across multiple words of memory and such.
Probably the guy who mentined "BSET.L" just meant "BFSET". Various other
instructions got extended with ".L" so this is an easy mistake to make.
Can we stop talking about this?
--
John Gilmore {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu gnu@ingres.berkeley.edu
Love your country but never trust its government.
-- from a hand-painted road sign in central Pennsylvania
Technical Details
Message-ID:
<1703@hoptoad.uucp>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!decwrl!sun!hoptoad!gnuReferences:
<760@orcisi.UUCP> <112@lmi-angel.UUCP> <816@drivax.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!decwrl!sun!hoptoad!gnu From: gnu@hoptoad.UUCP Newsgroups: comp.arch,comp.sys.m68k Subject: Re: Bit operations on 68K Message-ID: <1703@hoptoad.uucp> Date: Sat, 31-Jan-87 07:57:23 EST Article-I.D.: hoptoad.1703 Posted: Sat Jan 31 07:57:23 1987 Date-Received: Sun, 1-Feb-87 12:15:32 EST References: <760@orcisi.UUCP> <112@lmi-angel.UUCP> <816@drivax.UUCP> Organization: Nebula Consultants in San Francisco Lines: 35