mirror of
https://github.com/RevCurtisP/C02.git
synced 2025-02-15 23:31:46 +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
|
||||
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.
|
||||
|
||||
Note: dstlo and dsthi are left pointing to the
|
||||
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
|
||||
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
|
||||
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
|
||||
;Args: A = Character to fill with
|
||||
; Y = Number of bytes to fill
|
||||
|
@ -14,6 +14,12 @@ void memdst();
|
||||
* $FF if not found */
|
||||
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 *
|
||||
* Args: n - Number of bytes to compare *
|
||||
* &s - Source array *
|
||||
@ -26,14 +32,13 @@ char memcmp();
|
||||
|
||||
/* Copy Source Array to Destination Array *
|
||||
* Args: n - Number of bytes to copy *
|
||||
* &s - Source array *
|
||||
* &s - Source array *
|
||||
* Sets: Destination string specified by memdst() */
|
||||
char memcpy();
|
||||
|
||||
/* Fill Destination Array with Character *
|
||||
* Args: c - Character to fill array with *
|
||||
/* Fill Destination Array with Byte *
|
||||
* Args: b - Character to fill array with *
|
||||
* n - Number of bytes to fill *
|
||||
* Uses: Destination array specified by memdst() *
|
||||
* Returns: Number of characters copied */
|
||||
* Returns: Number of bytes copied */
|
||||
char memset();
|
||||
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
#include <py65.h02>
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
#include <memory.h02>
|
||||
|
||||
char c, d, f, i, n, p;
|
||||
@ -55,53 +57,43 @@ if (p) putln(&pass); else putln(&fail);
|
||||
newlin();
|
||||
|
||||
//Test memcmp()
|
||||
puts("less="); puts(&less);
|
||||
puts(" more="); puts(&more);
|
||||
puts(" most="); putln(&most);
|
||||
setdst(&less); printf("less=\"%s\", ");
|
||||
setdst(&more); printf("more=\"%s\", ");
|
||||
setdst(&most); printf("most=\"%s\"\n");
|
||||
|
||||
putln("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);
|
||||
|
||||
puts("memcmp(4, &most):");
|
||||
rcmp = memcmp(4, &most);
|
||||
printf(rcmp,"memcmp(4, &most)=$%h:");
|
||||
if (rcmp :-) putln(&pass); else putln(&fail);
|
||||
|
||||
puts("memcmp(3, &more):");
|
||||
rcmp = memcmp(3, &more);
|
||||
rcmp = memcmp(4, &more);
|
||||
printf("memcmp(4, &more)=$%h:");
|
||||
if (!rcmp) puts(&pass); else puts(&fail);
|
||||
|
||||
puts("memcmp(3, &less):");
|
||||
rcmp = memcmp(3, &less);
|
||||
rcmp = memcmp(4, &less);
|
||||
printf("memcmp(4, &less)=$%h:");
|
||||
if (rcmp > 0) putln(&pass); else putln(&fail);
|
||||
newlin();
|
||||
|
||||
//Test memset() and memcpy()
|
||||
putln("memdst(&temp);");
|
||||
memdst(&temp);
|
||||
putln("memdst(&temp);"); memdst(&temp);
|
||||
|
||||
puts("memset(0,20); ");
|
||||
memset(0,20);
|
||||
puts("memset(0,20); "); memset(0,20);
|
||||
puts("temp="); putln(&temp);
|
||||
|
||||
puts("temp=");
|
||||
putln(&temp);
|
||||
puts("memset('@',20); "); memset('@',20);
|
||||
puts("temp="); putln(&temp);
|
||||
|
||||
puts("memset('@',20); ");
|
||||
memset('@',20);
|
||||
puts("memcpy(10, <tr); "); memcpy(10, <tr);
|
||||
puts("temp="); putln(&temp);
|
||||
|
||||
puts("temp=");
|
||||
putln(&temp);
|
||||
|
||||
puts("memcpy(10, <tr); ");
|
||||
memcpy(10, <tr);
|
||||
|
||||
puts("temp=");
|
||||
putln(&temp);
|
||||
|
||||
puts("memcmp(10, <tr);");
|
||||
puts("memcmp(10, <tr);");
|
||||
rcmp = memcmp(10, <tr);
|
||||
if (!rcmp) putln(&pass); else putln(&fail);
|
||||
|
||||
@ -110,13 +102,14 @@ rcmp = memcmp(11, <tr);
|
||||
if (rcmp > 0) putln(&pass); else putln(&fail);
|
||||
newlin();
|
||||
|
||||
memdst(&temp); memcpy("ABCDEF");
|
||||
memdst(&dest); memcpy("123456");
|
||||
puts("memdst(&dest);memswp(3,&temp);");
|
||||
memswp(3,&temp);
|
||||
rcmp = memcmp(6,"ABC456");
|
||||
memdst(&temp); rcmp = memcmp(6,"123DEF") | rcmp;
|
||||
if (rcmp) putln(&fail); else putln(&pass);
|
||||
memdst(&temp); memcpy(7,"ABCDEF"); printf("temp=\"%s\", ");
|
||||
memdst(&dest); memcpy(7,"123456"); printf("dest=\"%s\"\n");
|
||||
putln("memdst(&dest);memswp(3,&temp);");
|
||||
memdst(&dest); memswp(3,&temp);
|
||||
memdst(&temp); printf("temp=\"%s\":"); florps(memcmp(7,"123DEF"));
|
||||
memdst(&dest); printf("dest=\"%s\":"); florps(memcmp(7,"ABC456"));
|
||||
newlin();
|
||||
|
||||
goto exit;
|
||||
|
||||
|
||||
void florps(rcmp) {if (rcmp) putln(&fail); else putln(&pass);}
|
Loading…
x
Reference in New Issue
Block a user