1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Merge branch 'cc65:master' into master

This commit is contained in:
polluks2 2022-01-30 02:40:27 +01:00 committed by GitHub
commit 97c83de37b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 285 additions and 51 deletions

View File

@ -33,6 +33,73 @@ jobs:
- name: Test that the samples can be built.
shell: bash
run: make -j2 samples
- name: Test that the targettest programs can be built.
shell: bash
run: |
make SYS=c64 -C targettest all
make SYS=c64 -C targettest clean
make SYS=apple2 -C targettest
make SYS=apple2 -C targettest clean
make SYS=apple2enh -C targettest
make SYS=apple2enh -C targettest clean
make SYS=atari -C targettest
make SYS=atari -C targettest clean
make SYS=atarixl -C targettest
make SYS=atarixl -C targettest clean
# make SYS=atari2600 -C targettest
# make SYS=atari2600 -C targettest clean
# make SYS=atari5200 -C targettest
# make SYS=atari5200 -C targettest clean
# make SYS=atmos -C targettest
# make SYS=atmos -C targettest clean
# make SYS=bbc -C targettest
# make SYS=bbc -C targettest clean
# make SYS=c128 -C targettest
# make SYS=c128 -C targettest clean
# make SYS=c16 -C targettest
# make SYS=c16 -C targettest clean
make SYS=c64 -C targettest
make SYS=c64 -C targettest clean
# make SYS=cbm510 -C targettest
# make SYS=cbm510 -C targettest clean
# make SYS=cbm610 -C targettest
# make SYS=cbm610 -C targettest clean
# make SYS=creativision -C targettest
# make SYS=creativision -C targettest clean
# make SYS=cx16 -C targettest
# make SYS=cx16 -C targettest clean
# make SYS=gamate -C targettest
# make SYS=gamate -C targettest clean
# make SYS=geos-apple -C targettest
# make SYS=geos-apple -C targettest clean
# make SYS=geos-cbm -C targettest
# make SYS=geos-cbm -C targettest clean
# make SYS=lunix -C targettest
# make SYS=lunix -C targettest clean
# make SYS=lynx -C targettest
# make SYS=lynx -C targettest clean
# make SYS=nes -C targettest
# make SYS=nes -C targettest clean
# make SYS=osic1p -C targettest
# make SYS=osic1p -C targettest clean
# make SYS=pce -C targettest
# make SYS=pce -C targettest clean
# make SYS=pet -C targettest
# make SYS=pet -C targettest clean
# make SYS=plus4 -C targettest
# make SYS=plus4 -C targettest clean
# make SYS=sim6502 -C targettest
# make SYS=sim6502 -C targettest clean
# make SYS=sim65c02 -C targettest
# make SYS=sim65c02 -C targettest clean
# make SYS=supervision -C targettest
# make SYS=supervision -C targettest clean
# make SYS=sym1 -C targettest
# make SYS=sym1 -C targettest clean
# make SYS=telestrat -C targettest
# make SYS=telestrat -C targettest clean
make SYS=vic20 -C targettest
make SYS=vic20 -C targettest clean
- name: Build the document files.
shell: bash
run: make -j2 doc
@ -60,3 +127,8 @@ jobs:
- name: Build app (release)
run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release
# TODO: fix tergettest Makefile for all currently commented out targets
# TODO: build targettest cbm subdir for all cbm targets
# TODO: build targettest atari subdir for all atari targets
# TODO: build targettest apple2 subdir for all apple2 targets

View File

@ -50,7 +50,6 @@ PET_2000 = $CA
PET_3000 = $FC
PET_4000 = $FD
;----------------------------------------------------------------------------
; Vector and other locations
@ -59,7 +58,25 @@ BRKVec := $0092
NMIVec := $0094
; ---------------------------------------------------------------------------
; I/O: 6522 VIA2
; I/O: 6520 PIA1
PIA1 := $E810 ; PIA1 base address
PIA1_PORTA := PIA1+$0 ; Port A (PA) and data direction register A (DDRA)
PIA1_PACTL := PIA1+$1 ; Port A control register (CRA)
PIA1_PORTB := PIA1+$2 ; Port B (PB) and data direction register B (DDRB)
PIA1_PBCTL := PIA1+$3 ; Port B control register (CRB)
; ---------------------------------------------------------------------------
; I/O: 6520 PIA2
PIA2 := $E820 ; PIA2 base address
PIA2_PORTA := PIA2+$0 ; Port A (PA) and data direction register A (DDRA)
PIA2_PACTL := PIA2+$1 ; Port A control register (CRA)
PIA2_PORTB := PIA2+$2 ; Port B (PB) and data direction register B (DDRB)
PIA2_PBCTL := PIA2+$3 ; Port B control register (CRB)
; ---------------------------------------------------------------------------
; I/O: 6522 VIA
VIA := $E840 ; VIA base address
VIA_PB := VIA+$0 ; Port register B

