Path: utzoo!attcan!uunet!lll-winken!ames!amdcad!crackle!tim From: tim@crackle.amd.com (Tim Olson) Newsgroups: comp.arch Subject: Re: Endian wars Message-ID: <24238@amdcad.AMD.COM> Date: 27 Jan 89 16:26:52 GMT References: <6133@columbia.edu> <5124@aldebaran.UUCP> Sender: news@amdcad.AMD.COM Reply-To: tim@amd.com (Tim Olson) Organization: Advanced Micro Devices, Inc. Sunnyvale CA Lines: 36 Summary: Expires: Sender: Followup-To: In article <5124@aldebaran.UUCP> jimp@cognos.UUCP (Jim Patterson) writes: | In article <6133@columbia.edu> eppstein@garfield (David Eppstein) writes: | >Big endian lets you use integer comparison instructions to do string | >compares a word at a time. Little endian means you are stuck with a | >byte at a time. | | I'd like to see an algorithm that actually benefits from this. | Consider... | | If you don't know how long the string is (as for strcmp and strncmp), | then you have to scan the string to find how long it is. For a | word-oriented algorithm to be effective here, you need an algorithm | which detects which byte of a word (if any) contains a NUL. | | If anyone has any good word-oriented implementations of memcmp or | especially strcmp, I'd be interested in seeing them. A couple of years ago I posted essentially the string routines we use on the Am29000. These routines make use of: 1) comparisons a word at a time 2) the "cpbyte" instruction to detect a null byte in a word 3) the "extract" instruction (extract a 32-bit word from a 64-bit word pair at any bit boundary) to take care of misaligned operands These routines broke even with a standard byte-at-a-time hand-coded routine with 5-byte strings (including null) and were always better with longer strings. -- Tim Olson Advanced Micro Devices (tim@crackle.amd.com)