From 1d877494bf8fa096057271196527ed3ddb3a6fbd Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Feb 2016 23:37:04 +0100 Subject: [PATCH 001/784] initial commit from c64-rrr-1.0 --- libsrc/c64/emd/c64-rrr.s | 285 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 libsrc/c64/emd/c64-rrr.s diff --git a/libsrc/c64/emd/c64-rrr.s b/libsrc/c64/emd/c64-rrr.s new file mode 100644 index 000000000..3de0ec0f4 --- /dev/null +++ b/libsrc/c64/emd/c64-rrr.s @@ -0,0 +1,285 @@ +; +;Extended Memory Driver for the Retro Replay RAM (32k) +;should work for ActionReplay as well... +; +; +;Version 1.0 +; +;Johannes Braun 2006-08-22 +;hannenz@freenet.de +; +;use the functions described in "usr/lib/cc65/include/em.h" to make use of this driver. +;------------------------------------------------------------------------------------------------------------------------- + +;NOTE: If called from ROM the Lo_Code routines must exit with LDA #$00 / STA $DE00!!! just change and recompile! + + .include "em-kernel.inc" + .importzp ptr1,ptr2,ptr3,ptr4,tmp1 + .macpack generic + +c64_ram = ptr1 ;use some more expressive identifiers... +rr_ram = ptr2 +len = ptr3 +aux = ptr4 +temp = tmp1 + +Lo_Mem = $0100 ;location of Lo_Code (must be below $1000 or above $e000) + +.segment "JUMPTABLE" + + .byte $65,$6d,$64 ;Driver signature + .byte EMD_API_VERSION + + .addr INSTALL ;Jump Table + .addr UNINSTALL + .addr PAGECOUNT + .addr MAP + .addr USE + .addr COMMIT + .addr COPYFROM + .addr COPYTO + +.bss +window: .res 256 ;the memory window (256 bytes) + +.rodata +dummy: .word window ;a "pseudo"-em_copy_struct, used by em_map/ em_commit + .byte 0 ;to pass over to COPYTO/COPYFROM +curpage: .byte $ff ;just this byte is changed according to the desired page + .byte 0 + .word 256 + +.code + +;---------------------------------------------------------------------------------------- +;unsigned char __fastcall__ em_install(void *driver); +;returns an error code +;---------------------------------------------------------------------------------------- +INSTALL: + ldx #c2-c1 +: lda c1,x + sta Lo_Mem,x + dex + bpl :- + stx curpage ;invalidate current page ($ff) + + ldx #$23 ;$de00 value for rr-ram + ldy #$02 ;$de00 value for c64-ram, CHANGE TO LDA #$00 if driver is called from ROM! + bne COMMON + +c1: stx $de00 ;try accessing rr-ram + lda $8888 + pha + lda $9999 ;remember old content of $8888 and $9999 + pha + + lda #$55 + sta $8888 ;write test values + asl + sta $9999 + + sty $de00 ;switch to c64 ram + stx $8888 + stx $9999 + + stx $de00 ;switch to rr-ram again (if present) + ldx $8888 ;read the values + ldy $9999 + pla + sta $9999 ;and write the old values back + pla + sta $8888 + + lda #2 + sta $de00 ;c64 ram again + + cli + cpx #$55 + bne no + cpy #$aa + bne no + lda #0 + rts +no: asl ;.A still has #2, so return #4: error code for "device not present" + rts +c2: +;---------------------------------------------------------------------------------------- +;void em_uninstall(void); +;---------------------------------------------------------------------------------------- +UNINSTALL: +return_null: + lda #$00 ;always return 32kb (128 pages) + .byte $2c + +;---------------------------------------------------------------------------------------- +;unsigned __fastcall__ em_pagecount(void); +;---------------------------------------------------------------------------------------- +PAGECOUNT: + lda #$80 + ldx #$00 + rts + +;---------------------------------------------------------------------------------------- +;void* __fastcall__ em_use(unsigned page); +;---------------------------------------------------------------------------------------- +USE: + cmp #$80 ;valid page? + bcs return_null ;no, return NULL pointer + sta curpage ;set to current page +return_win: lda #window +return: rts + +;---------------------------------------------------------------------------------------- +;void* __fastcall__ em_map(unsigned page); +;---------------------------------------------------------------------------------------- +MAP: + cmp #$80 + bcs return_null + sta curpage + lda #dummy ;adress in .A/.X) + jsr COPYFROM + bcs return_win ;function returns pointer to window (returns always with carry set!) + +;---------------------------------------------------------------------------------------- +;void __fastcall__ em_commit(void); +;---------------------------------------------------------------------------------------- +COMMIT: + lda curpage + cmp #$80 + bcs return + lda #dummy ;adress in .A/.X) + +;---------------------------------------------------------------------------------------- +;void __fastcall__ em_copyto (struct em_copy *copy_data); +;---------------------------------------------------------------------------------------- +COPYTO: + jsr get_struct_data ;read the parameters passed in the em_struct pointed to by .A/.X upon call + + ;copy the main copyto routine into Lo_Mem + + ldy #Lo_Code1_End - Lo_Code1 +: lda Lo_Code1-1,y + sta Lo_Mem-1,y + dey + bne :- +COMMON: + sei + jmp Lo_Mem + + ;this part will be executed in Lo_Mem (!) by COPYFROM + +Lo_Code2: + stx $de00 ;map in rr-ram + lda (rr_ram),y ;get byte from rr-ram + sty $de00 ;RR-ROM will be mapped to $8000-$a000 but write access will go to c64-ram anyway!! + sta (c64_ram),y ;and write to c64-ram + nop ;pad to same size as Lo_Code1 + nop +Lo_Code2_End: + + + ;this part will be executed in Lo_Mem (!) by COPYTO + +Lo_Code1: + lda (c64_ram),y ;read 1 byte from c64-ram + stx $de00 ;map in rr-ram + sta (rr_ram),y ;write byte to rr-ram + lda #$02 ;map in c64-ram again + sta $de00 + ;12 bytes + + ;this part is common for both COPYFROM/COPYTO and executed in Lo_Mem, too + +Lo_Code_Common: + inc c64_ram ;increase pointers + bne :+ + inc c64_ram+1 +: inc rr_ram + bne @skip + inc rr_ram+1 + lda rr_ram+1 + cmp #$a0 ;wrap around 16k boundary in rr-ram window ($8000-$a000) + bne @skip + + lda #$80 ;reset pointer to $8000 + sta rr_ram+1 + txa ;adjust value in .X to map in next 16k-bank in rr-ram + adc #7 ;carry is set because of former CMP, so it adds 8 + tax + ;27 bytes +@skip: lda c64_ram + cmp len + lda c64_ram+1 + sbc len+1 + bcc Lo_Code1 + lda #2 ;CHANGE to LDA #0 if driver is called from ROM + sta $de00 + cli + rts ;17 bytes = 56 bytes Lo_Code ($38) +Lo_Code1_End: +;---------------------------------------------------------------------------------------- +;void __fastcall__ em_copyfrom(struct em_copy *copy_data); +;copy from extended memory into linear memory +;---------------------------------------------------------------------------------------- +COPYFROM: + jsr get_struct_data + + ldy #Lo_Code2_End - Lo_Code2 ;copy routine into Lo_Mem +: lda Lo_Code2-1,y + sta Lo_Mem-1,y + dey + bne :- + ldy #Lo_Code1_End-Lo_Code_Common +: lda Lo_Code_Common-1,y + sta Lo_Mem+11,y + dey + bne :- + beq COMMON ;and execute... +;---------------------------------------------------------------------------------------- +;read the struct data located at (.A/.X) +;and setup parameters for stash/ fetch operation +;---------------------------------------------------------------------------------------- +get_struct_data: + + ;read and process the values from the em_copy struct passed to as parameters rameter to the + ;functions em_copyto and em_copyfrom + + sta aux ;store adress of struct (passed in .A/.X) into a zp pointer + stx aux+1 + ldy #0 ;index 0 + + lda (aux),y ;read c64-adress lo + sta c64_ram + iny + lda (aux),y ;read c64-adress hi + sta c64_ram+1 ;(c64_ram) --> points to c64-adress space + iny + lda (aux),y ;read rr-adress lo + sta rr_ram + iny + lda (aux),y ;rr-adress hi + pha ;remember + and #$1f + ora #$80 ;adjust into 16k-window ($8000-$a000) + sta rr_ram+1 + pla ;re-get hi byte of rr-adress + and #$60 ;isolate bits 5 and 6 + lsr + lsr ;shift into bits 3 and 4 + ora #$23 ;set bit 5 (select ram) and 1+2 (game/exrom setting for ULTIMAX-mode) + tax ;.X has now the value to write into $de00 to acess rr-ram at desired 16k-bank + iny + iny ;skip unused byte + lda (aux),y ;read length lo-byte + clc + adc c64_ram ;add to c64-addres + sta len + iny + lda (aux),y ;length hi-byte + adc c64_ram+1 + sta len+1 ;tmp2: length, tmp3 contains end adress of transfer in c64-ram. + rts ;55 bytes + From 799aec23a64c9f11fa2591f5e8dc7a93ee298430 Mon Sep 17 00:00:00 2001 From: Dave Plummer Date: Sat, 4 Jun 2022 13:00:48 -0700 Subject: [PATCH 002/784] Add KIM-1 Support --- asminc/kim1.inc | 28 +++++++++++++++++ cfg/kim1.cfg | 41 ++++++++++++++++++++++++ include/kim1.h | 67 ++++++++++++++++++++++++++++++++++++++++ libsrc/Makefile | 1 + libsrc/kim1/crt0.s | 47 ++++++++++++++++++++++++++++ libsrc/kim1/ctype.s | 5 +++ libsrc/kim1/read.s | 51 ++++++++++++++++++++++++++++++ libsrc/kim1/tapeio.s | 39 +++++++++++++++++++++++ libsrc/kim1/write.s | 49 +++++++++++++++++++++++++++++ samples/Makefile | 6 +++- samples/kim1/Makefile | 56 +++++++++++++++++++++++++++++++++ samples/kim1/kimHello | Bin 0 -> 2789 bytes samples/kim1/kimHello.c | 24 ++++++++++++++ src/ca65/main.c | 4 +++ src/cc65/main.c | 4 +++ src/common/target.c | 2 ++ src/common/target.h | 1 + targettest/Makefile | 1 + 18 files changed, 425 insertions(+), 1 deletion(-) create mode 100644 asminc/kim1.inc create mode 100644 cfg/kim1.cfg create mode 100644 include/kim1.h create mode 100644 libsrc/kim1/crt0.s create mode 100644 libsrc/kim1/ctype.s create mode 100644 libsrc/kim1/read.s create mode 100644 libsrc/kim1/tapeio.s create mode 100644 libsrc/kim1/write.s create mode 100644 samples/kim1/Makefile create mode 100644 samples/kim1/kimHello create mode 100644 samples/kim1/kimHello.c diff --git a/asminc/kim1.inc b/asminc/kim1.inc new file mode 100644 index 000000000..f0d1555a7 --- /dev/null +++ b/asminc/kim1.inc @@ -0,0 +1,28 @@ +; --------------------------------------------------------------------------- +; +; KIM-1 definitions +; +; --------------------------------------------------------------------------- + + +RAMSTART := $0200 ; Entry point + +; --------------------------------------------------------------------------- +; Monitor Functions +; --------------------------------------------------------------------------- + + +OUTCHR := $1EA0 ; Output character +INTCHR := $1E5A ; Input character without case conversion +DUMPT := $1800 ; Dump memory to tape +LOADT := $1873 ; Load memory from tape +SAL := $17F5 ; Tape load address low +SAH := $17F6 ; Tape load address high +EAL := $17F7 ; Tape address end low +EAH := $17F8 ; Tape address end high +ID := $17F9 ; Tape Identification number + +; --------------------------------------------------------------------------- +; System Memory +; --------------------------------------------------------------------------- + diff --git a/cfg/kim1.cfg b/cfg/kim1.cfg new file mode 100644 index 000000000..69636065e --- /dev/null +++ b/cfg/kim1.cfg @@ -0,0 +1,41 @@ +# kim1.cfg (4k) +# +# for unexpanded Kim-1 +# +# ld65 --config kim1.cfg -o .bin .o + +FEATURES { + STARTADDRESS: default = $0200; + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack + __STARTADDRESS__: type = export, value = %S; +} + +MEMORY { + ZP: file = %O, define = yes, start = $0000, size = $00EE; + CPUSTACK: file = "", define = yes, start = $0100, size = $0100; + RAM: file = %O, define = yes, start = %S, size = $1000 - %S - __STACKSIZE__; + MAINROM: file = "", define = yes, start = $E000, size = $1000; + TOP: file = "", define = yes, start = $F000, size = $1000; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; +} + diff --git a/include/kim1.h b/include/kim1.h new file mode 100644 index 000000000..52e690c9d --- /dev/null +++ b/include/kim1.h @@ -0,0 +1,67 @@ +/*****************************************************************************/ +/* */ +/* kim1.h */ +/* */ +/* Kim-1 system-specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2022 Dave Plummer */ +/* Email: davepl@davepl.com */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#ifndef _KIM1_H +#define _KIM1_H + +/* Check for errors */ +#if !defined(__KIM1__) +# error This module may only be used when compiling for the Kim-1! +#endif + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* Hardware */ +/*****************************************************************************/ + + +// Todo (davepl) +// +// #include <_6530.h> +// #define RIOT3 (*(struct __6530*)0x1700) // U25 +// #define RIOT2 (*(struct __6530*)0x1740) // U28 + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + +/* Read from tape */ +int __fastcall__ loadt (unsigned char); + +/* Write to tape */ +int __fastcall__ dumpt (unsigned char, const void*, const void*); + +/* End of sym1.h */ +#endif diff --git a/libsrc/Makefile b/libsrc/Makefile index 2018de801..627897d9b 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -27,6 +27,7 @@ TARGETS = apple2 \ $(CBMS) \ $(GEOS) \ gamate \ + kim1 \ lynx \ nes \ none \ diff --git a/libsrc/kim1/crt0.s b/libsrc/kim1/crt0.s new file mode 100644 index 000000000..7e7dd485b --- /dev/null +++ b/libsrc/kim1/crt0.s @@ -0,0 +1,47 @@ +; +; Startup code for cc65 (kim-1 version) +; + + .export _init, _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import _main + .import initlib, donelib, copydata, zerobss + .import __RAM_START__, __RAM_SIZE__ ; Linker generated + .import __STACKSIZE__ ; Linker generated + + .include "zeropage.inc" + .include "kim1.inc" + + +; Place the startup code in a special segment + +.segment "STARTUP" + + +; A little light housekeeping + +_init: cld ; Clear decimal mode + +; Set cc65 argument stack pointer + + lda #<(__RAM_START__ + __RAM_SIZE__) + sta sp + lda #>(__RAM_START__ + __RAM_SIZE__) + sta sp+1 + +; Initialize memory storage + + jsr zerobss ; Clear BSS segment + jsr copydata ; Initialize DATA segment + jsr initlib ; Run constructors + +; Call main() + + jsr _main + +; Back from main (this is also the _exit entry). There may be a more elegant way to9 +; return to the monitor on the Kim-1, but I don't know it! + +_exit: brk + diff --git a/libsrc/kim1/ctype.s b/libsrc/kim1/ctype.s new file mode 100644 index 000000000..1301965eb --- /dev/null +++ b/libsrc/kim1/ctype.s @@ -0,0 +1,5 @@ +; Character specification table. +; +; uses the "common" definition + + .include "ctype_common.inc" diff --git a/libsrc/kim1/read.s b/libsrc/kim1/read.s new file mode 100644 index 000000000..5566a9f27 --- /dev/null +++ b/libsrc/kim1/read.s @@ -0,0 +1,51 @@ +; +; int __fastcall__ read (int fd, void* buf, unsigned count); +; + +.include "kim1.inc" + +.import popax, popptr1 +.importzp ptr1, ptr2, ptr3 + +.export _read + +.proc _read + + sta ptr3 + stx ptr3+1 ; Count in ptr3 + inx + stx ptr2+1 ; Increment and store in ptr2 + tax + inx + stx ptr2 + jsr popptr1 ; Buffer address in ptr1 + jsr popax + +begin: dec ptr2 + bne getch + dec ptr2+1 + beq done ; If buffer full, return + +getch: jsr INTCHR ; Get character using Monitor ROM call + ;jsr OUTCHR ; Echo it + and #$7F ; Clear top bit + cmp #$07 ; Check for '\a' + bne chkcr ; ...if BEL character + ;jsr BEEP ; Make beep sound TODO +chkcr: cmp #$0D ; Check for '\r' + bne putch ; ...if CR character + lda #$0A ; Replace with '\n' + jsr OUTCHR ; and echo it + +putch: ldy #$00 ; Put char into return buffer + sta (ptr1),y + inc ptr1 ; Increment pointer + bne begin + inc ptr1+1 + bne begin + +done: lda ptr3 + ldx ptr3+1 + rts ; Return count + +.endproc diff --git a/libsrc/kim1/tapeio.s b/libsrc/kim1/tapeio.s new file mode 100644 index 000000000..4a16d6b9c --- /dev/null +++ b/libsrc/kim1/tapeio.s @@ -0,0 +1,39 @@ +; +; int __fastcall__ loadt (unsigned char id); +; int __fastcall__ dumpt (unsigned char id, void* start_addr, void* end_addr); +; + +.include "kim1.inc" + +.import popa, popax, return0, return1 + +.export _loadt, _dumpt + +.segment "CODE" + +.proc _loadt: near + + sta ID ; Tape record ID to P1L + jsr LOADT ; Read data from tape + bcs error + jmp return0 ; Return 0 if sucessful +error: jmp return1 ; or 1 if not + +.endproc + +.proc _dumpt: near + + sta EAL ; End address + stx EAH + jsr popax + sta SAL ; Start address + stx SAH + jsr popa + sta ID ; Tape Record ID + ldx #$00 + jsr DUMPT ; Write data to tape + bcs error + jmp return0 ; Return 0 if sucessful +error: jmp return1 ; or 1 if not + +.endproc diff --git a/libsrc/kim1/write.s b/libsrc/kim1/write.s new file mode 100644 index 000000000..216f5031c --- /dev/null +++ b/libsrc/kim1/write.s @@ -0,0 +1,49 @@ +; +; int __fastcall__ write (int fd, const void* buf, int count); +; + +.include "kim1.inc" + +.import popax, popptr1 +.importzp ptr1, ptr2, ptr3 + +.export _write + +.proc _write + + sta ptr3 + stx ptr3+1 ; Count in ptr3 + inx + stx ptr2+1 ; Increment and store in ptr2 + tax + inx + stx ptr2 + jsr popptr1 ; Buffer address in ptr1 + jsr popax + +begin: dec ptr2 + bne outch + dec ptr2+1 + beq done + +outch: ldy #0 + lda (ptr1),y + jsr OUTCHR ; Send character using Monitor call + cmp #$07 ; Check for '\a' + bne chklf ; ...if BEL character +;jsr BEEP ; Make beep sound +chklf: cmp #$0A ; Check for 'n' + bne next ; ...if LF character + lda #$0D ; Add a carriage return + jsr OUTCHR + +next: inc ptr1 + bne begin + inc ptr1+1 + jmp begin + +done: lda ptr3 + ldx ptr3+1 + rts ; Return count + +.endproc diff --git a/samples/Makefile b/samples/Makefile index 4007e3522..cec4bed89 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -154,7 +154,7 @@ endif # Lists of subdirectories # disasm depends on cpp -DIRLIST = tutorial geos atari2600 atari5200 apple2 gamate lynx supervision sym1 cbm +DIRLIST = tutorial geos atari2600 atari5200 apple2 gamate lynx supervision sym1 kim1 cbm # -------------------------------------------------------------------------- # Lists of executables @@ -329,6 +329,9 @@ EXELIST_supervision = \ EXELIST_sym1 = \ notavailable +EXELIST_kim1 = \ + notavailable + EXELIST_telestrat = \ ascii \ checkversion \ @@ -395,6 +398,7 @@ TARGETS := \ creativision \ cx16 \ gamate \ + kim1 \ lunix \ lynx \ nes \ diff --git a/samples/kim1/Makefile b/samples/kim1/Makefile new file mode 100644 index 000000000..89600ad5a --- /dev/null +++ b/samples/kim1/Makefile @@ -0,0 +1,56 @@ + +# Run 'make SYS='; or, set a SYS env. +# var. to build for another target system. +SYS ?= kim1 + +# Just the usual way to find out if we're +# using cmd.exe to execute make rules. +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +ifdef CMD_EXE + NULLDEV = nul: + DEL = -del /f + RMDIR = rmdir /s /q +else + NULLDEV = /dev/null + DEL = $(RM) + RMDIR = $(RM) -r +endif + +ifdef CC65_HOME + AS = $(CC65_HOME)/bin/ca65 + CC = $(CC65_HOME)/bin/cc65 + 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) +endif + +EXELIST_kim1 = \ + kimHello.bin + +ifneq ($(EXELIST_$(SYS)),) +samples: $(EXELIST_$(SYS)) +else +samples: notavailable +endif + +# empty target used to skip systems that will not work with any program in this dir +notavailable: +ifeq ($(MAKELEVEL),0) + @echo "info: kim1 tests not available for" $(SYS) +else +# suppress the "nothing to be done for 'samples' message + @echo > $(NULLDEV) +endif + +kimHello.bin: kimHello.c + $(CL) -t kim1 -O -o kimHello.bin kimHello.c + +clean: + @$(DEL) kimHello.bin 2>$(NULLDEV) diff --git a/samples/kim1/kimHello b/samples/kim1/kimHello new file mode 100644 index 0000000000000000000000000000000000000000..5842567557dc9f321409d269970f08832b736d86 GIT binary patch literal 2789 zcmbVOTWl2989pPwHj|K(i1^Ur@f{@6caBR^#e^evV4CFt9Pc8bVHbVBy0T$R2rJ0ktL?4Nib zo8J=YZ<8)^P!)bIYN9})f5+@!{>KkCxqxB*K%{?2S`KParRkDPJQrCHdD} z0@!q1Hct~T-8U=R>2Yzg!)n|iY!z*Y=9&Z-6I^_pQ(G)ZbVziBX1ZQ%rU7*b56R8W zzS-W9rvhdCYxE5<>*1Q5z-yyl4%@htlkG^!b8X~$(5S~j+uJQr9m%C)In)>Rzec2U&e!Iy&9tvVtJlaZjs>yGJKl==tlO% zXy-%Q-io#@kV>@SXK-OY>rI55LlFu+v5UA_}tI20RRB<@m$XfCNhAl?vz z*O?A!QC=cGD&HgK$#}2_4)wDQE^2_eqDvcKzUV$#xl8D8#8IhNJ$09aiQy$4dPkw( zl=z_otb=D4E^yChsu-eC#o(0SAX^8=PTeG7SGHipjkp+>v<0Hw1`NNKE{b^vuV5Tv znu{uT$PBp0Kg`wzgN$(7hz7RuOMb#sIwHcIJEJ=fgQ2gno@@ial?cm!4FLHT1GeOY z!%SYuxB&&ugE=eeD@s|{Dk-h8Y)Hr00-4jb#%*%)dP*BlRCH}PrS&!D$#q?;H*OI= z3-PV*Y?p7563}_lm?KQ0-4gw(1Y*cVz%Lsb_;HnHO=UC3a>z!Ia6;a4+Lw-ui%@Ig zkOUrtWm_oNnsLM9_pKo!Oem-DMU)*zQWrOa$|I>LVuZn7Le%? z!UWJnm~h)AlO{pNp$>ErstQ_C2IlG~GW5Lci}Xqo&O<{IsGxu;$pD32=9iL}+H7^u zX5Ac5j#V=pCz8c#<{VdCbOL2z2H8-l$nMUYA0*3*P;ACapa#1FSvZb6* z&s&+D?S3H(nb42wp2(RkdQ!xtyanM{j&+s}CmhL>cq0*kl&UCStRl-ccnebss!a+S zJt%Vx8nZ>ej%(7W@t(q-^TfCu$86Q5BTRGDiQ8&bDH==WUvbG;?Qd{URcR?;zsmbC z4U@d`%(pQB_~2~nBi_H)ifg6yXN{5Aw9&#vHg|I3iVDpgfT0N4Cl1P2l~9^uOCG6d z7E8FOWUmX%~9jU$gh?>da zx+muh+bHcd_U(naBAfN}TFNrF$OU;6*YpA&(j9C*FWWjl@4yFytL@Z|2d7hZsI>$1-l@(MIr=3XX6;Y7of>)5}T24^F|l z#REB0Q0p@VWjUUc3X4su;S==xk5T8bo?iq>h60VneFaoFhFh3@+LGBvk?&8ZvrTj~ zod>kj9bD`H(c&56f^khH#8d2EOPyi2k6HY?_zEwPFiratJt9;w?x)ao*&IO5cuGx$ zbhY&;LUdG#9%~=jl4I0T;p03v)~}W7XLV1SPK{t&DoyM47A_Up69>}YE)&`trCnTRNqAu{5TWMvyKOpFlOxSER-TGIo*tPY4?Xl|Zg7xp|L(5s-+PK48p!P) z%xzQ@q-1jg0|)7=2j3jn^90wGUHRPyemKbG-lw10wD}v)Zs~jO`ES3lZTpT5&pf?( z%jUjK&u;ERNDzsv7+YU**j^a5Vv)0G$Y^e JbXnmD{{hxi-7)|G literal 0 HcmV?d00001 diff --git a/samples/kim1/kimHello.c b/samples/kim1/kimHello.c new file mode 100644 index 000000000..dcbfb4e67 --- /dev/null +++ b/samples/kim1/kimHello.c @@ -0,0 +1,24 @@ +// -------------------------------------------------------------------------- +// Hello World for Kim-1 +// +// Dave Plummer based on Sym-1 sample by Wayne Parham +// +// davepl@davepl.com +// -------------------------------------------------------------------------- + +#include +#include + +int main (void) +{ + char str[100]; + char c = 0x00; + + printf ("\nHello World!\n\n"); + printf ("Type a line and press ENTER, please.\n\n"); + + gets( str ); + + printf ("\n\nThanks: %s\n\n", str); + return 0; +} diff --git a/src/ca65/main.c b/src/ca65/main.c index b1ef3a3db..4146aaf11 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -342,6 +342,10 @@ static void SetSys (const char* Sys) NewSymbol ("__SYM1__", 1); break; + case TGT_KIM1: + NewSymbol ("__KIM1__", 1); + break; + default: AbEnd ("Invalid target name: '%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index c08616efa..f800ac43e 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -299,6 +299,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__SYM1__", 1); break; + case TGT_KIM1: + DefineNumericMacro ("__KIM1__", 1); + break; + default: AbEnd ("Unknown target system '%s'", Sys); } diff --git a/src/common/target.c b/src/common/target.c index 4a851034a..ad62990bd 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -163,6 +163,7 @@ static const TargetEntry TargetMap[] = { { "geos", TGT_GEOS_CBM }, { "geos-apple", TGT_GEOS_APPLE }, { "geos-cbm", TGT_GEOS_CBM }, + { "kim1", TGT_KIM1 }, { "lunix", TGT_LUNIX }, { "lynx", TGT_LYNX }, { "module", TGT_MODULE }, @@ -219,6 +220,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "c65", CPU_4510, BINFMT_BINARY, CTPET }, { "cx16", CPU_65C02, BINFMT_BINARY, CTPET }, { "sym1", CPU_6502, BINFMT_BINARY, CTNone }, + { "kim1", CPU_6502, BINFMT_BINARY, CTNone }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 7087048e2..7439fa621 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -87,6 +87,7 @@ typedef enum { TGT_C65, TGT_CX16, TGT_SYM1, + TGT_KIM1, // Added at end so as not to shift existing entries TGT_COUNT /* Number of target systems */ } target_t; diff --git a/targettest/Makefile b/targettest/Makefile index 0450bfd4e..23463ccd9 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -742,6 +742,7 @@ TARGETS := \ creativision \ cx16 \ gamate \ + kim1 \ lunix \ lynx \ nes \ From 8f9777d9e0d34b4be32ff09750980138d61e9e01 Mon Sep 17 00:00:00 2001 From: Dave Plummer Date: Mon, 6 Jun 2022 15:14:01 -0700 Subject: [PATCH 003/784] Fix ushot overflow, capitalization --- cfg/kim1-60k.cfg | 41 +++++++++++++ include/kim1.h | 4 +- libsrc/kim1/crt0.s | 2 +- samples/kim1/Makefile | 8 ++- samples/kim1/kimSieve.c | 125 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 cfg/kim1-60k.cfg create mode 100644 samples/kim1/kimSieve.c diff --git a/cfg/kim1-60k.cfg b/cfg/kim1-60k.cfg new file mode 100644 index 000000000..a6704d9dd --- /dev/null +++ b/cfg/kim1-60k.cfg @@ -0,0 +1,41 @@ +# kim1.cfg (4k) +# +# for unexpanded Kim-1 +# +# ld65 --config kim1.cfg -o .bin .o + +FEATURES { + STARTADDRESS: default = $2000; + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack + __STARTADDRESS__: type = export, value = %S; +} + +MEMORY { + ZP: file = %O, define = yes, start = $0000, size = $00EE; + CPUSTACK: file = "", define = yes, start = $0100, size = $0100; + RAM: file = %O, define = yes, start = %S, size = $E000 - %S - __STACKSIZE__; + MAINROM: file = "", define = yes, start = $E000, size = $1000; + TOP: file = "", define = yes, start = $F000, size = $1000; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; +} + diff --git a/include/kim1.h b/include/kim1.h index 52e690c9d..bb616f7a0 100644 --- a/include/kim1.h +++ b/include/kim1.h @@ -2,7 +2,7 @@ /* */ /* kim1.h */ /* */ -/* Kim-1 system-specific definitions */ +/* KIM-1 system-specific definitions */ /* */ /* */ /* */ @@ -33,7 +33,7 @@ /* Check for errors */ #if !defined(__KIM1__) -# error This module may only be used when compiling for the Kim-1! +# error This module may only be used when compiling for the KIM-1! #endif diff --git a/libsrc/kim1/crt0.s b/libsrc/kim1/crt0.s index 7e7dd485b..aefdc3545 100644 --- a/libsrc/kim1/crt0.s +++ b/libsrc/kim1/crt0.s @@ -1,5 +1,5 @@ ; -; Startup code for cc65 (kim-1 version) +; Startup code for cc65 (KIM-1 version) ; .export _init, _exit diff --git a/samples/kim1/Makefile b/samples/kim1/Makefile index 89600ad5a..74c415fdc 100644 --- a/samples/kim1/Makefile +++ b/samples/kim1/Makefile @@ -32,7 +32,8 @@ else endif EXELIST_kim1 = \ - kimHello.bin + kimHello.bin \ + kimSieve.bin ifneq ($(EXELIST_$(SYS)),) samples: $(EXELIST_$(SYS)) @@ -49,8 +50,13 @@ else @echo > $(NULLDEV) endif +kimSieve.bin: kimSieve.c + $(CL) -t kim1 -C kim1-60k.cfg -O -o kimSieve.bin kimSieve.c + kimHello.bin: kimHello.c $(CL) -t kim1 -O -o kimHello.bin kimHello.c clean: + @$(DEL) kimSieve.bin 2>$(NULLDEV) @$(DEL) kimHello.bin 2>$(NULLDEV) + diff --git a/samples/kim1/kimSieve.c b/samples/kim1/kimSieve.c new file mode 100644 index 000000000..29cd7c7e9 --- /dev/null +++ b/samples/kim1/kimSieve.c @@ -0,0 +1,125 @@ +#include +#include + +typedef unsigned char byte; +typedef unsigned short int ushort; +typedef unsigned long int ulong; + +#define LIMIT 100000L + +// BITARRAY +// +// My bit-access macros pre-divide by two on the presumption that you'll never +// try try access both odd and even bits! + +#define GETBIT(array, bit) (array[bit >> 4] & (1 << ((bit >> 1) & 7))) +#define SETBIT(array, bit) (array[bit >> 4] |= (1 << ((bit >> 1) & 7))) +#define CLRBIT(array, bit) (array[bit >> 4] &= ~(1 << ((bit >> 1) & 7))) + +// RepeatChar +// +// Outputs a given character N times + +void RepeatChar(char c, size_t count) +{ + while (count--) + putc(c, stdout); +} + +// sqrti +// +// Binary search integer square root + +ushort sqrti(ulong num) +{ + long i; + ulong ret = 0; + + for(i = 15; i >= 0; i--) + { + ulong temp = ret | (1L << (ulong)i); + if(temp * temp <= num) + { + ret = temp; + } + } + return ret; +} + +// main() +// +// CC65 main function receives no parameters + +int main(void) +{ + // CC65 cannot mix code and data so we have to declare all variables here in the function prolog + + ulong iNumber; + ushort currentFactor; + ulong numBytesAllocated, rootOfLimit; + byte *array; + ulong countOfPrimes; + + rootOfLimit = sqrti(LIMIT); + puts("\r\n\r\n"); + RepeatChar('*', 70); + puts("\r\n** Prime Number Sieve - Dave Plummer 2022 **"); + RepeatChar('*', 70); + + printf("\r\n\r\nCalculating primes to %ld using a sqrt of %ld...\r\n", LIMIT, rootOfLimit); + + // Calculate how much memory should be allocated + + numBytesAllocated = (LIMIT + 15) / 16; + array = malloc(numBytesAllocated); + if (!array) + { + printf("Unable to allocate %ld bytes for %ld bits\r\n", numBytesAllocated, LIMIT); + return 0; + } + else + { + printf("Allocated %ld bytes for %ld slots\r\n", numBytesAllocated, LIMIT); + + // Preset all the bits to true + + for (iNumber = 0; iNumber < numBytesAllocated; iNumber++) + array[iNumber] = 0xFF; + } + + // Search for next unmarked factor + + currentFactor = 3; + while (currentFactor <= rootOfLimit) + { + ulong num, n; + + for (num = currentFactor; num <= LIMIT; num += 2) + { + if (GETBIT(array, num)) + { + currentFactor = num; + break; + } + } + + for (n = (ulong) currentFactor * currentFactor; n <= LIMIT; n += currentFactor * 2) + CLRBIT(array, n); + + currentFactor += 2; + } + + // Display results + // + // printf("The following primes were found at or below %ld:\r\n2, ", LIMIT); + + countOfPrimes = 1; + for (iNumber = 3; iNumber <= LIMIT; iNumber += 2) + if (GETBIT(array, iNumber)) + countOfPrimes++; + + printf("[END: Count = %ld]\r\n", countOfPrimes); + + free(array); + return 1; +} From 46541237e0d238ad635a53b09f39764c3b4fd173 Mon Sep 17 00:00:00 2001 From: David W Plummer Date: Mon, 6 Jun 2022 15:17:19 -0700 Subject: [PATCH 004/784] Add to contributor list for KIM-1 target --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e917a13e0..f011af83c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ External contributors: * [karrika](https://github.com/karrika): Atari 7800 target * [Stephan Mühlstrasser](https://github.com/smuehlst): osic1p target * [Wayne Parham](https://github.com/WayneParham): Sym-1 target +* [Dave Plummeer](https://github.com/davepl): KIM-1 target *(The above list is incomplete, if you feel left out - please speak up or add yourself in a PR)* From db44d59f7c99e602ff9619893bcaa6c0f319c216 Mon Sep 17 00:00:00 2001 From: David W Plummer Date: Mon, 6 Jun 2022 15:17:39 -0700 Subject: [PATCH 005/784] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f011af83c..287520320 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ External contributors: * [karrika](https://github.com/karrika): Atari 7800 target * [Stephan Mühlstrasser](https://github.com/smuehlst): osic1p target * [Wayne Parham](https://github.com/WayneParham): Sym-1 target -* [Dave Plummeer](https://github.com/davepl): KIM-1 target +* [Dave Plummer](https://github.com/davepl): KIM-1 target *(The above list is incomplete, if you feel left out - please speak up or add yourself in a PR)* From 27bfc8e35fa02be1f8cb347e2f6830c825fb1d3c Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Sun, 4 Apr 2021 03:13:45 +0200 Subject: [PATCH 006/784] Update README.md Commander X16 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 33c7d2830..b4d098dd3 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,10 @@ including - the Lynx console. - the Ohio Scientific Challenger 1P. - the Commander X16. +<<<<<<< HEAD - the Synertek Systems Sym-1. +======= +>>>>>>> 2583dfb71 (Update README.md) The libraries are fairly portable, so creating a version for other 6502s shouldn't be too much work. From 6c1c260e7b04a7d4388abf9002285af000a3ee91 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Thu, 9 Sep 2021 11:05:39 +0200 Subject: [PATCH 007/784] Create c-cpp.yml --- .github/workflows/c-cpp.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/c-cpp.yml diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml new file mode 100644 index 000000000..e3233268f --- /dev/null +++ b/.github/workflows/c-cpp.yml @@ -0,0 +1,23 @@ +name: C/C++ CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: configure + run: ./configure + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck From 687c8052aea79dae81cc0a7d90e0a7e2c0fddf53 Mon Sep 17 00:00:00 2001 From: polluks Date: Thu, 30 Dec 2021 00:04:57 +0100 Subject: [PATCH 008/784] Save a few bytes --- libsrc/cbm/read.s | 2 +- libsrc/cbm/write.s | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/cbm/read.s b/libsrc/cbm/read.s index fb0bb3171..71ba5d713 100644 --- a/libsrc/cbm/read.s +++ b/libsrc/cbm/read.s @@ -135,7 +135,7 @@ eof: lda #0 devnotpresent: lda #ENODEV - jmp __directerrno ; Sets _errno, clears _oserror, returns -1 + .byte $2C ; Skip next opcode ; Error entry: The given file descriptor is not valid or not open diff --git a/libsrc/cbm/write.s b/libsrc/cbm/write.s index ebc44a0ac..04010f2e4 100644 --- a/libsrc/cbm/write.s +++ b/libsrc/cbm/write.s @@ -106,7 +106,7 @@ devnotpresent2: pla devnotpresent: lda #ENODEV - jmp __directerrno ; Sets _errno, clears _oserror, returns -1 + .byte $2C ; Skip next opcode ; Error entry: The given file descriptor is not valid or not open From 919645f2832ef9e3875f91584fabf54ded746d18 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 12 Dec 2021 23:41:19 +0100 Subject: [PATCH 009/784] Updated URL and improved consistency. --- doc/apple2.sgml | 4 ++-- doc/apple2enh.sgml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index bd01b68dc..cf83dacc9 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -33,7 +33,7 @@ more information. The standard binary file format generated by the linker for the Apple ][ target is an file. +url="https://nulib.com/library/AppleSingle_AppleDouble.pdf"> file. The default load address is $803. , but uses the heap either explicitly or implicitly (i.e. by loading a driver) then -the memory from $800 to $2000 can be added to the heap by calling +the memory from $800 to $1FFF can be added to the heap by calling file. +url="https://nulib.com/library/AppleSingle_AppleDouble.pdf"> file. The default load address is $803. , but uses the heap either explicitly or implicitly (i.e. by loading a driver) then -the memory from $800 to $2000 can be added to the heap by calling +the memory from $800 to $1FFF can be added to the heap by calling Date: Sun, 12 Dec 2021 12:27:55 -0500 Subject: [PATCH 010/784] Changed a big script into separate named steps. It makes the job log easier to navigate. Also, Pull Requests don't need a Zip file. --- .github/workflows/build-on-pull-request.yml | 37 ++++++++------ .github/workflows/snapshot-on-push-master.yml | 48 ++++++++++++------- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index 53f79fef4..da9216a3d 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -1,6 +1,6 @@ name: Build Pull Request on: [pull_request] -concurrency: +concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -8,11 +8,11 @@ jobs: build_linux: name: Build and Test (Linux) runs-on: ubuntu-latest - + steps: - shell: bash run: git config --global core.autocrlf input - + - name: Checkout Source uses: actions/checkout@v2 @@ -21,28 +21,35 @@ jobs: run: | sudo apt-get update sudo apt-get install linuxdoc-tools linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass - - - name: Build - id: build + + - name: Build the tools. shell: bash + run: make -j2 bin USER_CFLAGS=-Werror + - name: Build the platform libraries. + shell: bash + run: make -j2 lib QUIET=1 + - name: Run the regression tests. + shell: bash + run: make test QUIET=1 + - name: Test that the samples can be built. + shell: bash + run: make -j2 samples + - name: Build the document files. + shell: bash + run: make -j2 doc + - name: Build 32-bit Windows versions of the tools. run: | - make -j2 bin USER_CFLAGS=-Werror - make -j2 lib QUIET=1 - make test QUIET=1 - make -j2 samples make -C src clean make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32- - make -C samples clean - make -j2 doc zip build_windows: name: Build (Windows) runs-on: windows-latest - + steps: - shell: bash run: git config --global core.autocrlf input - + - name: Checkout Source uses: actions/checkout@v2 @@ -51,6 +58,6 @@ jobs: - name: Build app (debug) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug - + - name: Build app (release) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index aefc7f2f5..e10904357 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -1,9 +1,9 @@ -name: Snapshot Build +name: Snapshot Build on: push: branches: master -concurrency: +concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -11,11 +11,11 @@ jobs: build_windows: name: Build (Windows) runs-on: windows-latest - + steps: - shell: bash run: git config --global core.autocrlf input - + - name: Checkout Source uses: actions/checkout@v2 @@ -24,7 +24,7 @@ jobs: - name: Build app (debug) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug - + - name: Build app (release) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release @@ -32,11 +32,11 @@ jobs: name: Build, Test and Snaphot (Linux) runs-on: ubuntu-latest needs: build_windows - + steps: - shell: bash run: git config --global core.autocrlf input - + - name: Checkout Source uses: actions/checkout@v2 @@ -45,25 +45,37 @@ jobs: run: | sudo apt-get update sudo apt-get install linuxdoc-tools linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass - - - name: Build - id: build + + - name: Build the tools. shell: bash + run: make -j2 bin USER_CFLAGS=-Werror + - name: Build the platform libraries. + shell: bash + run: make -j2 lib QUIET=1 + - name: Run the regression tests. + shell: bash + run: make test QUIET=1 + - name: Test that the samples can be built. + shell: bash + run: make -j2 samples + - name: Remove the output from the samples tests. + shell: bash + run: make -C samples clean + - name: Build the document files. + shell: bash + run: make -j2 doc + - name: Build and package 32-bit Windows versions of the tools. run: | - make -j2 bin USER_CFLAGS=-Werror - make -j2 lib QUIET=1 - make test QUIET=1 - make -j2 samples make -C src clean make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32- - make -C samples clean - make -j2 doc zip - + make zip + mv cc65.zip cc65-win32.zip + - name: Upload Snapshot Zip uses: actions/upload-artifact@v2 with: name: cc65-snapshot-win32.zip - path: cc65.zip + path: cc65-win32.zip # TODO: Update docs at https://github.com/cc65/doc # TODO: Publish snapshot zip at https://github.com/cc65/cc65.github.io From 32253a4e519de76bf068e465878f4b091a302538 Mon Sep 17 00:00:00 2001 From: Greg King Date: Sun, 12 Dec 2021 12:35:27 -0500 Subject: [PATCH 011/784] Removed unneeded package names. sshpass isn't needed because the Windows packages are put on Github. linuxdoc-tools is a dependency of linuxdoc-tools-info. The binutils package is a dependency of the gcc package. --- .github/workflows/build-on-pull-request.yml | 2 +- .github/workflows/snapshot-on-push-master.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index da9216a3d..c3214c308 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -20,7 +20,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get install linuxdoc-tools linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass + sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-i686 - name: Build the tools. shell: bash diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index e10904357..3f138e492 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -44,7 +44,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get install linuxdoc-tools linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass + sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-i686 - name: Build the tools. shell: bash From c143dd1f414e0c62c73a70f0183d366c5f98bbba Mon Sep 17 00:00:00 2001 From: Greg King Date: Sun, 12 Dec 2021 13:42:25 -0500 Subject: [PATCH 012/784] Added a 64-bit Windows cross-compile. That compiler catches pointer-integer width mismatches that other compilers ignore. --- .github/workflows/build-on-pull-request.yml | 6 +++--- .github/workflows/snapshot-on-push-master.yml | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index c3214c308..fe99c4673 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -20,7 +20,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-i686 + sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-x86-64 - name: Build the tools. shell: bash @@ -37,10 +37,10 @@ jobs: - name: Build the document files. shell: bash run: make -j2 doc - - name: Build 32-bit Windows versions of the tools. + - name: Build 64-bit Windows versions of the tools. run: | make -C src clean - make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32- + make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=x86_64-w64-mingw32- build_windows: name: Build (Windows) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 3f138e492..c8d36488d 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -44,7 +44,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-i686 + sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 - name: Build the tools. shell: bash @@ -64,6 +64,12 @@ jobs: - name: Build the document files. shell: bash run: make -j2 doc + - name: Build and package 64-bit Windows versions of the tools. + run: | + make -C src clean + make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=x86_64-w64-mingw32- + make zip + mv cc65.zip cc65-win64.zip - name: Build and package 32-bit Windows versions of the tools. run: | make -C src clean @@ -71,11 +77,16 @@ jobs: make zip mv cc65.zip cc65-win32.zip - - name: Upload Snapshot Zip + - name: Upload a 32-bit Snapshot Zip uses: actions/upload-artifact@v2 with: name: cc65-snapshot-win32.zip path: cc65-win32.zip + - name: Upload a 64-bit Snapshot Zip + uses: actions/upload-artifact@v2 + with: + name: cc65-snapshot-win64.zip + path: cc65-win64.zip # TODO: Update docs at https://github.com/cc65/doc # TODO: Publish snapshot zip at https://github.com/cc65/cc65.github.io From 81930053dd2e4aaee3f832597a03088b0acef1d4 Mon Sep 17 00:00:00 2001 From: Greg King Date: Sun, 12 Dec 2021 17:36:03 -0500 Subject: [PATCH 013/784] Used (size_t), instead of (long) where converting between pointers and integers. (long) still is 32 bits on 64-bit Windows! --- src/cc65/locals.c | 2 +- src/cc65/symentry.h | 2 +- src/cc65/symtab.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc65/locals.c b/src/cc65/locals.c index c2e314485..d3902f329 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -286,7 +286,7 @@ static void ParseAutoDecl (Declaration* Decl) ** We abuse the Collection somewhat by using it to store line ** numbers. */ - CollReplace (&CurrentFunc->LocalsBlockStack, (void *)(long)GetCurrentLine (), + CollReplace (&CurrentFunc->LocalsBlockStack, (void *)(size_t)GetCurrentLine (), CollCount (&CurrentFunc->LocalsBlockStack) - 1); } else { diff --git a/src/cc65/symentry.h b/src/cc65/symentry.h index bb87c7472..bcf586510 100644 --- a/src/cc65/symentry.h +++ b/src/cc65/symentry.h @@ -115,7 +115,7 @@ struct CodeEntry; typedef struct DefOrRef DefOrRef; struct DefOrRef { unsigned Line; - long LocalsBlockId; + size_t LocalsBlockId; unsigned Flags; int StackPtr; unsigned Depth; diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 5d7bd1436..3de0bb460 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -951,7 +951,7 @@ DefOrRef* AddDefOrRef (SymEntry* E, unsigned Flags) DOR = xmalloc (sizeof (DefOrRef)); CollAppend (E->V.L.DefsOrRefs, DOR); DOR->Line = GetCurrentLine (); - DOR->LocalsBlockId = (long)CollLast (&CurrentFunc->LocalsBlockStack); + DOR->LocalsBlockId = (size_t)CollLast (&CurrentFunc->LocalsBlockStack); DOR->Flags = Flags; DOR->StackPtr = StackPtr; DOR->Depth = CollCount (&CurrentFunc->LocalsBlockStack); @@ -1013,9 +1013,9 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags) /* Are we jumping into a block with initalization of an object that ** has automatic storage duration? Let's emit a warning. */ - if ((long)CollLast (AIC) != DOR->LocalsBlockId && + if ((size_t)CollLast (AIC) != DOR->LocalsBlockId && (CollCount (AIC) < DOR->Depth || - (long)CollAt (AIC, DOR->Depth - 1) != DOR->LocalsBlockId)) { + (size_t)CollAt (AIC, DOR->Depth - 1) != DOR->LocalsBlockId)) { Warning ("Goto at line %d to label %s jumps into a block with " "initialization of an object that has automatic storage duration", GetCurrentLine (), Name); @@ -1044,9 +1044,9 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags) /* Are we jumping into a block with initalization of an object that ** has automatic storage duration? Let's emit a warning. */ - if ((long)CollLast (AIC) != DOR->LocalsBlockId && + if ((size_t)CollLast (AIC) != DOR->LocalsBlockId && (CollCount (AIC) >= DOR->Depth || - (long)CollLast (AIC) >= (long)DOR->Line)) + (size_t)CollLast (AIC) >= (size_t)DOR->Line)) Warning ("Goto at line %d to label %s jumps into a block with " "initialization of an object that has automatic storage duration", DOR->Line, Name); From dd27a66a7bb0abd0111fec92d7b859e9dd69b024 Mon Sep 17 00:00:00 2001 From: Greg King Date: Sun, 12 Dec 2021 23:54:17 -0500 Subject: [PATCH 014/784] Install system packages before checking out the repo. --- .github/workflows/build-on-pull-request.yml | 11 +++++------ .github/workflows/snapshot-on-push-master.yml | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index fe99c4673..f5477d191 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -10,18 +10,17 @@ jobs: runs-on: ubuntu-latest steps: - - shell: bash - run: git config --global core.autocrlf input - - - name: Checkout Source - uses: actions/checkout@v2 - - name: Install Dependencies shell: bash run: | sudo apt-get update sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-x86-64 + - shell: bash + run: git config --global core.autocrlf input + - name: Checkout Source + uses: actions/checkout@v2 + - name: Build the tools. shell: bash run: make -j2 bin USER_CFLAGS=-Werror diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index c8d36488d..110edbbf0 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -34,18 +34,17 @@ jobs: needs: build_windows steps: - - shell: bash - run: git config --global core.autocrlf input - - - name: Checkout Source - uses: actions/checkout@v2 - - name: Install Dependencies shell: bash run: | sudo apt-get update sudo apt-get install linuxdoc-tools-info gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 + - shell: bash + run: git config --global core.autocrlf input + - name: Checkout Source + uses: actions/checkout@v2 + - name: Build the tools. shell: bash run: make -j2 bin USER_CFLAGS=-Werror From 5afc349199f6175af63a6e1b0468cd6438c11a4b Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Mon, 13 Dec 2021 17:14:57 +0100 Subject: [PATCH 015/784] Fixed typo --- src/ld65/scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index 256d47f07..718951aa5 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -196,7 +196,7 @@ static void StrVal (void) default: CfgWarning (&CfgErrorPos, - "Unkown escape sequence '%%%c'", C); + "Unknown escape sequence '%%%c'", C); SB_AppendChar (&CfgSVal, '%'); SB_AppendChar (&CfgSVal, C); NextChar (); From 7a0a0edb89ea7396304a1036dffee6b931bcbfee Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Mon, 13 Dec 2021 17:20:56 +0100 Subject: [PATCH 016/784] Fixed many typos --- src/dbginfo/dbginfo.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/dbginfo/dbginfo.c b/src/dbginfo/dbginfo.c index 42001ed07..fdebe6910 100644 --- a/src/dbginfo/dbginfo.c +++ b/src/dbginfo/dbginfo.c @@ -183,7 +183,7 @@ typedef struct DbgInfo DbgInfo; struct DbgInfo { /* First we have all items in collections sorted by id. The ids are - ** continous, so an access by id is almost as cheap as an array access. + ** continuous, so an access by id is almost as cheap as an array access. ** The collections are also used when the objects are deleted, so they're ** actually the ones that "own" the items. */ @@ -680,7 +680,7 @@ static char* SB_StrDup (const StrBuf* B) static Collection* CollInit (Collection* C) /* Initialize a collection and return it. */ { - /* Intialize the fields. */ + /* Initialize the fields. */ C->Count = 0; C->Size = 0; C->Items = 0; @@ -1349,7 +1349,7 @@ static int CompareFileInfoByName (const void* L, const void* R) static LibInfo* NewLibInfo (const StrBuf* Name) -/* Create a new LibInfo struct, intialize and return it */ +/* Create a new LibInfo struct, initialize and return it */ { /* Allocate memory */ LibInfo* L = xmalloc (sizeof (LibInfo) + SB_GetLen (Name)); @@ -1463,7 +1463,7 @@ static int CompareLineInfoByLine (const void* L, const void* R) static ModInfo* NewModInfo (const StrBuf* Name) -/* Create a new ModInfo struct, intialize and return it */ +/* Create a new ModInfo struct, initialize and return it */ { /* Allocate memory */ ModInfo* M = xmalloc (sizeof (ModInfo) + SB_GetLen (Name)); @@ -1536,7 +1536,7 @@ static int CompareModInfoByName (const void* L, const void* R) static ScopeInfo* NewScopeInfo (const StrBuf* Name) -/* Create a new ScopeInfo struct, intialize and return it */ +/* Create a new ScopeInfo struct, initialize and return it */ { /* Allocate memory */ ScopeInfo* S = xmalloc (sizeof (ScopeInfo) + SB_GetLen (Name)); @@ -1697,7 +1697,7 @@ static int CompareSegInfoByName (const void* L, const void* R) static SpanInfo* NewSpanInfo (void) -/* Create a new SpanInfo struct, intialize and return it */ +/* Create a new SpanInfo struct, initialize and return it */ { /* Allocate memory */ SpanInfo* S = xmalloc (sizeof (SpanInfo)); @@ -1779,7 +1779,7 @@ static int CompareSpanInfoByAddr (const void* L, const void* R) static SymInfo* NewSymInfo (const StrBuf* Name) -/* Create a new SymInfo struct, intialize and return it */ +/* Create a new SymInfo struct, initialize and return it */ { /* Allocate memory */ SymInfo* S = xmalloc (sizeof (SymInfo) + SB_GetLen (Name)); @@ -2147,7 +2147,7 @@ static TypeInfo* ParseTypeString (InputData* D, StrBuf* Type) I += GT_GET_SIZE (A[I]) + 1; } else { /* Unknown type in type string */ - ParseError (D, CC65_ERROR, "Unkown type in type value"); + ParseError (D, CC65_ERROR, "Unknown type in type value"); return 0; } break; @@ -2733,7 +2733,7 @@ static int StrConstFollows (InputData* D) static int Consume (InputData* D, Token Tok, const char* Name) -/* Check for a token and consume it. Return true if the token was comsumed, +/* Check for a token and consume it. Return true if the token was consumed, ** return false otherwise. */ { @@ -6936,7 +6936,7 @@ const cc65_scopeinfo* cc65_scope_byspan (cc65_dbginfo Handle, unsigned SpanId) const cc65_scopeinfo* cc65_childscopes_byid (cc65_dbginfo Handle, unsigned Id) /* Return the direct child scopes of a scope with a given id. The function ** returns NULL if no scope with this id was found, otherwise a list of the -** direct childs. +** direct children. */ { const DbgInfo* Info; From a08f9e51a0ca78eff4037c09f05a04695872f000 Mon Sep 17 00:00:00 2001 From: polluks2 Date: Tue, 14 Dec 2021 13:13:16 +0100 Subject: [PATCH 017/784] Fixed many typos --- doc/apple2.sgml | 2 +- doc/apple2enh.sgml | 2 +- doc/atari.sgml | 12 ++++++------ doc/atari5200.sgml | 2 +- doc/ca65.sgml | 2 +- doc/cc65.sgml | 6 +++--- doc/cl65.sgml | 4 ++-- doc/co65.sgml | 4 ++-- doc/coding.sgml | 2 +- doc/da65.sgml | 2 +- doc/debugging.sgml | 6 +++--- doc/geos.sgml | 4 ++-- doc/grc65.sgml | 6 +++--- doc/intro.sgml | 2 +- doc/ld65.sgml | 2 +- doc/smc.sgml | 4 ++-- 16 files changed, 31 insertions(+), 31 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index cf83dacc9..09052ade1 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -73,7 +73,7 @@ system takes care of actually moving the code into the Language Card. The amount of memory available in the Language Card for generated code depends on the parameters. There are -several usefull settings: +several useful settings: diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 8b61df91c..a105cb47a 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -73,7 +73,7 @@ system takes care of actually moving the code into the Language Card. The amount of memory available in the Language Card for generated code depends on the parameters. There are -several usefull settings: +several useful settings: diff --git a/doc/atari.sgml b/doc/atari.sgml index 903895d17..85dcaaf5e 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -131,7 +131,7 @@ With the default load address of $2400 this gives a usable memory range o [$2400-$CFFF]. Please note that the first load chunk (which checks the system -compatibilty and available memory) will always be loaded at +compatibility and available memory) will always be loaded at $2E00, regardless of the specified start address. This address can only be changed by a custom linker config file. @@ -305,7 +305,7 @@ The names are the usual ones you can find in system reference manuals. Example: ... -Please note that memory location 762/$2FA is called " -Please inspect the The old "HEADER" memory description contained six bytes: $FFFF -and the first and last memory addess of the program. For the "system -check" load chunk this had to be split into two memory assigments. The +and the first and last memory address of the program. For the "system +check" load chunk this had to be split into two memory assignments The "HEADER" now only contains the $FFFF. The main program's first and last memory address were moved to a new segment, called "MAINHDR", which in the new linker config file goes into its own memory area (also diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml index c7e5be73e..599ffe3c9 100644 --- a/doc/atari5200.sgml +++ b/doc/atari5200.sgml @@ -237,7 +237,7 @@ The runtime library provides a default game name which is "cc65 compiled". To change that, one has to link a file which puts data into the " .export __CART_NAME__: absolute = 1 .macpack atari diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 8ae8eabd9..0638ab08c 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -301,7 +301,7 @@ Here is a description of all the command line options: compiler, see there for a list. Depending on the target, the default CPU type is also set. This can be - overriden by using the / option. + overridden by using the / option.