|
|
1.1 root 1: //////////
2: / i8086 C string library.
3: / strncpy()
4: / ANSI 4.11.2.4.
5: //////////
6:
7: //////////
8: / char *
9: / strncpy(To, From, Count)
10: / char *To, *From;
11: / int Count;
12: /
13: / Copy up to Count bytes from From to To,
14: / then NUL-pad if Count not reached.
15: //////////
16:
17: #include <larges.h>
18:
19: To = LEFTARG
20: From = To+DPL
21: Count = From+DPL
22:
23: Enter(strncpy_)
24: Les di, To(bp) / To address to ES:DI
25: mov cx, Count(bp) / Count to CX
26: or cx, cx
27: je 2f / Copy nothing
28: Lds si, From(bp) / From address to DS:SI
29: cld
30:
31: 1: lodsb / Fetch From character
32: stosb / and store through To
33: orb al, al
34: loopne 1b / Continue if AL!=0 && CX!=0
35: rep / Finish clearing line
36: stosb / (does nothing if CX==0)
37:
38: 2: mov ax, To(bp) / Return the destination
39: #if LARGEDATA
40: mov dx, es
41: #endif
42: Leave
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.