Annotation of researchv10no/libc/gen/strpbrk.s, revision 1.1

1.1     ! root        1:        .file   "strpbrk.s"
        !             2: #      @(#)strpbrk.s   1.5
        !             3: # Fast assembler language version of the following C-program
        !             4: #                      strpbrk
        !             5: # which represents the `standard' for the C-library.
        !             6: 
        !             7: #  Return ptr to first occurance of any character from `brkset'
        !             8: #    in the character string `string'; NULL if none exists.
        !             9: 
        !            10: #      char *
        !            11: #      strpbrk(string, brkset)
        !            12: #      register char *string, *brkset;
        !            13: #      {
        !            14: #              register char *p;
        !            15: #      
        !            16: #              if(!string || !brkset)
        !            17: #                      return(0);
        !            18: #              do {
        !            19: #                      for(p=brkset; *p != '\0' && *p != *string; ++p)
        !            20: #                              ;
        !            21: #                      if(*p != '\0')
        !            22: #                              return(string);
        !            23: #              }
        !            24: #              while(*string++);
        !            25: #              return(0);
        !            26: #      }
        !            27:        .globl  _strpbrk
        !            28:        .text
        !            29:        .align  2
        !            30: _strpbrk:
        !            31:        .word   0x0000                  # pgm uses regs 0,1,2,3,4
        !            32:        movab   -256(sp),sp             # get table space
        !            33:        movc5   $0,(ap),$0,$256,(sp)    # and zero it out
        !            34:        movl    8(ap),r0                # charset ptr in r0
        !            35:        beql    L5                      # return 0 if arg was NULL
        !            36: L0:
        !            37:        movzbl  (r0)+,r3                # byte from charset for index
        !            38:        beql    L1                      # hop if found ending NULL
        !            39:        movb    $255,(sp)[r3]           # make entry in scanc table
        !            40:        jmp     L0                      # get next byte from charset
        !            41: L1:
        !            42:        movl    4(ap),r1                # string ptr in r1
        !            43:        beql    L4                      # if it's NULL, return 0
        !            44: L2:
        !            45:        movl    r1,r4                   # preserve a copy of this ptr
        !            46:        locc    $0,$65535,(r1)          # get length of string
        !            47:        bneq    L3                      # skip if string not > 65535
        !            48:        scanc   $65535,(r4),(sp),$255   # else scanc the first 65535
        !            49:        bneq    L4                      # hop ahead if we found one
        !            50:        jmp     L2                      # else go back and do next 65535
        !            51: L3:
        !            52:        subl3   r4,r1,r0                # length to end of string in r0
        !            53:        scanc   r0,(r4),(sp),$255       # this is the main function
        !            54:        beql    L5                      # skip if none (r0 already 0)
        !            55: L4:
        !            56:        movl    r1,r0                   # return ptr to brk char
        !            57: L5:
        !            58:        movab   256(sp),sp              # restore the stack pointer
        !            59:        ret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.