1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-03 16:33:19 +00:00

added bzero implementation

git-svn-id: svn://svn.cc65.org/cc65/trunk@1812 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
izydorst 2002-12-21 00:05:51 +00:00
parent ca698f0959
commit c024ddbdb2

View File

@ -1,21 +1,41 @@
; ;
; void* memset (void* ptr, int c, size_t n); ; void* memset (void* ptr, int c, size_t n);
; void* _bzero (void* ptr, size_t n);
; void bzero (void* ptr, size_t n);
; ;
; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001 ; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
; ;
; NOTE: bzero will return it's first argument as memset does. It is no problem
; to declare the return value as void, since it may be ignored. _bzero
; (note the leading underscore) is declared with the proper return type,
; because the compiler will replace memset by _bzero if the fill value
; is zero, and the optimizer looks at the return type to see if the value
; in a/x is of any use.
.export _memset
.export _memset, _bzero, __bzero
.import popa, popax .import popa, popax
.include "../inc/jumptab.inc" .include "../inc/jumptab.inc"
.include "../inc/geossym.inc" .include "../inc/geossym.inc"
_bzero:
__bzero:
sta r0L
stx r0H
lda #0
sta r2L ; fill with zeros
beq common
_memset: _memset:
sta r0L sta r0L
stx r0H stx r0H
jsr popax jsr popax
sta r2L sta r2L
jsr popax common: jsr popax
sta r1L sta r1L
stx r1H stx r1H
jmp FillRam jsr FillRam
lda r1L ; restore ptr and pass as result
ldx r1H
rts