1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * %sccs.include.proprietary.c% 9 */ 10 11#ifndef lint 12 .asciz "@(#)s_cmp_s.s 5.2 (Berkeley) 04/12/91" 13#endif /* not lint */ 14 15.data 16.text 17LL0:.align 1 18.globl _s_cmp 19.set MASK__,0x1004 20.data 21.text 22_s_cmp:.word MASK__ 23movl 4(fp),r0 /* a */ 24movl 8(fp),r1 /* b */ 25movl 12(fp),r12 /* la */ 26cmpl r12,16(fp) /* if (la <= lb) */ 27jgtr L17 28movl r12, r2 /* compare according to la */ 29cmps3 30jeql L2 /* if not equal */ 31 32L20: 33cvtbl (r0), r0 /* return(*a - *b) */ 34cvtbl (r1), r1 35subl2 r1,r0 36ret 37 38L2: 39cmpl r12,16(fp) /* if (la == lb) */ 40jneq L50 41clrl r0 /* then strings are equal */ 42ret 43 44L50: 45addl3 8(fp), 16(fp), r12 /* r12 = bend */ 46 47L3: 48cmpb (r1), $32 /* if *b != space */ 49jeql L4 50cvtbl (r1), r1 51movl $32, r0 /* return(' ' - *b) */ 52subl2 r1, r0 53ret 54 55L4: /* else loop */ 56incl r1 57cmpl r1, r12 58jlssu L3 /* till bend */ 59clrl r0 60ret /* strings equal: return(0) */ 61 62 63L17: /* else */ 64movl 16(fp), r2 /* compare according to lb */ 65cmps3 66jneq L20 /* if not equal */ 67 /* return(*a - *b) */ 68addl3 4(fp), 12(fp), r12 /* r12 = aend */ 69 70L30: 71cmpb (r0), $32 /* if *a != space */ 72jeql L40 73cvtbl (r0), r0 74movl $32, r1 /* return(*a - ' ') */ 75subl2 r1, r0 76ret 77 78L40: /* else loop */ 79incl r0 80cmpl r0, r12 81jlssu L30 /* till bend */ 82clrl r0 83ret /* strings equal: return(0) */ 84 85