mirror of
https://github.com/RevCurtisP/C02.git
synced 2025-02-19 19:31:04 +00:00
Added function clrmem() to module 'memory'
This commit is contained in:
parent
44a763826b
commit
5b09345f3c
@ -23,12 +23,18 @@ The following functions are defined:
|
|||||||
Note: Aliased to the setdst() routine which sets
|
Note: Aliased to the setdst() routine which sets
|
||||||
variables dstlo and dsthi as a pointer to the array.
|
variables dstlo and dsthi as a pointer to the array.
|
||||||
|
|
||||||
memset(c, n); Fills first n bytes of the destination array set
|
memset(c, n); Fills first n bytes of the destination array set
|
||||||
by a a prior memdst() call with character c.
|
by a a prior memdst() call with character c.
|
||||||
|
|
||||||
Note: dstlo and dsthi are left pointing to the
|
Note: dstlo and dsthi are left pointing to the
|
||||||
destination array.
|
destination array.
|
||||||
|
|
||||||
|
memclr(n, &s); Memory Clear: Fills first n bytes of array s with
|
||||||
|
the byte $00.
|
||||||
|
|
||||||
|
Note: Calls memdst(&d) and memset(n,$00), leaving
|
||||||
|
dstlo and dsthi pointing to s.
|
||||||
|
|
||||||
p = memchr(c, n); Searches for character c in the first n bytes of the
|
p = memchr(c, n); Searches for character c in the first n bytes of the
|
||||||
destination array set by a a prior memdst() call.
|
destination array set by a a prior memdst() call.
|
||||||
|
|
||||||
|
@ -89,6 +89,11 @@ MEMCPL: LDA (SRCLO),Y ;Get Character from Source Array
|
|||||||
TYA ;Copy Index to Accumulater
|
TYA ;Copy Index to Accumulater
|
||||||
RTS ;Else Return
|
RTS ;Else Return
|
||||||
|
|
||||||
|
MEMCLR: JSR SETDST ;Set Destination Address
|
||||||
|
TAY ;Transer Count to Y
|
||||||
|
LDA #0 ;Set Fill Character to Null
|
||||||
|
;and Fall into MEMSET
|
||||||
|
|
||||||
;memset(c, n) - Fill Destination Array
|
;memset(c, n) - Fill Destination Array
|
||||||
;Args: A = Character to fill with
|
;Args: A = Character to fill with
|
||||||
; Y = Number of bytes to fill
|
; Y = Number of bytes to fill
|
||||||
|
@ -14,6 +14,12 @@ void memdst();
|
|||||||
* $FF if not found */
|
* $FF if not found */
|
||||||
char memchr();
|
char memchr();
|
||||||
|
|
||||||
|
/* Clear Array (Fill with $00) *
|
||||||
|
* Args: n - Number of bytes to fill *
|
||||||
|
* &s - Array to fill *
|
||||||
|
* Returns: Number of bytes filled */
|
||||||
|
char memclr();
|
||||||
|
|
||||||
/* Compare Destination Array against Source Array *
|
/* Compare Destination Array against Source Array *
|
||||||
* Args: n - Number of bytes to compare *
|
* Args: n - Number of bytes to compare *
|
||||||
* &s - Source array *
|
* &s - Source array *
|
||||||
@ -26,14 +32,13 @@ char memcmp();
|
|||||||
|
|
||||||
/* Copy Source Array to Destination Array *
|
/* Copy Source Array to Destination Array *
|
||||||
* Args: n - Number of bytes to copy *
|
* Args: n - Number of bytes to copy *
|
||||||
* &s - Source array *
|
* &s - Source array *
|
||||||
* Sets: Destination string specified by memdst() */
|
* Sets: Destination string specified by memdst() */
|
||||||
char memcpy();
|
char memcpy();
|
||||||
|
|
||||||
/* Fill Destination Array with Character *
|
/* Fill Destination Array with Byte *
|
||||||
* Args: c - Character to fill array with *
|
* Args: b - Character to fill array with *
|
||||||
* n - Number of bytes to fill *
|
* n - Number of bytes to fill *
|
||||||
* Uses: Destination array specified by memdst() *
|
* Uses: Destination array specified by memdst() *
|
||||||
* Returns: Number of characters copied */
|
* Returns: Number of bytes copied */
|
||||||
char memset();
|
char memset();
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
#include <py65.h02>
|
#include <py65.h02>
|
||||||
#include <stddef.h02>
|
#include <stddef.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
#include <stdio.h02>
|
#include <stdio.h02>
|
||||||
|
#include <stdiox.h02>
|
||||||
#include <memory.h02>
|
#include <memory.h02>
|
||||||
|
|
||||||
char c, d, f, i, n, p;
|
char c, d, f, i, n, p;
|
||||||
@ -55,53 +57,43 @@ if (p) putln(&pass); else putln(&fail);
|
|||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
//Test memcmp()
|
//Test memcmp()
|
||||||
puts("less="); puts(&less);
|
setdst(&less); printf("less=\"%s\", ");
|
||||||
puts(" more="); puts(&more);
|
setdst(&more); printf("more=\"%s\", ");
|
||||||
puts(" most="); putln(&most);
|
setdst(&most); printf("most=\"%s\"\n");
|
||||||
|
|
||||||
putln("memdst(&more);");
|
putln("memdst(&more);");
|
||||||
memdst(&more);
|
memdst(&more);
|
||||||
|
|
||||||
puts("memcmp(2, &most):");
|
rcmp = memcmp(2, &most);
|
||||||
rcmp = memcmp(2, &most);
|
printf(rcmp,"memcmp(2, &most)=$%h:");
|
||||||
if (!rcmp) puts(&pass); else puts(&fail);
|
if (!rcmp) puts(&pass); else puts(&fail);
|
||||||
|
|
||||||
puts("memcmp(4, &most):");
|
|
||||||
rcmp = memcmp(4, &most);
|
rcmp = memcmp(4, &most);
|
||||||
|
printf(rcmp,"memcmp(4, &most)=$%h:");
|
||||||
if (rcmp :-) putln(&pass); else putln(&fail);
|
if (rcmp :-) putln(&pass); else putln(&fail);
|
||||||
|
|
||||||
puts("memcmp(3, &more):");
|
rcmp = memcmp(4, &more);
|
||||||
rcmp = memcmp(3, &more);
|
printf("memcmp(4, &more)=$%h:");
|
||||||
if (!rcmp) puts(&pass); else puts(&fail);
|
if (!rcmp) puts(&pass); else puts(&fail);
|
||||||
|
|
||||||
puts("memcmp(3, &less):");
|
rcmp = memcmp(4, &less);
|
||||||
rcmp = memcmp(3, &less);
|
printf("memcmp(4, &less)=$%h:");
|
||||||
if (rcmp > 0) putln(&pass); else putln(&fail);
|
if (rcmp > 0) putln(&pass); else putln(&fail);
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
//Test memset() and memcpy()
|
//Test memset() and memcpy()
|
||||||
putln("memdst(&temp);");
|
putln("memdst(&temp);"); memdst(&temp);
|
||||||
memdst(&temp);
|
|
||||||
|
|
||||||
puts("memset(0,20); ");
|
puts("memset(0,20); "); memset(0,20);
|
||||||
memset(0,20);
|
puts("temp="); putln(&temp);
|
||||||
|
|
||||||
puts("temp=");
|
puts("memset('@',20); "); memset('@',20);
|
||||||
putln(&temp);
|
puts("temp="); putln(&temp);
|
||||||
|
|
||||||
puts("memset('@',20); ");
|
puts("memcpy(10, <tr); "); memcpy(10, <tr);
|
||||||
memset('@',20);
|
puts("temp="); putln(&temp);
|
||||||
|
|
||||||
puts("temp=");
|
puts("memcmp(10, <tr);");
|
||||||
putln(&temp);
|
|
||||||
|
|
||||||
puts("memcpy(10, <tr); ");
|
|
||||||
memcpy(10, <tr);
|
|
||||||
|
|
||||||
puts("temp=");
|
|
||||||
putln(&temp);
|
|
||||||
|
|
||||||
puts("memcmp(10, <tr);");
|
|
||||||
rcmp = memcmp(10, <tr);
|
rcmp = memcmp(10, <tr);
|
||||||
if (!rcmp) putln(&pass); else putln(&fail);
|
if (!rcmp) putln(&pass); else putln(&fail);
|
||||||
|
|
||||||
@ -110,13 +102,14 @@ rcmp = memcmp(11, <tr);
|
|||||||
if (rcmp > 0) putln(&pass); else putln(&fail);
|
if (rcmp > 0) putln(&pass); else putln(&fail);
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
memdst(&temp); memcpy("ABCDEF");
|
memdst(&temp); memcpy(7,"ABCDEF"); printf("temp=\"%s\", ");
|
||||||
memdst(&dest); memcpy("123456");
|
memdst(&dest); memcpy(7,"123456"); printf("dest=\"%s\"\n");
|
||||||
puts("memdst(&dest);memswp(3,&temp);");
|
putln("memdst(&dest);memswp(3,&temp);");
|
||||||
memswp(3,&temp);
|
memdst(&dest); memswp(3,&temp);
|
||||||
rcmp = memcmp(6,"ABC456");
|
memdst(&temp); printf("temp=\"%s\":"); florps(memcmp(7,"123DEF"));
|
||||||
memdst(&temp); rcmp = memcmp(6,"123DEF") | rcmp;
|
memdst(&dest); printf("dest=\"%s\":"); florps(memcmp(7,"ABC456"));
|
||||||
if (rcmp) putln(&fail); else putln(&pass);
|
newlin();
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
void florps(rcmp) {if (rcmp) putln(&fail); else putln(&pass);}
|
Loading…
x
Reference in New Issue
Block a user