Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!ames!amdcad!weitek!mahar From: mahar@weitek.UUCP (Mike Mahar) Newsgroups: comp.arch Subject: Re: Endian reversing MOVEs Message-ID: <412@attila.weitek.UUCP> Date: 27 Feb 89 18:18:40 GMT References: <759@atanasoff.cs.iastate.edu> <772@atanasoff.cs.iastate.edu> <24618@amdcad.AMD.COM> Reply-To: mahar@attila.UUCP (Mike Mahar) Organization: WEITEK Corporation, Sunnyvale, CA Lines: 50 In article <24618@amdcad.AMD.COM> rpw3@amdcad.amd.com (Rob Warnock) writes: >Took me a little while to get around to it, but below is a fast (4 cycle) >byte-swap for the Am29000, to round out the mix. And here's what I've seem >to date: > > machine who reported language cycles notes > ======= ============ ======== ====== ===== > 29k rpw3@amd C 10 > MIPS mashey@mips C 9 > ARM rwilson@acorn C 7 > VAX bimadre@kulcs assembler 5 Instr., not cycles! > 88k klossner@tek assembler 7 (2+5n, maybe?) > ARM rwilson@acorn assembler 4 1+3n > 29k rpw3@amd assembler 4 1+3n > The Weitek XL-Series has an instruction "perfect exchange". It is capable of swaping just about any thing. It does a half word swap, a byte swap, a nybble swap, or a bit swap. pexch rb,im5,ra ra,rb - registers im5 - 5 bit immediate This instruction performs a perfect exchange among the bits of the contents of register rb. The result is placed in register ra. The bits in the immediate field control which parts of the word are exchanged. The most significant bit, of the immediate field, causes the upper half- word to be exchanged with the lower halfword. The second most significant bit causes the lower two bytes to be exchanged and the upper two bytes to be exchanged. The least significant bit in the immediate field causes each pair of adjacent bits to be ex- changed. Assume the immediate field is 1 1 1 1 1. a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F - original word q r s t u v w x y z A B C D E F a b c d e f g h i j k l m n o p - bit 4 applied y z A B C D E F q r s t u v w x i j k l m n o p a b c d e f g h - bit 3 applied C D E F y z A B u v w x q r s t m n o p i j k l e f g h a b c d - bit 2 applied E F C D