<sect2>FillRam and ClearRam
<p>
-<tt/void FillRam (char *dest, char value, unsigned length)/
+<tt/void *FillRam (char *dest, char value, unsigned length)/
<p>
-<tt/void ClearRam (char *dest, unsigned length)/
+<tt/void *ClearRam (char *dest, unsigned length)/
<p>
-Both functions are filling given memory range. <tt/ClearRam/ fills with <tt/NULLs/, while
+Both functions are filling given memory range. <tt/ClearRam/ fills with <tt/0s/, while
<tt/FillRam/ uses given <tt/value/. Be warned that these functions destroy <tt/r0, r1 and
-r2L/ registers. <tt/FillRam/ is an alias for <tt/memset/.
+r2L/ registers. These are aliases for <tt/memset/ and <tt/bzero/, respectively.
<sect2>MoveData
<p>
-<tt/void MoveData (char *dest, char *src, unsigned length)/
+<tt/void *MoveData (char *dest, char *src, unsigned length)/
<p>
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
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);
; 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
-
- .include "../inc/jumptab.inc"
- .include "../inc/geossym.inc"
-
-_bzero:
-__bzero:
- sta r0L
- stx r0H
- lda #0
- sta r2L ; fill with zeros
- beq common
+ .import _ClearRam, _FillRam
-_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
;
-; 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
_ClearRam:
jsr DoublePop
- jmp ClearRam
+ pha
+ txa
+ pha
+ jsr ClearRam
+ pla
+ tax
+ pla
+ rts
+
;
; 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
jsr popax
sta r1L
stx r1H
- jmp FillRam
+ pha
+ txa
+ pha
+ jsr FillRam
+ pla
+ tax
+ pla
+ rts