struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / device / lib / mos6502 / _memset.s
blob1f19bed8870e61653c43d152d0e032adb6ce9e43
1 ;-------------------------------------------------------------------------
2 ; _memset.s - standarc C library
4 ; Copyright (C) 2003, Ullrich von Bassewitz
5 ; Copyright (C) 2009, Christian Krueger
6 ; Copyright (C) 2023, Gabriele Gorla
8 ; This library is free software; you can redistribute it and/or modify it
9 ; under the terms of the GNU General Public License as published by the
10 ; Free Software Foundation; either version 2, or (at your option) any
11 ; later version.
13 ; This library is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ; GNU General Public License for more details.
18 ; You should have received a copy of the GNU General Public License
19 ; along with this library; see the file COPYING. If not, write to the
20 ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 ; MA 02110-1301, USA.
23 ; As a special exception, if you link this library with other files,
24 ; some of which are compiled with SDCC, to produce an executable,
25 ; this library does not by itself cause the resulting executable to
26 ; be covered by the GNU General Public License. This exception does
27 ; not however invalidate any other reasons why the executable file
28 ; might be covered by the GNU General Public License.
29 ;-------------------------------------------------------------------------
31 .module _memset
33 ;--------------------------------------------------------
34 ; exported symbols
35 ;--------------------------------------------------------
36 .globl _memset_PARM_2
37 .globl _memset_PARM_3
38 .globl _memset
40 ;--------------------------------------------------------
41 ; overlayable function parameters in zero page
42 ;--------------------------------------------------------
43 .area OSEG (PAG, OVR)
44 _memset_PARM_2:
45 .ds 1
46 _memset_PARM_3:
47 .ds 2
49 ;--------------------------------------------------------
50 ; local aliases
51 ;--------------------------------------------------------
52 .define save "REGTEMP+0"
53 .define dst "DPTR"
54 .define val "_memset_PARM_2"
55 .define count "_memset_PARM_3"
57 ;--------------------------------------------------------
58 ; code
59 ;--------------------------------------------------------
60 .area CODE
62 _memset:
63 sta *save+0
64 stx *save+1
65 sta *dst+0
66 stx *dst+1
68 ldy #0
69 lda *val
70 ldx *count+1
71 beq 00002$
72 00001$:
73 sta [dst],y
74 iny
75 sta [dst],y
76 iny
77 bne 00001$
78 inc *dst+1
79 dex
80 bne 00001$
81 00002$:
82 ldx *count+0
83 beq 00004$
84 00003$:
85 sta [dst],y
86 iny
87 dex
88 bne 00003$
89 00004$:
90 lda *save+0
91 ldx *save+1
92 rts