View File

@ -726,6 +726,11 @@ for sectors 1 to 3, regardless of the type of diskette.
The console I/O is speed optimized therefore support for XEP80 hardware
or f80.com software is missing. Of course you may use stdio.h functions.
<tt/cprintf/ targets a 40 character line. On a 20-column display this has
the unexpected effect of a blank line after your text. On such displays you can either
use for example <tt/gotoxy(20,0)/ to target the "next" line, or you can switch to <tt/write()/
function which does not have this side effect.
<sect>Technical details<label id="techdetail"><p>

View File

@ -78,6 +78,7 @@ int __fastcall__ stricmp (const char* s1, const char* s2); /* DOS/Windows */
int __fastcall__ strcasecmp (const char* s1, const char* s2); /* Same for Unix */
int __fastcall__ strnicmp (const char* s1, const char* s2, size_t count); /* DOS/Windows */
int __fastcall__ strncasecmp (const char* s1, const char* s2, size_t count); /* Same for Unix */
size_t __fastcall__ strnlen (const char* s, size_t maxlen); /* POSIX.1-2008 */
char* __fastcall__ strlwr (char* s);
char* __fastcall__ strlower (char* s);
char* __fastcall__ strupr (char* s);

54
libsrc/common/strnlen.s Normal file
View File

@ -0,0 +1,54 @@
; size_t __fastcall__ strnlen (const char* s, size_t maxlen);
.export _strnlen
.import popax
.importzp ptr1, tmp1, tmp2, tmp3, tmp4
.proc _strnlen
; Get maximum length.
tay
iny
sty tmp3
inx
stx tmp4
; Fetch string pointer.
jsr popax
sta ptr1
stx ptr1+1
; Clear return value.
ldy #0
sty tmp1
sty tmp2
;;; Loop over string.
; Decrement maximum length.
next: dec tmp3
bne l2
dec tmp4
beq done
l2:
lda (ptr1),y
beq done
; Step to next character.
iny
bne l1
inc ptr1+1
l1:
; Increment return value.
inc tmp1
bne next
inc tmp2
bne next ; (jmp)
done: lda tmp1
ldx tmp2
rts
.endproc

View File

@ -105,7 +105,7 @@ static void SetAX (CPURegs* Regs, unsigned Val)
static unsigned char Pop (CPURegs* Regs)
{
return MemReadByte (0x0100 + ++Regs->SP);
return MemReadByte (0x0100 + (++Regs->SP & 0xFF));
}
@ -317,6 +317,8 @@ void ParaVirtInit (unsigned aArgStart, unsigned char aSPAddr)
void ParaVirtHooks (CPURegs* Regs)
/* Potentially execute paravirtualization hooks */
{
unsigned lo;
/* Check for paravirtualization address range */
if (Regs->PC < PARAVIRT_BASE ||
Regs->PC >= PARAVIRT_BASE + sizeof (Hooks) / sizeof (Hooks[0])) {
@ -327,5 +329,6 @@ void ParaVirtHooks (CPURegs* Regs)
Hooks[Regs->PC - PARAVIRT_BASE] (Regs);
/* Simulate RTS */
Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1;
lo = Pop (Regs);
Regs->PC = lo + (Pop (Regs) << 8) + 1;
}

View File

@ -122,6 +122,44 @@ DISK_atarixl = testcode.atr
.PRECIOUS: %.o
LDFLAGS=
ifeq ($(SYS),c64)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),c128)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),c16)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),cbm510)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),cbm610)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),cx16)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),geos-cbm)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),lunix)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),pet)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),pet-overlay)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),plus4)
LDFLAGS+=-Ln $@.lbl
endif
ifeq ($(SYS),vic20)
LDFLAGS+=-Ln $@.lbl
endif
.o:
ifeq ($(SYS),vic20)
$(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib
@ -160,6 +198,7 @@ EXELIST_c64 = \
scanf-test \
ser-test \
strdup-test \
strnlen \
stroserror-test \
strqtok-test \
tinyshell \
@ -190,6 +229,7 @@ EXELIST_vic20 = \
rename-test \
scanf-test \
strdup-test \
strnlen \
stroserror-test \
strqtok-test \
tinyshell \
@ -222,6 +262,7 @@ EXELIST_apple2 = \
seek \
ser-test \
strdup-test \
strnlen \
stroserror-test \
strqtok-test \
tinyshell \
@ -257,6 +298,7 @@ EXELIST_atari = \
seek \
ser-test \
strdup-test \
strnlen \
stroserror-test \
strqtok-test \
tinyshell \
@ -292,6 +334,7 @@ all: testcode
make -C cbm SYS=$(SYS)
make -C gamate
make -C pce
make -C sym1
# --------------------------------------------------------------------------
# some programs link against getsp.o
@ -399,3 +442,4 @@ clean: mostlyclean
make -C cbm SYS=$(SYS) clean
make -C gamate clean
make -C pce clean
make -C sym1 clean

View File

@ -20,10 +20,10 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
all: c64-scpu-test.prg c128-scpu-test.prg c64dtv-test.prg \

View File

@ -23,10 +23,10 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
all: hgrshow hgrtest dhgrshow

View File

@ -21,10 +21,10 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
all: charmapping.xex defdev.xex displaylist.xex mem.xex multi.xex ostype.xex \

View File

@ -21,10 +21,10 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
all: hello

View File

@ -24,19 +24,27 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
all: petscii.prg cbmdir-test.prg
ifeq ($(SYS),c64)
petscii.prg: petscii.c
$(CL) -t $(SYS) -O -o petscii.prg petscii.c
else
petscii.prg:
endif
cbmdir-test.prg: cbmdir-test.c
ifeq ($(SYS),vic20)
$(CL) -t $(SYS) -C vic20-32k.cfg -Oris -o $@ $<
else
$(CL) -t $(SYS) -Oris -o $@ $<
endif
clean:
@$(DEL) petscii.prg cbmdir-test.prg 2>$(NULLDEV)
@$(DEL) *.lbl petscii.prg cbmdir-test.prg 2>$(NULLDEV)

View File

@ -21,10 +21,10 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
all: audiotest.bin lcdtest.bin ctest.bin

View File

@ -7,7 +7,7 @@ unsigned char y = 0;
unsigned char x = 0;
unsigned short n;
int main(int argc, char *argv[])
void main(void)
{
clrscr();
gotoxy(0,0);cputs("Gamate C-Test");
@ -47,6 +47,4 @@ int main(int argc, char *argv[])
(*((unsigned char*)LCD_YPOS)) = y;
}
return 0;
}

