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

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

Parent Directory Parent Directory | Revision Log Revision Log


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


1 ; void *memset (void *buffer, int c, int count)
2 ;
3 ; shamelessly adopted from Fabrice Frances' memcpy.
4 ; (clueless comments added by me)
5 ; [me=alexios@vennea.demon.co.uk]
6
7 _memset
8 ldy #0 ; get buffer pointer
9 lda (sp),y
10 sta op1
11 sta patch_memsetret_x+1 ; keep return value for later
12 iny
13 lda (sp),y
14 sta op1+1
15 sta patch_memsetret_a+1 ; keep return value for later
16
17 iny ; get character to fill buffer with
18 lda (sp),y
19 pha ; stack it -- we'll be needing it later
20
21 ldy #4 ; get the count of bytes to set
22 sec
23 lda #0
24 sbc (sp),y
25 sta tmp
26 tax
27 iny
28 cmp #1
29 lda (sp),y
30 adc #0
31 tay
32 beq memsetret ; I don't have a clue what just happened here!
33
34 sec ; adjust the self-modifying part of the routine.
35 lda op1
36 sbc tmp
37 sta memsetloop+1
38 lda op1+1
39 sbc #0
40 sta memsetloop+2
41
42 pla ; recover the byte value from the stack
43
44 memsetloop ; main loop
45 sta $2211,x ; set a byte
46 inx
47 bne memsetloop
48 inc memsetloop+2
49 dey
50 bne memsetloop
51
52 memsetret
53 patch_memsetret_x
54 ldx #1 ; return buffer
55 patch_memsetret_a
56 lda #3
57 rts
58

  ViewVC Help
Powered by ViewVC 1.1.26