1 /*-------------------------------------------------------------------------
2 _memset.c - part of string library functions
4 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
5 mcs51 assembler by Frieder Ferlemann (2007)
7 This library is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Library General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 In other words, you are welcome to use, share and improve this program.
22 You are forbidden to forbid anyone else to use, share and improve
23 what you give them. Help stamp out software-hoarding!
24 -------------------------------------------------------------------------*/
27 #if defined (_SDCC_NO_ASM_LIB_FUNCS) || !defined (SDCC_mcs51) || \
28 (!defined (SDCC_MODEL_SMALL) && !defined (SDCC_MODEL_LARGE)) || \
29 (defined (SDCC_STACK_AUTO) || defined (SDCC_PARMS_IN_BANK1) )
36 register unsigned char * ret = buf;
39 *(unsigned char *) ret = ch;
40 ret = ((unsigned char *) ret) + 1;
48 /* assembler implementation for mcs51 */
49 static void dummy(void) __naked
53 /* assigning function parameters to registers.
54 SDCC_PARMS_IN_BANK1 or SDCC_STACK_AUTO not yet implemented. */
55 #if defined (SDCC_MODEL_SMALL)
57 #if defined(SDCC_NOOVERLAY)
71 ; Assign buf (b holds memspace, no need to touch)
77 mov r7,(_memset_PARM_3 + 1)
79 ; if (!count) return buf;
80 ; check for count != 0 intermangled with gymnastic
81 ; preparing djnz instructions
82 cjne r6,#0x00,COUNT_LSB_NOT_ZERO
89 ; This was 8 byte overhead for preparing
90 ; the count argument for an integer loop with two
91 ; djnz instructions - it might make sense to
92 ; let SDCC automatically generate this when
93 ; it encounters a loop like:
94 ; for(i=0;i<j;i++){...}
95 ; (at least for option --opt-code-speed)
114 ; Assign buf (b holds memspace, no need to touch)
119 mov dptr,#_memset_PARM_3
126 ; if (!count) return buf;
127 ; check for count != 0 intermangled with gymnastic
128 ; preparing djnz instructions
129 cjne r6,#0x00,COUNT_LSB_NOT_ZERO
137 mov dptr,#_memset_PARM_2
139 ; acc is precious now
147 /* now independent of the parameter passing everything
148 should be in registers by now and the loop may start */
158 ; _memset.c } while(--count) ;
164 ; _memset.c return buf ;