View File

@ -6,7 +6,7 @@
static unsigned char* V[256];
static char* V[256];
@ -17,7 +17,7 @@ static char* Alloc (void)
unsigned char Size = (((unsigned char)rand()) & 0x7F) + 1;
/* Allocate memory */
unsigned char* P = malloc (Size);
char* P = malloc (Size);
/* Set the string to a defined value. We use the size, since this will
** also allow us to retrieve it later.
@ -33,7 +33,7 @@ static char* Alloc (void)
static void Free (unsigned char* P)
static void Free (char* P)
/* Check a memory block and free it */
{
unsigned char I;

View File

@ -21,10 +21,10 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
.PHONY: all clean test

View File

@ -5,7 +5,7 @@
#include <_heap.h>
static unsigned char* V[256];
static char* V[256];
static void ShowInfo (void)
/* Show heap info */

32
targettest/strnlen.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char * str = "0123456789";
void
check (size_t result, size_t expected)
{
if (result != expected) {
printf ("Expected strnlen() to return %u, got %u.\n",
expected, result);
exit (EXIT_FAILURE);
}
}
int
main (void)
{
size_t maxlen = strlen (str);
size_t result;
size_t expected;
for (expected = 0; expected < maxlen; expected++)
check (strnlen (str, expected), expected);
check (strnlen (str, maxlen << 1), maxlen);
printf ("strnlen() OK.\n");
return EXIT_SUCCESS;
}

View File

@ -20,10 +20,10 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
all: symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin

View File

@ -60,13 +60,13 @@ extern unsigned int getsp(void); /* comes from getsp.s */
static unsigned char verbose;
static unsigned char terminate;
static unsigned char cmd;
static unsigned char *cmd_asc, *arg1, *arg2, *arg3, *args; /* 'args': everything after command */
static unsigned char keyb_buf[KEYB_BUFSZ + 1];
static unsigned char keyb_buf2[KEYB_BUFSZ + 1];
static char *cmd_asc, *arg1, *arg2, *arg3, *args; /* 'args': everything after command */
static char keyb_buf[KEYB_BUFSZ + 1];
static char keyb_buf2[KEYB_BUFSZ + 1];
static size_t cpbuf_sz = 4096;
struct cmd_table {
unsigned char *name;
char *name;
unsigned char code;
} cmd_table[] = {
{ "help", CMD_HELP },
@ -196,7 +196,7 @@ static void cmd_help(void)
static void cmd_ls(void)
{
DIR *dir;
unsigned char *arg;
char *arg;
struct dirent *dirent;
#ifdef __ATARI__
char need_free = 0;
@ -356,7 +356,7 @@ static void cmd_rename(void)
static void cmd_exec(void)
{
unsigned char *progname, *arguments;
char *progname, *arguments;
progname = strtok(args, " \t\n");
if (! progname) {
@ -373,7 +373,7 @@ static void cmd_exec(void)
static void cmd_copy(void)
{
int srcfd = -1, dstfd = -1;
unsigned char *buf;
char *buf;
int readsz, writesz;
if (!arg2 || arg3) {