2 ; Ullrich von Bassewitz, 31.05.1998
4 ; char* strncpy (char* dest, const char* src, unsigned size);
9 .importzp ptr1, ptr2, ptr3, tmp1, tmp2
20 sta ptr3 ; remember for function return
24 ldx tmp1 ; Low byte of size
27 ; Copy the first chunk < 256
30 bcs L3 ; Jump if end of string found
32 ; Copy full 256 byte chunks
34 L1: lda tmp2 ; High byte of size
36 ldx #$00 ; Copy 256 bytes
43 ; Fill the remaining space with zeroes. If we come here, the value in X
44 ; is the low byte of the fill count, tmp2 holds the high byte. Y is the index
45 ; into the target string.
47 L3: tax ; Test low byte
51 L4: lda tmp2 ; Test high byte
57 ; Done - return a pointer to the string
64 ; -------------------------------------------------------------------
65 ; Copy byte count in X from ptr1 to ptr2
84 ; -------------------------------------------------------------------
85 ; Fill byte count in X with zeroes