🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #22197

Re: Byte ordering

#22197
From: Alan Lovejoy
Date: Wed, 07 Feb 1990 05:04
55 lines
3299 bytes
In article <1910@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes:
>The raster problem corresponds to fixed point fractions; when truncating,
>the most significant part is used.  This is easier in big endian.

As much as I like big-endianness, I beg to disagree.  Have you ever implemented
BitBlt?  I have.  In the general case, you have to splice words ON BOTH SIDES
of each line in the bitmap.  On the the left end of the line, you want to
combine the leftmost bits of the word in the destination bitmap with the 
rightmost bits in the word from the source bitmap.  On the right end of the 
line, you want to combine the leftmost bits of the word from the source bitmap 
with rightmost bits of the word in the destination bitmap.  (All the above 
assumes that the leftmost bit in a word represents the leftmost pixel.)

Also, there are generally two ways to clear a word of unwanted bits, if you
are restricted to the standard shift and mask instructions (special bitfield
and/or graphics instructions may provide other options).  One way is to
code "dataWord & mask."  The other way is "((dataWord >> bits) << bits)."
Normally, one prepares masks outside the BitBlt loop as follows:

...code which calculates the left and right pivot bits mercifully omitted..
leftSrcMask = ((~0 << leftPivotBit) >> leftPivotBit);
leftDstMask = ~leftSrcMask;
rightSrcMask = ((~0 >> rightPivotBit) << rightPivotBit);
rightDstMask = ~rightSrcMask;

The leftmost word to be copied in each line is then "blitted" as follows:

(The following code assumes that the pixel bits happen to be aligned in the
source and destination bitmaps.)

srcWord = *srcPtr++;
destWord = *destPtr;
*destWPtr++ = (srcWord & leftSrcMask) | (destWord & leftDstMask);

The rightmost word to be copied is blitted thusly:

srcWord = *srcPtr++;
destWord = *destPtr;
*destPtr++ = (srcWord & rightSrcMask) | (destWord & rightDstMask);

I fail to see any advantage here for big-endian over any other constistent, 
contiguous byte ordering.  But perhaps you had something else in mind?

Of course, it would be nice if there were a single machine instruction that
could achieve the effect of "(srcWord & mask) | (destWord & ~mask)," where
"mask" is either a field of 1 bits followed by a field of zero bits, or else
vice versa.

	


____"Congress shall have the power to prohibit speech offensive to Congress"____
Alan Lovejoy; alan@pdn; 813-530-2211; AT&T Paradyne: 8550 Ulmerton, Largo, FL.
Disclaimer: I do not speak for AT&T Paradyne.  They do not speak for me. 
Mottos:  << Many are cold, but few are frozen. >>     << Frigido, ergo sum. >>
Technical Details
Message-ID: <7345@pdn.paradyne.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!mephisto!uflorida!usfvax2!tscs!pdn!oz!alan
References: <9656@spool.cs.wisc.edu> <1990Feb2.215421.24894@utzoo.uucp> <1991@osc.COM> <1910@l.cc.purdue.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!mephisto!uflorida!usfvax2!tscs!pdn!oz!alan
From: alan@oz.nm.paradyne.com (Alan Lovejoy)
Newsgroups: comp.arch
Subject: Re: Byte ordering
Keywords: byte sex
Message-ID: <7345@pdn.paradyne.com>
Date: 7 Feb 90 05:04:33 GMT
References: <9656@spool.cs.wisc.edu> <1990Feb2.215421.24894@utzoo.uucp> <1991@osc.COM> <1910@l.cc.purdue.edu>
Sender: usenet@pdn.paradyne.com
Reply-To: alan@oz.paradyne.com (Alan Lovejoy)
Organization: AT&T Paradyne, Largo, Florida
Lines: 55