From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,3557f675db944df6 X-Google-Attributes: gid1164f8,public From: edlee@chinet.chinet.com (Edward Lee) Subject: Re: Suggested Change to Alpha Books (Correction) Date: 1997/07/17 Message-ID: <5qm91a$3lc$1@chinet.chinet.com>#1/1 X-Deja-AN: 257525399 References: <5qgipn$7q1$1@chinet.chinet.com> <5qlpi7$g3c@usenet.pa.dec.com> Organization: A poorly-installed InterNetNews site Newsgroups: comp.sys.dec In article <5qlpi7$g3c@usenet.pa.dec.com>, Stephen Hoff Hoffman wrote: > The following response is a quote from one of the folks responsible > for the Alpha Architecture Reference Manual (ARM): > >"[....] > >Assuming one wants to compare NUL-terminated strings, as in C's >strcmp routine, your suggested replacement code would work. Note >that if control reaches your "NOTEQUAL" label, the strings might >still be equal up to the terminating NUL in each string. I was assuming that the ends of strings would be padded with '\0' characters up to the next quadword boundary if someone were to go to the trouble of quadword aligning every string. I should have stated that. >We may change the ARM example to something like the following: > > >To compare two null-terminated strings for greater/equal/less: > > > >LOOP: > LDQ R3, 0(R1) ; Pick up 8 bytes of string1 > LDA R1, 8(R1) ; Increment string1 pointer > LDQ R4, 0(R2) ; Pick up 8 bytes of string2 > LDA R2, 8(R2) ; Incremente string2 pointer > CMPBGE R31, R3, R6 ; Test for zeros in string1 > XOR R3, R4, R5 ; Test for all equal bytes > BNE R6, DONE ; Exit if a zero found > BEQ R5, LOOP ; Else repeat if all equal >DONE: CMPBGE R31, R5, R5 ; > ... >; At this point, R5 can be used to determine the first not-equal >; byte position (if any), and R6 can be used to determine the >; position of the terminating zero in string 1 (if any). >[....] In my suggested code change, I deliberately tried to keep the number of registers that were used down to the original 5. The code above looks fine to me as well. Thanks for the prompt response. -Ed L