appletasm.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletasm.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include <ctype.h>
00008 
00009 #include "appletdefs.h"
00010 #include "appletasm.h"
00011 
00012 
00013 #ifdef THINK_C
00014 boolean fastunicaseequalstrings (bigstring bs1, bigstring bs2) {
00015 
00016     /*
00017     return true if the two strings (pascal type, with length-byte) are
00018     equal, ignoring case.
00019     */
00020     
00021     asm {
00022         /*
00023         register usage:
00024             d0 - scratch, return value
00025             d1 - *bs1
00026             d2 - *bs2
00027             d3 - "ct"
00028             
00029             a0 - scratch
00030             a1 - "bs1"
00031             a2 - "bs2"
00032         */
00033         
00034         movem.l d3/a2,-(a7)
00035         
00036 #ifdef THINK_C
00037         movea.l bs1,a1
00038         movea.l bs2,a2
00039 #endif
00040         
00041         moveq   #0,d1       ; clear high bytes
00042         moveq   #0,d2
00043         
00044         moveq   #0,d3       ; length of bs1
00045         move.b  (a1)+,d3
00046         
00047         cmp.b   (a2)+,d3    ; compare lengths
00048         beq.s   @1
00049         
00050         moveq   #0,d0       ; different lengths, return false
00051         bra.s   @9
00052         
00053     @1  subq.w  #1,d3       ; length exhausted?
00054         bge.s   @2
00055         
00056         moveq   #1,d0       ; yes, strings are equal
00057         bra.s   @9
00058         
00059     @2  move.b  (a1)+,d1    ; get *bs1++
00060         
00061         lea     __ctype,a0  ; isupper?
00062         adda.l  d1,a0
00063         btst    #6,(a0)
00064         beq.s   @3
00065         
00066         moveq   #0x20,d0    ; tolower
00067         eor.w   d0,d1
00068         
00069     @3  move.b  (a2)+,d2    ; get *bs2++
00070         
00071         lea     __ctype,a0  ; isupper?
00072         adda.l  d2,a0
00073         btst    #6,(a0)
00074         beq.s   @4
00075         
00076         moveq   #0x20,d0    ; tolower
00077         eor.w   d0,d2
00078         
00079     @4  cmp.w   d1,d2       ; characters equal?
00080         beq.s   @1
00081         
00082         moveq   #0,d0
00083         
00084     @9
00085         movem.l (a7)+,d3/a2
00086     }
00087     } /*fastunicaseequalstrings*/
00088 #else
00089 boolean fastunicaseequalstrings (bigstring bs1, bigstring bs2)
00090 {
00091     char    c1, c2;
00092     short   i = 1;
00093     
00094     // if the lengths aren't equal, fail!
00095     if (bs1[0] != bs2[0])   return false;
00096     
00097     while (i <= bs1[0]) {
00098         c1 = bs1[i];    c2 = bs2[i];
00099         
00100         if (c1 != c2) { // if not equal as is, fix the case
00101             if ((c1 >=97) && (c1 <=122))    c1 -= 0x020;
00102             if ((c2 >=97) && (c2 <=122))    c2 -= 0x020;
00103             
00104             if (c1 != c2)   return false;   // they're not equal, so fail!
00105         }
00106     }
00107     
00108     // we get this far, we're equal!
00109     return true;
00110 }
00111 #endif
00112 

Generated on Wed May 31 18:19:39 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6