From 78908d8421a51894f761d6dba538495a7da39ac9 Mon Sep 17 00:00:00 2001 From: izydorst Date: Tue, 19 Aug 2003 22:56:55 +0000 Subject: [PATCH] removed redundant code; memset == FillRam, bzero == ClearRam with proper return values git-svn-id: svn://svn.cc65.org/cc65/trunk@2376 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/geos.sgml | 10 ++++----- include/geos/gmemory.h | 6 ++--- libsrc/geos/common/memset.s | 41 +++++------------------------------ libsrc/geos/memory/clearram.s | 16 ++++++++++---- libsrc/geos/memory/fillram.s | 11 ++++++++-- 5 files changed, 34 insertions(+), 50 deletions(-) diff --git a/doc/geos.sgml b/doc/geos.sgml index 1d4c2f30f..d01ba6601 100644 --- a/doc/geos.sgml +++ b/doc/geos.sgml @@ -1116,17 +1116,17 @@ compatible with standard CRC routines. FillRam and ClearRam

- - -Both functions are filling given memory range. MoveData

- This functions copies one memory region to another. There are checks for overlap and the non-destructive method is chosen. Be warned that this function destroys contents of diff --git a/include/geos/gmemory.h b/include/geos/gmemory.h index cf421d748..ecfc2fd5e 100644 --- a/include/geos/gmemory.h +++ b/include/geos/gmemory.h @@ -19,10 +19,10 @@ void __fastcall__ CopyFString(char len, char *dest, const char *source); char __fastcall__ CmpFString(char len, char *dest, const char *source); unsigned __fastcall__ CRC(const char *buffer, unsigned len); -void __fastcall__ ClearRam(char *dest, unsigned len); -void __fastcall__ FillRam(char *dest, char what, unsigned len); +void* __fastcall__ ClearRam(char *dest, unsigned len); +void* __fastcall__ FillRam(char *dest, char what, unsigned len); -void __fastcall__ MoveData(char *dest, const char *source, unsigned len); +void* __fastcall__ MoveData(char *dest, const char *source, unsigned len); void __fastcall__ InitRam(char *myInitTab); diff --git a/libsrc/geos/common/memset.s b/libsrc/geos/common/memset.s index 1a98c1c34..77d830f6e 100644 --- a/libsrc/geos/common/memset.s +++ b/libsrc/geos/common/memset.s @@ -3,43 +3,12 @@ ; 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, 20.08.2003 ; -; 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, _bzero, __bzero - .import popa, popax + .import _ClearRam, _FillRam - .include "../inc/jumptab.inc" - .include "../inc/geossym.inc" - -_bzero: -__bzero: - sta r0L - stx r0H - lda #0 - sta r2L ; fill with zeros - beq common - -_memset: - sta r0L - stx r0H - jsr popax - sta r2L -common: jsr popax - sta r1L - pha - stx r1H - txa - pha - jsr FillRam - pla ; restore ptr and return it - tax - pla - rts +_bzero = _ClearRam +__bzero = _ClearRam +_memset = _FillRam diff --git a/libsrc/geos/memory/clearram.s b/libsrc/geos/memory/clearram.s index 0c3ec35bf..22c0448ed 100644 --- a/libsrc/geos/memory/clearram.s +++ b/libsrc/geos/memory/clearram.s @@ -1,10 +1,10 @@ ; -; Maciej 'YTM/Alliance' Witkowiak +; Maciej 'YTM/Elysium' Witkowiak ; -; 30.10.99 +; 30.10.99, 20.08.2003 -; void ClearRam (char *dest, int length); +; void * ClearRam (char *dest, int length); .import DoublePop .export _ClearRam @@ -14,4 +14,12 @@ _ClearRam: jsr DoublePop - jmp ClearRam + pha + txa + pha + jsr ClearRam + pla + tax + pla + rts + diff --git a/libsrc/geos/memory/fillram.s b/libsrc/geos/memory/fillram.s index 72301c7fd..013fce797 100644 --- a/libsrc/geos/memory/fillram.s +++ b/libsrc/geos/memory/fillram.s @@ -4,7 +4,7 @@ ; ; 30.10.99, 15.07.2001 -; void FillRam (char *dest, char what, int length); +; void * FillRam (char *dest, char what, int length); .import popa, popax .export _FillRam @@ -20,4 +20,11 @@ _FillRam: jsr popax sta r1L stx r1H - jmp FillRam + pha + txa + pha + jsr FillRam + pla + tax + pla + rts