Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!hplabs!hpda!hpcuhb!hpcllla!hpclisp!hpclkwp!karl From: karl@hpclkwp.HP.COM (Karl Pettis) Newsgroups: comp.arch Subject: Re: Endian reversing MOVEs Message-ID: <650007@hpclkwp.HP.COM> Date: 13 Feb 89 23:05:10 GMT References: <759@atanasoff.cs.iastate.edu> Organization: Hewlett-Packard Calif. Language Lab Lines: 27 On the Hewlett-Packard Precision Architecture, reversing the bytes in a word can be done in three instructions: ; r1 = "ABCD" SHD r1,r1,16,r2 ; r2 = "CDAB" DEP r2,15,8,r2 ; r2 = "CBAB" SHD r1,r2,8,r2 ; r2 = "DCBA" Explanation: SHD r1,r2,p,t ; Shift Double Concatenates r1 and r2 and shifts the combination right by p bits, putting the low 32 bits of the result into t. DEP r,p,len,t ; Deposit Takes the len low order bits of r and places them into register t with the least significant bit at position p. Other bits of t are unchanged. HPPA numbers bits in a word in big-endian order: 0..31. This code was devised by Jerry Huck. I'm just posting it. - Karl Pettis karl@hpda