add extra underscore to _bzero, add a test for bzero/memset

This commit is contained in:
mrdudz
2022-08-29 23:20:48 +02:00
parent 3b03a96375
commit 5bda57de87
12 changed files with 86 additions and 35 deletions

View File

@@ -4,7 +4,7 @@
.export _clrscr
.import _screen
.import pushax, __bzero
.import pushax, ___bzero
.include "extzp.inc"
.code
@@ -16,7 +16,7 @@
jsr pushax
ldx #>(charsperline * screenrows)
lda #<(charsperline * screenrows)
jmp __bzero
jmp ___bzero
.endproc

View File

@@ -4,7 +4,7 @@
.export _mono_clrscr
.import _mono_screen
.import pushax, __bzero
.import pushax, ___bzero
.include "extzp.inc"
.code
@@ -16,7 +16,7 @@
jsr pushax
ldx #>(mono_charsperline * screenrows)
lda #<(mono_charsperline * screenrows)
jmp __bzero
jmp ___bzero
.endproc

View File

@@ -7,7 +7,7 @@
;
.export _calloc
.import _malloc, __bzero
.import _malloc, ___bzero
.import tosumulax, pushax
@@ -48,7 +48,7 @@ ClearBlock:
jsr pushax ; ptr
lda Size
ldx Size+1 ; Size
jmp __bzero
jmp ___bzero
.endproc

View File

@@ -1,6 +1,6 @@
;
; void* __fastcall__ memset (void* ptr, int c, size_t n);
; void* __fastcall__ _bzero (void* ptr, size_t n);
; void* __fastcall__ __bzero (void* ptr, size_t n);
; void __fastcall__ bzero (void* ptr, size_t n);
;
; Ullrich von Bassewitz, 29.05.1998
@@ -8,19 +8,19 @@
; Christian Krueger, 12.09.2009, slightly improved 12.01.2011
;
; 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
; to declare the return value as void, since it may be ignored. __bzero
; (note the leading underscores) 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
.export _memset, _bzero, ___bzero
.import popax
.importzp sp, ptr1, ptr2, ptr3
_bzero:
__bzero:
___bzero:
sta ptr3
stx ptr3+1 ; Save n
ldx #0 ; Fill with zeros

View File

@@ -1,14 +1,14 @@
;
; void* memset (void* ptr, int c, size_t n);
; void* _bzero (void* ptr, size_t n);
; void* __bzero (void* ptr, size_t n);
; void bzero (void* ptr, size_t n);
;
; Maciej 'YTM/Elysium' Witkowiak, 20.08.2003
;
.export _memset, _bzero, __bzero
.export _memset, _bzero, ___bzero
.import _ClearRam, _FillRam
_bzero = _ClearRam
__bzero = _ClearRam
___bzero = _ClearRam
_memset = _FillRam

View File

@@ -6,21 +6,21 @@
; 1998-05-29, Ullrich von Bassewitz
; 2015-11-06, Greg King
;
; void* __fastcall__ _bzero (void* ptr, size_t n);
; void* __fastcall__ __bzero (void* ptr, size_t n);
; void __fastcall__ bzero (void* ptr, size_t n);
; void* __fastcall__ memset (void* ptr, int c, size_t n);
;
; NOTE: bzero() will return its first argument, as memset() does. It is no
; problem to declare the return value as void, because it can be ignored.
; _bzero() (note the leading underscore) is declared with the proper
; return type because the compiler will replace memset() by _bzero() if
; __bzero() (note the leading underscores) 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 .XA is of any use.
;
; NOTE: This function uses entry points from "pce/memcpy.s"!
;
.export __bzero, _bzero, _memset
.export ___bzero, _bzero, _memset
.import memcpy_getparams, memcpy_increment
.import pushax, popax
@@ -30,7 +30,7 @@
; ----------------------------------------------------------------------
__bzero:
___bzero:
_bzero: pha
cla ; fill with zeros
jsr pushax ; (high byte isn't important)