2 ; Ullrich von Bassewitz, 2003-05-04
4 ; char* __fastcall__ strncpy (char* dest, const char* src, unsigned size);
9 .importzp ptr1, ptr2, tmp1, tmp2, tmp3
17 sta tmp2 ; Store -size - 1
25 stx tmp3 ; remember for function return
27 ; Copy src -> dest up to size bytes
29 ldx tmp1 ; Load low byte of ones complement of size
36 L2: lda (ptr1),y ; Copy one character
38 beq L3 ; Bail out if terminator reached
42 inc ptr2+1 ; Bump high bytes
43 bne L1 ; Branch always
45 ; Fill the remaining bytes. A is zero if we come here
55 inc ptr2+1 ; Bump high byte
56 bne L3 ; Branch always
60 L9: lda ptr2 ; Get low byte
61 ldx tmp3 ; Get unchanged high byte