own versions of some common routines, fillram and movedata equal to memset

and memcpy


git-svn-id: svn://svn.cc65.org/cc65/trunk@789 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
izydorst
2001-07-15 16:09:50 +00:00
parent 66bcf9ac4e
commit 8e97e1f4b7
14 changed files with 160 additions and 26 deletions

View File

@@ -4,7 +4,7 @@
#
# Maciej 'YTM/Elysium' Witkowiak
OBJ_DIRS=devel disk dlgbox file graph menuicon memory mousesprite process system
OBJ_DIRS=common devel disk dlgbox file graph menuicon memory mousesprite process system
all:
@for i in $(OBJ_DIRS); do $(MAKE) -C $$i; done

View File

@@ -0,0 +1,21 @@
#
# Makefile for GEOS lib
# for cc65
#
%.o: %.c
@$(CC) $(CFLAGS) $<
@$(AS) -g -o $@ $(AFLAGS) $(*).s
%.o: %.s
@$(AS) -o $@ $(AFLAGS) $<
C_OBJS = abort.o perror.o
S_OBJS = copydata.o memcpy.o memset.o rand.o
all: $(C_OBJS) $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f $(C_OBJS:.o=.s)
@rm -f $(C_OBJS)

View File

@@ -0,0 +1,16 @@
/*
* abort.c
*
* Maciej 'YTM/Elysium' Witkowiak 15.7.2001
*/
#include <stdlib.h>
#include <geos.h>
void abort (void)
{
DlgBoxOk(CBOLDON "ABNORMAL PROGRAM", "TERMINATION." CPLAINTEXT);
exit(3);
}

View File

@@ -0,0 +1,27 @@
;
; Maciej 'YTM/Elysium' Witkowiak 15.07.2001
;
; Copy the data segment from the LOAD to the RUN location
;
.export copydata
.import __DATA_LOAD__, __DATA_RUN__, __DATA_SIZE__
.include "../inc/geossym.inc"
.include "../inc/jumptab.inc"
copydata:
lda #<__DATA_SIZE__ ; no need to check if it is == 0
ldx #>__DATA_SIZE__
sta r2L
stx r2H
lda #<__DATA_RUN__
ldx #>__DATA_RUN__
sta r1L
stx r1H
lda #<__DATA_LOAD__
ldx #>__DATA_LOAD__
sta r0L
stx r0H
jmp MoveData

View File

@@ -0,0 +1,12 @@
;
; void* memcpy (void* dest, const void* src, size_t n);
; void* memmove (void* dest, const void* src, size_t n);
;
; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
;
.export _memcpy, _memmove
.import _MoveData
_memcpy = _MoveData
_memmove = _MoveData

View File

@@ -0,0 +1,10 @@
;
; void* memset (void* ptr, int c, size_t n);
;
; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
;
.export _memset
.import _FillRam
_memset = _FillRam

View File

@@ -0,0 +1,17 @@
/*
* perror.c
*
* Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <geos.h>
void perror(const char* msg)
{
DlgBoxOk((char*)msg,strerror(errno));
}

20
libsrc/geos/common/rand.s Normal file
View File

@@ -0,0 +1,20 @@
;
; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
;
;
; int rand (void);
; void srand (unsigned seed);
;
.export _rand, _srand
.include "../inc/jumptab.inc"
.code
_rand:
jsr GetRandom
pha
jsr GetRandom
tax
pla
_srand:
rts

View File

@@ -1,19 +1,23 @@
;
; Maciej 'YTM/Alliance' Witkowiak
; Maciej 'YTM/Elysium' Witkowiak
;
; 30.10.99
; 30.10.99, 15.07.2001
; void FillRam (char what, char *dest, int length);
; void FillRam (char *dest, char what, int length);
.import DoublePop, popa
.import popa, popax
.export _FillRam
.include "../inc/jumptab.inc"
.include "../inc/geossym.inc"
_FillRam:
jsr DoublePop
sta r0L
stx r0H
jsr popa
sta r2L
jsr popax
sta r1L
stx r1H
jmp FillRam

View File

@@ -1,10 +1,10 @@
;
; Maciej 'YTM/Alliance' Witkowiak
; Maciej 'YTM/Elysium' Witkowiak
;
; 30.10.99
; 30.10.99, 15.07.2001
; void MoveData (char* source, char *dest, int length);
; void MoveData (char* dest, char *source, int length);
.import popax
.export _MoveData
@@ -16,9 +16,9 @@ _MoveData:
sta r2L
stx r2H
jsr popax
sta r1L
stx r1H
jsr popax
sta r0L
stx r0H
jsr popax
sta r1L
stx r1H
jmp MoveData