/*1* arch/alpha/lib/strncpy.S2* Contributed by Richard Henderson ([email protected])3*4* Copy no more than COUNT bytes of the null-terminated string from5* SRC to DST. If SRC does not cover all of COUNT, the balance is6* zeroed.7*8* Or, rather, if the kernel cared about that weird ANSI quirk. This9* version has cropped that bit o' nastiness as well as assuming that10* __stxncpy is in range of a branch.11*/1213.set noat14.set noreorder1516.text1718.align 419.globl strncpy20.ent strncpy21strncpy:22.frame $30, 0, $2623.prologue 02425mov $16, $0 # set return value now26beq $18, $zerolen27unop28bsr $23, __stxncpy # do the work of the copy2930unop31bne $18, $multiword # do we have full words left?32subq $24, 1, $3 # nope33subq $27, 1, $43435or $3, $24, $3 # clear the bits between the last36or $4, $27, $4 # written byte and the last byte in COUNT37andnot $3, $4, $438zap $1, $4, $13940stq_u $1, 0($16)41ret4243.align 444$multiword:45subq $27, 1, $2 # clear the final bits in the prev word46or $2, $27, $247zapnot $1, $2, $148subq $18, 1, $184950stq_u $1, 0($16)51addq $16, 8, $1652unop53beq $18, 1f5455nop56unop57nop58blbc $18, 0f5960stq_u $31, 0($16) # zero one word61subq $18, 1, $1862addq $16, 8, $1663beq $18, 1f64650: stq_u $31, 0($16) # zero two words66subq $18, 2, $1867stq_u $31, 8($16)68addq $16, 16, $1669bne $18, 0b70711: ldq_u $1, 0($16) # clear the leading bits in the final word72subq $24, 1, $273or $2, $24, $27475zap $1, $2, $176stq_u $1, 0($16)77$zerolen:78ret7980.end strncpy818283