        .title  str
        .psect  $CODE quad,pic,con,lcl,shr,exe,nowrt
        .entry  str_hash,^m<r2,r3,r4>
        movl    B^4(ap),r0
        movl    B^4(r0),r1              ; address of string
        movzwl  (r0),r2                 ; length of string
        movl    @B^8(ap),r4             ; modulo
        movl    #0,r0                   ; result=0
        cmpl    #256,r4                 ; test if modulo>256
        bgtr    200$
100$:   cmpl    #1,r2                   ; test if lengt=1
        bgeq    200$
        movzwl  (r1),r3                 ; result=result+word
        addl2   r3,r0
        addl2   #2,r1
        subl2   #2,r2
        brb     100$
200$:   tstl    r2
        bleq    300$
        movzbl  (r1),r3                 ; result=result+byte
        addl2   r3,r0
        incl    r1
        decl    r2
        brb     100$
300$:   divl3   r4,r0,r2                ; result=MOD(result,modulo)
        mull2   r4,r2
        subl2   r2,r0
        ret
        .entry  str_init,^m<r2,r3,r4,r5>
        movl    B^4(ap),r1
        movl    B^8(ap),r2
        movc5   #0,#0,@B^4(r2),(r1),@B^4(r1)
        ret
        .end
