/[projet1]/public/pc/tools/osdk/main/Osdk/_final_/lib2/strncpy.s
Defence Force logotype

Contents of /public/pc/tools/osdk/main/Osdk/_final_/lib2/strncpy.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1154 - (show annotations)
Sun Aug 10 18:19:54 2014 UTC (5 years, 6 months ago) by dbug
File size: 771 byte(s)


1 ;char *strncpy(char *s1, char *s2, int n)
2 _strncpy
3 jsr get_2ptr ; get s1 and s2
4
5 ldy #5
6 lda (sp),y ; get n
7 sta tmp ; tmp=hi(n)
8 dey
9 lda (sp),y
10 tax ; x=lo(n)
11
12 ldy op1
13 sty strncpyend+3
14 lda op1+1
15 sta strncpyend+1
16 ldy #0
17
18 strncpyloop
19 dex ; decrease n
20 cpx #$ff
21 bne strncpy1
22 dec tmp
23 lda tmp
24 cmp #$ff
25 beq strncpyend ; n<0?
26
27 strncpy1
28 lda (op2),Y ; copy characters
29 sta (op1),Y
30 beq strncpyend
31 iny
32 bne strncpyloop
33 inc op1+1
34 inc op2+1
35 jmp strncpyloop
36
37 strncpyend
38 lda #$01 ; return s1
39 ldx #$03
40 rts
41
42

  ViewVC Help
Powered by ViewVC 1.1.26