[BACK]Return to str.S CVS log [TXT][DIR] Up to [local] / sys / arch / vax / boot / common

Annotation of sys/arch/vax/boot/common/str.S, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: str.S,v 1.1 2002/06/11 09:36:24 hugh Exp $ */
                      2: /*     $NetBSD: str.S,v 1.1 2002/02/24 01:04:25 matt Exp $ */
                      3: /*
                      4:  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
                      5:  * All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  * 3. All advertising materials mentioning features or use of this software
                     16:  *    must display the following acknowledgement:
                     17:  *      This product includes software developed at Ludd, University of
                     18:  *      Lule}, Sweden and its contributors.
                     19:  * 4. The name of the author may not be used to endorse or promote products
                     20:  *    derived from this software without specific prior written permission
                     21:  *
                     22:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     25:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     26:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     27:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     28:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     29:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     30:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     31:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     32:  */
                     33:
                     34: /*
                     35:  * Small versions of the most common functions not using any
                     36:  * emulated instructions.
                     37:  */
                     38:
                     39: #include "asm.h"
                     40:
                     41: /*
                     42:  * atoi() used in devopen.
                     43:  */
                     44: ENTRY(atoi, 0)
                     45:        movl    4(ap),r1
                     46:        clrl    r0
                     47:
                     48: 2:     movzbl  (r1)+,r2
                     49:        cmpb    r2,$48
                     50:        blss    1f
                     51:        cmpb    r2,$57
                     52:        bgtr    1f
                     53:        subl2   $48,r2
                     54:        mull2   $10,r0
                     55:        addl2   r2,r0
                     56:        brb     2b
                     57: 1:     ret
                     58:
                     59: /*
                     60:  * index() small and easy.
                     61:  * doesnt work if we search for null.
                     62:  */
                     63: ENTRY(index, 0)
                     64:        movq    4(ap),r0
                     65: 1:     cmpb    (r0), r1
                     66:        beql    2f
                     67:        tstb    (r0)+
                     68:        bneq    1b
                     69:        clrl    r0
                     70: 2:     ret
                     71:
                     72: /*
                     73:  * cmpc3 is emulated on MVII.
                     74:  */
                     75: ENTRY(bcmp, 0)
                     76:        movl    4(ap), r2
                     77:        movl    8(ap), r1
                     78:        movl    12(ap), r0
                     79: 2:     cmpb    (r2)+, (r1)+
                     80:        bneq    1f
                     81:        decl    r0
                     82:        bneq    2b
                     83: 1:     ret
                     84:
                     85: /*
                     86:  * Is movc3/movc5 emulated on any CPU? I dont think so; use them here.
                     87:  */
                     88: ENTRY(bzero,0)
                     89:        movc5   $0,*4(ap),$0,8(ap),*4(ap)
                     90:        ret
                     91:
                     92: ENTRY(bcopy,0)
                     93:        movc3   12(ap), *4(ap), *8(ap)
                     94:        ret
                     95:
                     96: ENTRY(strlen, 0)
                     97:        movl    4(ap), r0
                     98: 1:     tstb    (r0)+
                     99:        bneq    1b
                    100:        decl    r0
                    101:        subl2   4(ap), r0
                    102:        ret
                    103:
                    104: ENTRY(strncmp, 0)
                    105:        movl    12(ap), r3
                    106:        brb     5f
                    107:
                    108: ENTRY(strcmp, 0)
                    109:        movl    $250, r3        # max string len to compare
                    110: 5:     movl    4(ap), r2
                    111:        movl    8(ap), r1
                    112:        movl    $1, r0
                    113:
                    114: 2:     cmpb    (r2),(r1)+
                    115:        bneq    1f              # something differ
                    116:        tstb    (r2)+
                    117:        beql    4f              # continue, strings unequal
                    118:        decl    r3              # max string len encountered?
                    119:        bneq    2b
                    120:
                    121: 4:     clrl    r0              # We are done, strings equal.
                    122:        ret
                    123:
                    124: 1:     bgtr    3f
                    125:        mnegl   r0, r0
                    126: 3:     ret
                    127:
                    128: ENTRY(strncpy, 0)
                    129:        movl    4(ap), r1
                    130:        movl    8(ap), r2
                    131:        movl    12(ap), r3
                    132:        bleq    2f
                    133:
                    134: 1:     movb    (r2)+, (r1)+
                    135:        beql    2f
                    136:        decl    r3
                    137:        bneq    1b
                    138: 2:     ret
                    139:
                    140: ENTRY(strcat, 0)
                    141:        pushl   4(ap)
                    142:        calls   $1,_C_LABEL(strlen)
                    143:        addl2   4(ap),r0
                    144:        movl    8(ap),r1
                    145: 1:     movb    (r1)+,(r0)+
                    146:        bneq    1b
                    147:        ret
                    148:
                    149: ENTRY(setjmp, 0)
                    150:        movl    4(ap), r0
                    151:        movl    8(fp), (r0)
                    152:        movl    12(fp), 4(r0)
                    153:        movl    16(fp), 8(r0)
                    154:        addl3   fp,$28,12(r0)
                    155:        clrl    r0
                    156:        ret
                    157:
                    158: ENTRY(longjmp, 0)
                    159:        movl    4(ap), r1
                    160:        movl    8(ap), r0
                    161:        movl    (r1), ap
                    162:        movl    4(r1), fp
                    163:        movl    12(r1), sp
                    164:        jmp     *8(r1)
                    165:

CVSweb