From 921e54917268637498610d5fb41c3836bf8b384a Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Fri, 24 Dec 2021 23:44:57 +0100 Subject: [PATCH 01/32] Add standard C library function strnlen(). --- include/string.h | 1 + libsrc/common/strnlen.s | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 libsrc/common/strnlen.s diff --git a/include/string.h b/include/string.h index 2f5953196..74442415f 100644 --- a/include/string.h +++ b/include/string.h @@ -50,6 +50,7 @@ char* __fastcall__ strcpy (char* dest, const char* src); size_t __fastcall__ strcspn (const char* s1, const char* s2); char* __fastcall__ strerror (int errcode); size_t __fastcall__ strlen (const char* s); +size_t __fastcall__ strnlen (const char* s, size_t maxlen); char* __fastcall__ strncat (char* s1, const char* s2, size_t count); int __fastcall__ strncmp (const char* s1, const char* s2, size_t count); char* __fastcall__ strncpy (char* dest, const char* src, size_t count); diff --git a/libsrc/common/strnlen.s b/libsrc/common/strnlen.s new file mode 100644 index 000000000..e748325e2 --- /dev/null +++ b/libsrc/common/strnlen.s @@ -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 + ; Fetch string pointer. + sta ptr1 + stx ptr1+1 + + ; Clear return value. + lda #0 + sta tmp1 + sta tmp2 + + ; Get maximum length. + jsr popax + sta tmp3 + inc tmp3 + inx + stx tmp4 + + ;;; Loop over string. + ldy #0 + + ; Decrement maximum length. +next: dec tmp3 + bne l2 + dec tmp4 + beq done +l2: + + lda (ptr1),y + beq done + + ; Step to next character. + inc ptr1 + bne l1 + inc ptr1+1 +l1: + + ; Increment return value. + inc tmp1 + bne next + inc tmp2 + + jmp next + + +done: lda tmp1 + ldx tmp2 + rts +.endproc From 0b84465276dc2c6e2f380a3d26b1e08c3015b0ac Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 09:11:58 +0100 Subject: [PATCH 02/32] Fix strnlen(). --- libsrc/common/strnlen.s | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libsrc/common/strnlen.s b/libsrc/common/strnlen.s index e748325e2..eb2c16006 100644 --- a/libsrc/common/strnlen.s +++ b/libsrc/common/strnlen.s @@ -5,25 +5,25 @@ .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. - lda #0 - sta tmp1 - sta tmp2 + ldy #0 + sty tmp1 + sty tmp2 - ; Get maximum length. - jsr popax - sta tmp3 - inc tmp3 - inx - stx tmp4 ;;; Loop over string. - ldy #0 - ; Decrement maximum length. next: dec tmp3 bne l2 @@ -35,7 +35,7 @@ l2: beq done ; Step to next character. - inc ptr1 + iny bne l1 inc ptr1+1 l1: @@ -45,7 +45,7 @@ l1: bne next inc tmp2 - jmp next + bne next ; (jmp) done: lda tmp1 From c9ccc82b9f8d43daf489c4139d8383206a7aa925 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 09:12:13 +0100 Subject: [PATCH 03/32] strnlen(): Add comment with POSIX standard. --- include/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/string.h b/include/string.h index 74442415f..70abd5851 100644 --- a/include/string.h +++ b/include/string.h @@ -50,7 +50,7 @@ char* __fastcall__ strcpy (char* dest, const char* src); size_t __fastcall__ strcspn (const char* s1, const char* s2); char* __fastcall__ strerror (int errcode); size_t __fastcall__ strlen (const char* s); -size_t __fastcall__ strnlen (const char* s, size_t maxlen); +size_t __fastcall__ strnlen (const char* s, size_t maxlen); /* POSIX.1-2008 */ char* __fastcall__ strncat (char* s1, const char* s2, size_t count); int __fastcall__ strncmp (const char* s1, const char* s2, size_t count); char* __fastcall__ strncpy (char* dest, const char* src, size_t count); From 87fe2f5d0ea7536fcfbf2dd9523bcf47cc30a227 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 09:13:43 +0100 Subject: [PATCH 04/32] Add test of strnlen(). --- targettest/Makefile | 4 ++++ targettest/strnlen.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 targettest/strnlen.c diff --git a/targettest/Makefile b/targettest/Makefile index f3694335c..44933949a 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -160,6 +160,7 @@ EXELIST_c64 = \ scanf-test \ ser-test \ strdup-test \ + strnlen \ stroserror-test \ strqtok-test \ tinyshell \ @@ -190,6 +191,7 @@ EXELIST_vic20 = \ rename-test \ scanf-test \ strdup-test \ + strnlen \ stroserror-test \ strqtok-test \ tinyshell \ @@ -222,6 +224,7 @@ EXELIST_apple2 = \ seek \ ser-test \ strdup-test \ + strnlen \ stroserror-test \ strqtok-test \ tinyshell \ @@ -257,6 +260,7 @@ EXELIST_atari = \ seek \ ser-test \ strdup-test \ + strnlen \ stroserror-test \ strqtok-test \ tinyshell \ diff --git a/targettest/strnlen.c b/targettest/strnlen.c new file mode 100644 index 000000000..d07b7628c --- /dev/null +++ b/targettest/strnlen.c @@ -0,0 +1,32 @@ +#include +#include +#include + +const char * str = "0123456789"; + +void +check (size_t result, size_t expected) +{ + if (result != expected) { + printf ("Expected strnlen() to return %d, got %d.\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; +} From ba93ab07bc5652be9b0692180ab0ae616e96c74c Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 09:19:37 +0100 Subject: [PATCH 05/32] Do not compile petscii test for unsupported platforms. Only C64 is supported. --- targettest/cbm/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/targettest/cbm/Makefile b/targettest/cbm/Makefile index 298f80d62..147df2c1c 100644 --- a/targettest/cbm/Makefile +++ b/targettest/cbm/Makefile @@ -32,8 +32,12 @@ 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 $(CL) -t $(SYS) -Oris -o $@ $< From 58dd28f0536b269c7fe3d03200985e8d05d78c3d Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 09:40:32 +0100 Subject: [PATCH 06/32] Make VICE monitor command lists for Commodore platforms. --- targettest/Makefile | 40 +++++++++++++++++++++++++++++++++++++++- targettest/cbm/Makefile | 2 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/targettest/Makefile b/targettest/Makefile index f3694335c..16f25fd3f 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -122,6 +122,44 @@ DISK_atarixl = testcode.atr .PRECIOUS: %.o +LDFLAGS= +ifeq ($(SYS),c64) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),c128) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),c16) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),cbm510) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),cbm510) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),cx16) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),geos-cbm) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),lunix) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),pet) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),pet-overlay) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),plus4) + LDFLAGS+=-Ln $@.lst +endif +ifeq ($(SYS),vic20) + LDFLAGS+=-Ln $@.lst +endif + .o: ifeq ($(SYS),vic20) $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib @@ -386,7 +424,7 @@ testcode.atr: testcode # Clean-up rules mostlyclean: - @$(DEL) *.lbl *.map *.o 2>$(NULLDEV) + @$(DEL) *.lbl *.map *.lst *.o 2>$(NULLDEV) # we cant use .s since we have asm files in the directory that we want to keep @$(DEL) ${patsubst %.c,%.s,$(wildcard *.c)} 2>$(NULLDEV) diff --git a/targettest/cbm/Makefile b/targettest/cbm/Makefile index 147df2c1c..73b51fc76 100644 --- a/targettest/cbm/Makefile +++ b/targettest/cbm/Makefile @@ -43,4 +43,4 @@ cbmdir-test.prg: cbmdir-test.c $(CL) -t $(SYS) -Oris -o $@ $< clean: - @$(DEL) petscii.prg cbmdir-test.prg 2>$(NULLDEV) + @$(DEL) *.lst petscii.prg cbmdir-test.prg 2>$(NULLDEV) From bdd18d958b47332fbad42d0934b91d5e52639d79 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 09:45:15 +0100 Subject: [PATCH 07/32] cbmdir-test for VICs needs memory expansion. --- targettest/cbm/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/targettest/cbm/Makefile b/targettest/cbm/Makefile index 73b51fc76..3c0678c32 100644 --- a/targettest/cbm/Makefile +++ b/targettest/cbm/Makefile @@ -40,7 +40,11 @@ petscii.prg: endif cbmdir-test.prg: cbmdir-test.c +ifeq ($(SYS),vic20) + $(CL) -C vic20-32k.cfg -Oris -o $@ $< +else $(CL) -t $(SYS) -Oris -o $@ $< +endif clean: @$(DEL) *.lst petscii.prg cbmdir-test.prg 2>$(NULLDEV) From 65564a158c5347f3e949139833706344a7a35b0b Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 09:57:18 +0100 Subject: [PATCH 08/32] Remove most compiler warnings. --- targettest/gamate/ctest.c | 3 +++ targettest/heaptest.c | 6 +++--- targettest/strdup-test.c | 2 +- targettest/tinyshell.c | 14 +++++++------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/targettest/gamate/ctest.c b/targettest/gamate/ctest.c index bff3f5986..b2c3740c5 100644 --- a/targettest/gamate/ctest.c +++ b/targettest/gamate/ctest.c @@ -9,6 +9,9 @@ unsigned short n; int main(int argc, char *argv[]) { + (void) argc; // Suppress warnings. + (void) argv; + clrscr(); gotoxy(0,0);cputs("Gamate C-Test"); diff --git a/targettest/heaptest.c b/targettest/heaptest.c index 560694bee..e3a21eaa6 100644 --- a/targettest/heaptest.c +++ b/targettest/heaptest.c @@ -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; diff --git a/targettest/strdup-test.c b/targettest/strdup-test.c index 2fcc9816f..8e7ae87d8 100644 --- a/targettest/strdup-test.c +++ b/targettest/strdup-test.c @@ -5,7 +5,7 @@ #include <_heap.h> -static unsigned char* V[256]; +static char* V[256]; static void ShowInfo (void) /* Show heap info */ diff --git a/targettest/tinyshell.c b/targettest/tinyshell.c index c83bd14e8..71e9b56e3 100644 --- a/targettest/tinyshell.c +++ b/targettest/tinyshell.c @@ -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) { From 666f266e900653fc4f27ba5839b08630af36136b Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 14:21:47 +0100 Subject: [PATCH 09/32] Move strnlen() to non-ANSI section. --- include/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/string.h b/include/string.h index 70abd5851..83970493e 100644 --- a/include/string.h +++ b/include/string.h @@ -50,7 +50,6 @@ char* __fastcall__ strcpy (char* dest, const char* src); size_t __fastcall__ strcspn (const char* s1, const char* s2); char* __fastcall__ strerror (int errcode); size_t __fastcall__ strlen (const char* s); -size_t __fastcall__ strnlen (const char* s, size_t maxlen); /* POSIX.1-2008 */ char* __fastcall__ strncat (char* s1, const char* s2, size_t count); int __fastcall__ strncmp (const char* s1, const char* s2, size_t count); char* __fastcall__ strncpy (char* dest, const char* src, size_t count); @@ -79,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); From d1cbb1deebe0b015f90e954b7a07ab78fe96f165 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 20:04:10 +0100 Subject: [PATCH 10/32] More strict printf() format string. --- targettest/strnlen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targettest/strnlen.c b/targettest/strnlen.c index d07b7628c..ac39f2396 100644 --- a/targettest/strnlen.c +++ b/targettest/strnlen.c @@ -8,7 +8,7 @@ void check (size_t result, size_t expected) { if (result != expected) { - printf ("Expected strnlen() to return %d, got %d.\n", + printf ("Expected strnlen() to return %u, got %u.\n", expected, result); exit (EXIT_FAILURE); } From de158c08470f40098fff9de4230c56751b536e88 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 20:07:34 +0100 Subject: [PATCH 11/32] Use suffix '.lbl' instead of '.lst'. --- targettest/Makefile | 26 +++++++++++++------------- targettest/cbm/Makefile | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/targettest/Makefile b/targettest/Makefile index 16f25fd3f..6aabe06a3 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -124,40 +124,40 @@ DISK_atarixl = testcode.atr LDFLAGS= ifeq ($(SYS),c64) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),c128) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),c16) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),cbm510) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),cbm510) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),cx16) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),geos-cbm) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),lunix) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),pet) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),pet-overlay) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),plus4) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),vic20) - LDFLAGS+=-Ln $@.lst + LDFLAGS+=-Ln $@.lbl endif .o: @@ -424,7 +424,7 @@ testcode.atr: testcode # Clean-up rules mostlyclean: - @$(DEL) *.lbl *.map *.lst *.o 2>$(NULLDEV) + @$(DEL) *.lbl *.map *.lbl *.o 2>$(NULLDEV) # we cant use .s since we have asm files in the directory that we want to keep @$(DEL) ${patsubst %.c,%.s,$(wildcard *.c)} 2>$(NULLDEV) diff --git a/targettest/cbm/Makefile b/targettest/cbm/Makefile index 3c0678c32..cbff73273 100644 --- a/targettest/cbm/Makefile +++ b/targettest/cbm/Makefile @@ -47,4 +47,4 @@ else endif clean: - @$(DEL) *.lst petscii.prg cbmdir-test.prg 2>$(NULLDEV) + @$(DEL) *.lbl petscii.prg cbmdir-test.prg 2>$(NULLDEV) From 34dd29556fb72586829de1456f055366bad9083e Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 20:09:18 +0100 Subject: [PATCH 12/32] Use -t option alongside -C. --- targettest/Makefile | 2 +- targettest/cbm/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/targettest/Makefile b/targettest/Makefile index 6aabe06a3..1340fb5eb 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -162,7 +162,7 @@ endif .o: ifeq ($(SYS),vic20) - $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib + $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(SYS) -C vic20-32k.cfg -m $@.map $^ $(SYS).lib else $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib endif diff --git a/targettest/cbm/Makefile b/targettest/cbm/Makefile index cbff73273..a7646c2d9 100644 --- a/targettest/cbm/Makefile +++ b/targettest/cbm/Makefile @@ -41,7 +41,7 @@ endif cbmdir-test.prg: cbmdir-test.c ifeq ($(SYS),vic20) - $(CL) -C vic20-32k.cfg -Oris -o $@ $< + $(CL) -t $(SYS) -C vic20-32k.cfg -Oris -o $@ $< else $(CL) -t $(SYS) -Oris -o $@ $< endif From 412a30987ad24447f6f3f37d0307c505eb65a5db Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 20:10:53 +0100 Subject: [PATCH 13/32] Remove -t option for linker only. --- targettest/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targettest/Makefile b/targettest/Makefile index 1340fb5eb..6aabe06a3 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -162,7 +162,7 @@ endif .o: ifeq ($(SYS),vic20) - $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(SYS) -C vic20-32k.cfg -m $@.map $^ $(SYS).lib + $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib else $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib endif From f4702cbc40d7111118e2d182141bafe145669577 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 20:11:22 +0100 Subject: [PATCH 14/32] Make label file for c610 platform. --- targettest/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targettest/Makefile b/targettest/Makefile index 6aabe06a3..f9afff64f 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -135,7 +135,7 @@ endif ifeq ($(SYS),cbm510) LDFLAGS+=-Ln $@.lbl endif -ifeq ($(SYS),cbm510) +ifeq ($(SYS),cbm610) LDFLAGS+=-Ln $@.lbl endif ifeq ($(SYS),cx16) From 0707cdbe2c75cf36aa7f5098870beddefaa24dda Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 20:12:45 +0100 Subject: [PATCH 15/32] Remove command line arguments and return value from main(). --- targettest/gamate/ctest.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/targettest/gamate/ctest.c b/targettest/gamate/ctest.c index b2c3740c5..6b2de2354 100644 --- a/targettest/gamate/ctest.c +++ b/targettest/gamate/ctest.c @@ -7,11 +7,8 @@ unsigned char y = 0; unsigned char x = 0; unsigned short n; -int main(int argc, char *argv[]) +void main(void) { - (void) argc; // Suppress warnings. - (void) argv; - clrscr(); gotoxy(0,0);cputs("Gamate C-Test"); From 3bd72b96599c37d2acf6a1813bd17133caa884b2 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 20:15:09 +0100 Subject: [PATCH 16/32] main(): Re-introduce return value. Compiler rejects 'void'. --- targettest/gamate/ctest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targettest/gamate/ctest.c b/targettest/gamate/ctest.c index 6b2de2354..c3ee819bc 100644 --- a/targettest/gamate/ctest.c +++ b/targettest/gamate/ctest.c @@ -7,7 +7,7 @@ unsigned char y = 0; unsigned char x = 0; unsigned short n; -void main(void) +int main(void) { clrscr(); gotoxy(0,0);cputs("Gamate C-Test"); From 05b8af07aa38531a193d10b77a6be59e66400fdc Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 21:21:01 +0100 Subject: [PATCH 17/32] main(): No return value. --- targettest/gamate/ctest.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/targettest/gamate/ctest.c b/targettest/gamate/ctest.c index c3ee819bc..9acbe94cd 100644 --- a/targettest/gamate/ctest.c +++ b/targettest/gamate/ctest.c @@ -7,7 +7,7 @@ unsigned char y = 0; unsigned char x = 0; unsigned short n; -int main(void) +void main(void) { clrscr(); gotoxy(0,0);cputs("Gamate C-Test"); @@ -47,6 +47,4 @@ int main(void) (*((unsigned char*)LCD_YPOS)) = y; } - - return 0; } From 683739d6fc308da3a11d3359f5d7ecbc569e3c20 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 25 Dec 2021 21:25:52 +0100 Subject: [PATCH 18/32] mostlyclean: Clean up. --- targettest/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targettest/Makefile b/targettest/Makefile index f9afff64f..7d752480b 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -424,7 +424,7 @@ testcode.atr: testcode # Clean-up rules mostlyclean: - @$(DEL) *.lbl *.map *.lbl *.o 2>$(NULLDEV) + @$(DEL) *.lbl *.map *.o 2>$(NULLDEV) # we cant use .s since we have asm files in the directory that we want to keep @$(DEL) ${patsubst %.c,%.s,$(wildcard *.c)} 2>$(NULLDEV) From cf1bc4fad427052eae7ce4d9077715459d938e89 Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Fri, 7 Jan 2022 09:56:46 -0500 Subject: [PATCH 19/32] Fix Pop() implementation in src/sim65/paravirt.c (fixes #1625) The Pop() function was not handling stack pointer wrap around correctly. Also, change the simulated RTS implementation in ParaVirtHooks() to explicitly sequence the two Pop() calls in the correct order. --- src/sim65/paravirt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index e73bd3400..b3ec8fa37 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -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)); } @@ -327,5 +327,7 @@ void ParaVirtHooks (CPURegs* Regs) Hooks[Regs->PC - PARAVIRT_BASE] (Regs); /* Simulate RTS */ - Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1; + unsigned lo = Pop(Regs); + unsigned hi = Pop(Regs); + Regs->PC = lo + (hi << 8) + 1; } From 92bfbeb8abf85596a30a13d5af275b535d640dfe Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Sat, 8 Jan 2022 16:24:40 -0500 Subject: [PATCH 20/32] Adjust Pop() sequencing in paravirt.c --- src/sim65/paravirt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index b3ec8fa37..7da683f1d 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -328,6 +328,5 @@ void ParaVirtHooks (CPURegs* Regs) /* Simulate RTS */ unsigned lo = Pop(Regs); - unsigned hi = Pop(Regs); - Regs->PC = lo + (hi << 8) + 1; + Regs->PC = lo + (Pop(Regs) << 8) + 1; } From 1f6bc6240faa126048c13ad20427b250d9cba235 Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Sat, 8 Jan 2022 16:29:42 -0500 Subject: [PATCH 21/32] Move local variable declaration to top of block --- src/sim65/paravirt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index 7da683f1d..ba3a76461 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -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,6 +329,6 @@ void ParaVirtHooks (CPURegs* Regs) Hooks[Regs->PC - PARAVIRT_BASE] (Regs); /* Simulate RTS */ - unsigned lo = Pop(Regs); + lo = Pop(Regs); Regs->PC = lo + (Pop(Regs) << 8) + 1; } From 22a3d55e40317e2554c5e686725d793e8df9900c Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Sat, 8 Jan 2022 16:39:30 -0500 Subject: [PATCH 22/32] Add space after function names --- src/sim65/paravirt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index ba3a76461..db4120326 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -329,6 +329,6 @@ void ParaVirtHooks (CPURegs* Regs) Hooks[Regs->PC - PARAVIRT_BASE] (Regs); /* Simulate RTS */ - lo = Pop(Regs); - Regs->PC = lo + (Pop(Regs) << 8) + 1; + lo = Pop (Regs); + Regs->PC = lo + (Pop (Regs) << 8) + 1; } From 12f9a2f1f87b90d0ec880bc4e76be10996150b9f Mon Sep 17 00:00:00 2001 From: Daniel Lehenbauer Date: Mon, 17 Jan 2022 08:22:15 -0800 Subject: [PATCH 23/32] asminc/pet.inc: Add PIA1 & PIA2 --- asminc/pet.inc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/asminc/pet.inc b/asminc/pet.inc index d165bb336..ee96d378c 100644 --- a/asminc/pet.inc +++ b/asminc/pet.inc @@ -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 From 91920f807ee3b80063290215cdc352c6d4328786 Mon Sep 17 00:00:00 2001 From: Scott Prive Date: Sun, 23 Jan 2022 18:53:14 -0500 Subject: [PATCH 24/32] document special case on sub 40-col modes --- doc/funcref.sgml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index e6cb42a0f..2dc28137a 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -7788,6 +7788,10 @@ format specifiers as /. between The function is only available as fastcall function, so it may only be used in presence of a prototype. +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 gotoxy(20,0) to target the "next" line, or you can switch to write() +function which does not have this side effect. Date: Mon, 24 Jan 2022 20:13:49 +0100 Subject: [PATCH 25/32] put Atari 20-column note to where it belongs... --- doc/atari.sgml | 5 +++++ doc/funcref.sgml | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/atari.sgml b/doc/atari.sgml index 903895d17..ec281c0b5 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -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. +Technical details