This commit is contained in:
polluks 2021-12-30 00:42:29 +01:00
commit 1bcf93d010
57 changed files with 2002 additions and 88 deletions

View file

@ -0,0 +1,62 @@
name: Build Pull Request
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_linux:
name: Build and Test (Linux)
runs-on: ubuntu-latest
steps:
- 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
- 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 64-bit Windows versions of the tools.
run: |
make -C src clean
make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=x86_64-w64-mingw32-
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
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- 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

View file

@ -1,23 +0,0 @@
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

View file

@ -0,0 +1,91 @@
name: Snapshot Build
on:
push:
branches:
master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- 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
build_linux:
name: Build, Test and Snaphot (Linux)
runs-on: ubuntu-latest
needs: build_windows
steps:
- 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
- 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 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
make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
make zip
mv cc65.zip cc65-win32.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

View file

@ -4,7 +4,7 @@
[Wiki](https://github.com/cc65/wiki/wiki) [Wiki](https://github.com/cc65/wiki/wiki)
[![Build Status](https://app.travis-ci.com/cc65/cc65.svg?branch=master)](https://app.travis-ci.com/cc65/cc65) [![Snapshot Build](https://github.com/cc65/cc65/actions/workflows/snapshot-on-push-master.yml/badge.svg?branch=master)](https://github.com/cc65/cc65/actions/workflows/snapshot-on-push-master.yml)
cc65 is a complete cross development package for 65(C)02 systems, including cc65 is a complete cross development package for 65(C)02 systems, including
a powerful macro assembler, a C compiler, linker, librarian and several a powerful macro assembler, a C compiler, linker, librarian and several
@ -36,6 +36,7 @@ including
- the Lynx console. - the Lynx console.
- the Ohio Scientific Challenger 1P. - the Ohio Scientific Challenger 1P.
- the Commander X16. - the Commander X16.
- the Synertek Systems Sym-1.
The libraries are fairly portable, so creating a version for other 6502s The libraries are fairly portable, so creating a version for other 6502s
shouldn't be too much work. shouldn't be too much work.

View file

@ -77,6 +77,8 @@ VIC_SPR_EXP_Y := $D017
VIC_SPR_EXP_X := $D01D VIC_SPR_EXP_X := $D01D
VIC_SPR_MCOLOR := $D01C VIC_SPR_MCOLOR := $D01C
VIC_SPR_BG_PRIO := $D01B VIC_SPR_BG_PRIO := $D01B
VIC_SPR_COLL := $D01E
VIC_SPR_BG_COLL := $D01F
VIC_SPR_MCOLOR0 := $D025 VIC_SPR_MCOLOR0 := $D025
VIC_SPR_MCOLOR1 := $D026 VIC_SPR_MCOLOR1 := $D026

186
asminc/sym1.inc Normal file
View file

@ -0,0 +1,186 @@
; ---------------------------------------------------------------------------
;
; SYM-1 definitions
;
; ---------------------------------------------------------------------------
RAMSTART := $0200 ; Entry point
; ---------------------------------------------------------------------------
; Monitor Functions
; ---------------------------------------------------------------------------
WARM := $8003 ; Monitor entry
SVNMI := $809B ; Save NMI entry
INBYTE := $81D9 ; Get two HEX characters and pack
ASCNIB := $8275 ; Test for carriage-return
INCCMP := $82B2 ; Increment pointer
CHKSAD := $82DD ; Compute checksum
OUTPC := $82EE ; Display program counter
OUTBYT := $82FA ; Print byte as two ASCII characters
OUTS2 := $8319 ; Print pointer
INSTAT := $8386 ; Determine if key is pressed
GETKEY := $88AF ; Get key (disregarding monitor login)
SCAND := $8906 ; Flash LED display (once)
KEYQ := $8923 ; Test for keypress
BEEP := $8972 ; Make a beep
CONFIG := $89A5 ; Configure I/O
OUTDSP := $89C1 ; Output to on-board LED display
INCHR := $8A1B ; Input character and convert to uppercase
OUTCHR := $8A47 ; Output character
INTCHR := $8A58 ; Input character without case conversion
DLYF := $8AE6 ; Delay 1 bit time
DLYH := $8AE9 ; Delay 1/2 bit time
RESET := $8B4A ; Hard reset
ACCESS := $8B86 ; Unlock lowest 4K memory
NACCES := $8B9C ; Lock lowest 4K memory
L8C78 := $8C78 ; Link to tape
DUMPT := $8E87 ; Dump memory to tape
LOADT := $8C78 ; Load memory from tape
TAPEMODE := $00FD ; Top bit on for high-speed
; ---------------------------------------------------------------------------
; System Memory
; ---------------------------------------------------------------------------
DISBUF := $A640 ; On-Board Display Buffer
DISBUF0 := $A640 ; Left-Most digit
DISBUF1 := $A641 ; Second digit
DISBUF2 := $A642 ; Third
DISBUF3 := $A643 ; Fourth
DISBUF4 := $A644 ; Fifth
DISBUF5 := $A645 ; Sixth and right-most digit
DISBUF6 := $A646 ; Not-used / right of display (shift buffer)
RDIG := $A645 ; Right-most digit (same as DISBUF5)
P3L := $A64A ; Parameter 3 (low-byte)
P3H := $A64B ; (high-byte)
P2L := $A64C ; Parameter 2
P2H := $A64D ;
P1L := $A64E ; Parameter 1
P1H := $A64F
PARNR := $A649 ; Number of Parameters Entered
PADBIT := $A650 ; Pad Bits for Carriage Return
SDBYT := $A651 ; Baud Rate for RS232 (01-4800,06-2400,10-1200,24-600,4C-300,D5-110)
ERCNT := $A652 ; Error Count (Max FF)
TECHO := $A653 ; Terminal Echo (bit-7=ECHO/NO, 6=CTL-O TOGGLE)
TOUTFL := $A654 ; Output Flags (bit-7=CRT IN, 6=TTY IN, 5=TTY OUT, 4=CRT OUT)
KSHFL := $A655 ; Keyboard Shift Flag
TV := $A656 ; Trace Velocity (0=Single Step)
LSTCOM := $A657 ; Last Monitor Command
MAXRC := $A658 ; Maximum Record Length for Memory Dump
; ---------------------------------------------------------------------------
; Register Followers
; ---------------------------------------------------------------------------
PCLR := $A659 ; Program Counter (low-byte)
PCHR := $A65A ; (high-byte)
SR := $A65B ; Stack Pointer
FR := $A65C ; Status Register Flags
AR := $A65D ; A Register
XR := $A65E ; X Register
YR := $A65F ; Y Register
; ---------------------------------------------------------------------------
; I/O Vectors (3 bytes each)
; ---------------------------------------------------------------------------
INVEC := $A660 ; Input Character
OUTVEC := $A663 ; Output Character
INSVEC := $A666 ; Input Status
URSVEC := $A669 ; Unrecognized Syntax
URCVEC := $A66C ; Unrecognized Command / Error
SCNVEC := $A66F ; Scan On-board Display
; ---------------------------------------------------------------------------
; Trace and Interrupt Vectors (2 bytes each)
; ---------------------------------------------------------------------------
EXEVEC := $A672 ; Exec and Alternate InVec
TRCVEC := $A674 ; Trace
UBRKVC := $A676 ; User Break after Monitor
UIRQVC := $A678 ; User non-break IRQ after Monitor
NMIVEC := $A67A ; Non-Maskable Interrupt
RSTVEC := $A67C ; Reset
IRQVEC := $A67E ; Interrupt Request
; ---------------------------------------------------------------------------
; I/O Registers
; ---------------------------------------------------------------------------
;
; 6532 (U27)
;
PADA := $A400 ; Keyboard / Display
P3DA := $A402 ; Serial I/O
DDPADA := $A401 ; Data-Direction Register for PADA
DDP3DA := $A403 ; Data-Direction Register for P3DA
WEDRTA := $A404 ; Write-Edge Detect Read Timer A
WEDRFA := $A405 ; Write-Edge Detect Read-Int Flags A
WEDRTB := $A406 ; Write-Edge Detect Read Timer B
WEDRFB := $A407 ; Write-Edge Detect Read-Int Flags B
TIM0001 := $A41C ; Timer / 1
TIM0008 := $A41D ; Timer / 8
TIM0064 := $A41E ; Timer / 64
TIM1024 := $A41F ; Timer / 1024
;
; 6522 (U25)
;
OR1A := $A001 ; Input / Output Register for 1A
DDR1A := $A003 ; Data-Direction Register for 1A
OR1B := $A000 ; Input / Output Register for 1B
DDR1B := $A002 ; Data-Direction Register for 1B
TIC1L := $A004 ;
TIC1H := $A005 ;
TIL1L := $A006 ;
TIL1H := $A007 ;
T2L1L := $A008 ;
T2C1L := $A008 ;
T2C1H := $A009 ;
SR1 := $A00A ;
ACR1 := $A00B ;
PCR1 := $A00C ;
IFR1 := $A00D ;
IER1 := $A00E ;
DR1A := $A00F ;
;
; 6522 (U28)
;
OR2A := $A801 ; Input / Output Register for 2A
DDR2A := $A803 ; Data-Direction Register for 2A
OR2B := $A800 ; Input / Output Register for 2B
DDR2B := $A802 ; Data-Direction Register for 2B
TIC2L := $A804 ;
TIC2H := $A805 ;
TIL2L := $A806 ;
TIL2H := $A807 ;
T2L2L := $A808 ;
T2C2L := $A808 ;
T2C2H := $A809 ;
SR2 := $A80A ;
ACR2 := $A80B ;
PCR2 := $A80C ;
IFR2 := $A80D ;
IER2 := $A80E ;
DR2A := $A80F ;
;
; 6522 (U29)
;
OR3A := $AC01 ; Write-Protect RAM, Debug On/Off, I/O-3A
DDR3A := $AC03 ; Data-Direction Register for 3A
OR3B := $AC00 ; Input / Output Register for 3B
DDR3B := $AC02 ; Data-Direction Register for 3B
TIC3L := $AC04 ;
TIC3H := $AC05 ;
TIL3L := $AC06 ;
TIL3H := $AC07 ;
T2L3L := $AC08 ;
T2C3L := $AC08 ;
T2C3H := $AC09 ;
SR3 := $AC0A ;
ACR3 := $AC0B ;
PCR3 := $AC0C ;
IFR3 := $AC0D ;
IER3 := $AC0E ;
DR3A := $AC0F ;

20
cfg/c128-asm.cfg Normal file
View file

@ -0,0 +1,20 @@
FEATURES {
STARTADDRESS: default = $1c01;
}
SYMBOLS {
__LOADADDR__: type = import;
}
MEMORY {
ZP: file = "", start = $0002, size = $00FE, define = yes;
LOADADDR: file = %O, start = %S - 2, size = $0002;
MAIN: file = %O, start = %S, size = $D000 - %S;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
}

46
cfg/sym1-32k.cfg Normal file
View file

@ -0,0 +1,46 @@
# sym1-32k.cfg (32k)
#
# for Sym-1 with 32kb RAM
#
# ld65 --config sym1-32k.cfg -o <prog>.bin <prog>.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 = $0200; # 512 byte program stack
__STARTADDRESS__: type = export, value = %S;
}
MEMORY {
ZP: file = %O, define = yes, start = $0000, size = $00F7;
CPUSTACK: file = "", define = yes, start = $0100, size = $0100;
RAM: file = %O, define = yes, start = %S, size = $8000 - %S - __STACKSIZE__;
MONROM: file = "", define = yes, start = $8000, size = $1000;
EXT: file = "", define = yes, start = $9000, size = $1000;
IO: file = "", define = yes, start = $A000, size = $1000;
RAE1: file = "", define = yes, start = $B000, size = $1000;
BASROM: file = "", define = yes, start = $C000, size = $1000;
RAE2: 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;
}

46
cfg/sym1-4k.cfg Normal file
View file

@ -0,0 +1,46 @@
# sym1-4k.cfg (4k)
#
# for Sym-1 with 4kb RAM
#
# ld65 --config sym1-4k.cfg -o <prog>.bin <prog>.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 = $00F7;
CPUSTACK: file = "", define = yes, start = $0100, size = $0100;
RAM: file = %O, define = yes, start = %S, size = $1000 - %S - __STACKSIZE__;
MONROM: file = "", define = yes, start = $8000, size = $1000;
EXT: file = "", define = yes, start = $9000, size = $1000;
IO: file = "", define = yes, start = $A000, size = $1000;
RAE1: file = "", define = yes, start = $B000, size = $1000;
BASROM: file = "", define = yes, start = $C000, size = $1000;
RAE2: 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;
}

46
cfg/sym1.cfg Normal file
View file

@ -0,0 +1,46 @@
# sym1-4k.cfg (4k)
#
# for Sym-1 with 4kb RAM
#
# ld65 --config sym1-4k.cfg -o <prog>.bin <prog>.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 = $00F7;
CPUSTACK: file = "", define = yes, start = $0100, size = $0100;
RAM: file = %O, define = yes, start = %S, size = $1000 - %S - __STACKSIZE__;
MONROM: file = "", define = yes, start = $8000, size = $1000;
EXT: file = "", define = yes, start = $9000, size = $1000;
IO: file = "", define = yes, start = $A000, size = $1000;
RAE1: file = "", define = yes, start = $B000, size = $1000;
BASROM: file = "", define = yes, start = $C000, size = $1000;
RAE2: 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;
}

19
cfg/vic20-asm.cfg Normal file
View file

@ -0,0 +1,19 @@
FEATURES {
STARTADDRESS: default = $1001;
}
SYMBOLS {
__LOADADDR__: type = import;
}
MEMORY {
ZP: file = "", start = $0002, size = $001A, define = yes;
LOADADDR: file = %O, start = $1001, size = $0002;
MAIN: file = %O, start = %S, size = $0DF3 - %S;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
}

View file

@ -33,7 +33,7 @@ more information.
The standard binary file format generated by the linker for the The standard binary file format generated by the linker for the
Apple&nbsp;&rsqb;&lsqb; target is an <url name="AppleSingle" Apple&nbsp;&rsqb;&lsqb; target is an <url name="AppleSingle"
url="http://kaiser-edv.de/documents/AppleSingle_AppleDouble.pdf"> file. url="https://nulib.com/library/AppleSingle_AppleDouble.pdf"> file.
The default load address is &dollar;803. The default load address is &dollar;803.
<bf/AppleCommander 1.4.0/ or later (available at <url <bf/AppleCommander 1.4.0/ or later (available at <url
@ -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 The amount of memory available in the Language Card for generated code depends
on the <ref id="link-configs" name="linker configuration"> parameters. There are on the <ref id="link-configs" name="linker configuration"> parameters. There are
several usefull settings: several useful settings:
<descrip> <descrip>
@ -281,7 +281,7 @@ AppleCommander option to put LOADER.SYSTEM on a ProDOS 8 disk image is <tt/-p/.
If the cc65 program can be successfully linked as system program using the linker If the cc65 program can be successfully linked as system program using the linker
configuration <ref id="apple-sys-cfg" name="apple2-system.cfg">, but configuration <ref id="apple-sys-cfg" name="apple2-system.cfg">, but
uses the heap either explicitly or implicitly (i.e. by loading a driver) then uses the heap either explicitly or implicitly (i.e. by loading a driver) then
the memory from &dollar;800 to &dollar;2000 can be added to the heap by calling the memory from &dollar;800 to &dollar;1FFF can be added to the heap by calling
<tt/_heapadd ((void *) 0x0800, 0x1800);/ at the beginning of <tt/main()/. <tt/_heapadd ((void *) 0x0800, 0x1800);/ at the beginning of <tt/main()/.

View file

@ -33,7 +33,7 @@ more information.
The standard binary file format generated by the linker for the The standard binary file format generated by the linker for the
enhanced&nbsp;Apple&nbsp;//e target is an <url name="AppleSingle" enhanced&nbsp;Apple&nbsp;//e target is an <url name="AppleSingle"
url="http://kaiser-edv.de/documents/AppleSingle_AppleDouble.pdf"> file. url="https://nulib.com/library/AppleSingle_AppleDouble.pdf"> file.
The default load address is &dollar;803. The default load address is &dollar;803.
<bf/AppleCommander 1.4.0/ or later (available at <url <bf/AppleCommander 1.4.0/ or later (available at <url
@ -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 The amount of memory available in the Language Card for generated code depends
on the <ref id="link-configs" name="linker configuration"> parameters. There are on the <ref id="link-configs" name="linker configuration"> parameters. There are
several usefull settings: several useful settings:
<descrip> <descrip>
@ -281,7 +281,7 @@ AppleCommander option to put LOADER.SYSTEM on a ProDOS 8 disk image is <tt/-p/.
If the cc65 program can be successfully linked as system program using the linker If the cc65 program can be successfully linked as system program using the linker
configuration <ref id="apple-sys-cfg" name="apple2enh-system.cfg">, but configuration <ref id="apple-sys-cfg" name="apple2enh-system.cfg">, but
uses the heap either explicitly or implicitly (i.e. by loading a driver) then uses the heap either explicitly or implicitly (i.e. by loading a driver) then
the memory from &dollar;800 to &dollar;2000 can be added to the heap by calling the memory from &dollar;800 to &dollar;1FFF can be added to the heap by calling
<tt/_heapadd ((void *) 0x0800, 0x1800);/ at the beginning of <tt/main()/. <tt/_heapadd ((void *) 0x0800, 0x1800);/ at the beginning of <tt/main()/.

View file

@ -131,7 +131,7 @@ With the default load address of &dollar;2400 this gives a usable memory range o
&lsqb;&dollar;2400-&dollar;CFFF&rsqb;. &lsqb;&dollar;2400-&dollar;CFFF&rsqb;.
Please note that the first load chunk (which checks the system 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
&dollar;2E00, regardless of the specified start address. This address &dollar;2E00, regardless of the specified start address. This address
can only be changed by a custom linker config file. 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:
... ...
</verb></tscreen> </verb></tscreen>
Please note that memory location 762/$2FA is called "<tt/char_/" while the orignal name "<tt/char/" conflicts with the C keyword. Please note that memory location 762/$2FA is called "<tt/char_/" while the original name "<tt/char/" conflicts with the C keyword.
If you like to use the OS names and locations for the original Atari 800 operating system, please "<tt/#define OSA/" before including the If you like to use the OS names and locations for the original Atari 800 operating system, please "<tt/#define OSA/" before including the
<tt/atari.h/ header file. <tt/atari.h/ header file.
@ -401,7 +401,7 @@ OS.sdlst = &amp;DisplayList;
... ...
</verb></tscreen> </verb></tscreen>
Please inspect the <tt/_antic.h/ header file to detemine the supported Please inspect the <tt/_antic.h/ header file to determine the supported
instruction names. Modifiers on instructions can be nested without need instruction names. Modifiers on instructions can be nested without need
for an order: for an order:
@ -410,7 +410,7 @@ for an order:
Please mind that ANTIC has memory alignment requirements for "player Please mind that ANTIC has memory alignment requirements for "player
missile graphics"-data, font data, display lists and screen memory. Creation missile graphics"-data, font data, display lists and screen memory. Creation
of a special linker configuration with appropriate aligned segments and of a special linker configuration with appropriate aligned segments and
switching to that segment in the c-code is usually neccessary. A more memory switching to that segment in the c-code is usually necessary. A more memory
hungry solution consists in using the "<tt/posix_memalign()/" function in hungry solution consists in using the "<tt/posix_memalign()/" function in
conjunction with copying your data to the allocated memory. conjunction with copying your data to the allocated memory.
@ -1141,8 +1141,8 @@ ld65: Error: Missing memory area assignment for segment 'MAINHDR'
</verb></tscreen> </verb></tscreen>
The old "HEADER" memory description contained six bytes: &dollar;FFFF The old "HEADER" memory description contained six bytes: &dollar;FFFF
and the first and last memory addess of the program. For the "system and the first and last memory address of the program. For the "system
check" load chunk this had to be split into two memory assigments. The check" load chunk this had to be split into two memory assignments The
"HEADER" now only contains the &dollar;FFFF. The main program's first "HEADER" now only contains the &dollar;FFFF. The main program's first
and last memory address were moved to a new segment, called "MAINHDR", 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 which in the new linker config file goes into its own memory area (also

View file

@ -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 compiled". To change that, one has to link a file which puts data into
the "<tt/CARTNAME/" segment. the "<tt/CARTNAME/" segment.
For reference, here's the default version used by the cc65 libary: For reference, here's the default version used by the cc65 library:
<tscreen><verb> <tscreen><verb>
.export __CART_NAME__: absolute = 1 .export __CART_NAME__: absolute = 1
.macpack atari .macpack atari

View file

@ -301,7 +301,7 @@ Here is a description of all the command line options:
compiler, see there for a list. compiler, see there for a list.
Depending on the target, the default CPU type is also set. This can be Depending on the target, the default CPU type is also set. This can be
overriden by using the <tt/<ref id="option--cpu" name="--cpu">/ option. overridden by using the <tt/<ref id="option--cpu" name="--cpu">/ option.
<label id="option-v"> <label id="option-v">
@ -4786,6 +4786,7 @@ compiler, depending on the target system selected:
<item><tt/__SIM6502__/ - Target system is <tt/sim6502/ <item><tt/__SIM6502__/ - Target system is <tt/sim6502/
<item><tt/__SIM65C02__/ - Target system is <tt/sim65c02/ <item><tt/__SIM65C02__/ - Target system is <tt/sim65c02/
<item><tt/__SUPERVISION__/ - Target system is <tt/supervision/ <item><tt/__SUPERVISION__/ - Target system is <tt/supervision/
<item><tt/__SYM1__/ - Target system is <tt/sym1/
<item><tt/__VIC20__/ - Target system is <tt/vic20/ <item><tt/__VIC20__/ - Target system is <tt/vic20/
</itemize> </itemize>

View file

@ -395,7 +395,7 @@ Here is a description of all the command line options:
This option is used to set the target system. The target system determines This option is used to set the target system. The target system determines
the character set that is used for strings and character constants and the the character set that is used for strings and character constants and the
default CPU. The CPU setting can be overriden by use of the <tt/<ref default CPU. The CPU setting can be overridden by use of the <tt/<ref
id="option--cpu" name="--cpu">/ option. id="option--cpu" name="--cpu">/ option.
The following target systems are supported: The following target systems are supported:
@ -1022,6 +1022,10 @@ The compiler defines several macros at startup:
This macro is defined if the target is the Supervision (-t supervision). This macro is defined if the target is the Supervision (-t supervision).
<tag><tt>__SYM1__</tt></tag>
This macro is defined if the target is the Sym-1 (-t sym1).
<tag><tt>__TELESTRAT__</tt></tag> <tag><tt>__TELESTRAT__</tt></tag>
This macro is defined if the target is the Telestrat (-t telestrat). This macro is defined if the target is the Telestrat (-t telestrat).
@ -1246,7 +1250,7 @@ parameter with the <tt/#pragma/.
This pragma is used to display informational messages at compile-time. This pragma is used to display informational messages at compile-time.
The message intented to be displayed must be a string literal. The message intended to be displayed must be a string literal.
Example: Example:
<tscreen><verb> <tscreen><verb>
@ -1365,7 +1369,7 @@ parameter with the <tt/#pragma/.
Switch compiler warnings on or off. "name" is the name of a warning (see the Switch compiler warnings on or off. "name" is the name of a warning (see the
<tt/<ref name="-W" id="option-W">/ compiler option for a list). The name is <tt/<ref name="-W" id="option-W">/ compiler option for a list). The name is
followed either by "pop", which restores the last pushed state, or by "on" or followed either by "pop", which restores the last pushed state, or by "on" or
"off", optionally preceeded by "push" to push the current state before "off", optionally preceded by "push" to push the current state before
changing it. changing it.
Example: Example:

View file

@ -57,11 +57,11 @@ Short options:
-O Optimize code -O Optimize code
-Oi Optimize code, inline more code -Oi Optimize code, inline more code
-Or Optimize code, honour the register keyword -Or Optimize code, honour the register keyword
-Os Optimize code, inline standard funtions -Os Optimize code, inline standard functions
-S Compile but don't assemble and link -S Compile but don't assemble and link
-T Include source as comment -T Include source as comment
-V Print the version number -V Print the version number
-W name[,...] Supress compiler warnings -W name[,...] Suppress compiler warnings
-Wa options Pass options to the assembler -Wa options Pass options to the assembler
-Wc options Pass options to the compiler -Wc options Pass options to the compiler
-Wl options Pass options to the linker -Wl options Pass options to the linker

View file

@ -235,12 +235,12 @@ things to be different from runtime loading:
<item> Without changing the segment names, all segments take the default <item> Without changing the segment names, all segments take the default
names used by the standard linker configurations. This means that the names used by the standard linker configurations. This means that the
driver code is no longer contingous in memory, instead the code driver code is no longer contiguous in memory, instead the code
segment is placed somewhere in between all other code segments, the segment is placed somewhere in between all other code segments, the
data segment is placed with all other data segments and so on. If the data segment is placed with all other data segments and so on. If the
driver doesn't do strange things this shouldn't be a problem. driver doesn't do strange things this shouldn't be a problem.
<item> With statically linked code, data and bss segments will get intialized <item> With statically linked code, data and bss segments will get initialized
once (when the application is loaded), while a loadable driver will once (when the application is loaded), while a loadable driver will
get its initialization each time the driver is loaded into memory get its initialization each time the driver is loaded into memory
(which may be more than once in the lifetime of a program). It depends (which may be more than once in the lifetime of a program). It depends

View file

@ -59,7 +59,7 @@ slower than the same code for unsigned types.
<sect>Use chars instead of ints if possible<p> <sect>Use chars instead of ints if possible<p>
While in arithmetic operations, chars are immidiately promoted to ints, they While in arithmetic operations, chars are immediately promoted to ints, they
are passed as chars in parameter lists and are accessed as chars in variables. are passed as chars in parameter lists and are accessed as chars in variables.
The code generated is usually not much smaller, but it is faster, since The code generated is usually not much smaller, but it is faster, since
accessing chars is faster. For several operations, the generated code may be accessing chars is faster. For several operations, the generated code may be

View file

@ -156,7 +156,7 @@ Here is a description of all the command line options:
<tag><tt>-i name, --info name</tt></tag> <tag><tt>-i name, --info name</tt></tag>
Specify an info file. The info file contains global options that may Specify an info file. The info file contains global options that may
override or replace command line options plus informations about the code override or replace command line options plus information about the code
that has to be disassembled. See the separate section <ref id="infofile" that has to be disassembled. See the separate section <ref id="infofile"
name="Info File Format">. name="Info File Format">.

View file

@ -39,7 +39,7 @@ transfer the program to the real machine until it is done.
<item>An emulator allows many things that are almost impossible one of the <item>An emulator allows many things that are almost impossible one of the
original machines. You may set watchpoints (detect read or write access to original machines. You may set watchpoints (detect read or write access to
arbitary addresses), debug interrupt handlers and even debug routines that run arbitrary addresses), debug interrupt handlers and even debug routines that run
inside the 1541 floppy. inside the 1541 floppy.
<item>You may use the label file generated by the linker to make much more use <item>You may use the label file generated by the linker to make much more use
@ -117,7 +117,7 @@ these warnings and errors as long as they reference any problems VICE thinks
it has with the labels. it has with the labels.
After loading the labels, they are used by VICE in the disassembler listing, After loading the labels, they are used by VICE in the disassembler listing,
and you may use them whereever you need to specify an address. Try and you may use them wherever you need to specify an address. Try
<tscreen><verb> <tscreen><verb>
d ._main d ._main
@ -138,7 +138,7 @@ load your label file like this:
</verb></tscreen> </verb></tscreen>
After loading the labels, they are used by Oricutron in the disassembler listing, After loading the labels, they are used by Oricutron in the disassembler listing,
and you may use them whereever you need to specify an address. Try and you may use them wherever you need to specify an address. Try
<tscreen><verb> <tscreen><verb>
d ._main d ._main

View file

@ -207,7 +207,7 @@ see them together in the filling box in GeoPaint.
<p> <p>
<tt/void GraphicsString (const void *myGString)/ <tt/void GraphicsString (const void *myGString)/
<p> <p>
One of the more powerfull routines of GEOS. This function calls other graphic functions depending One of the more powerful routines of GEOS. This function calls other graphic functions depending
on the given command string. See the structures chapter for a more detailed description. on the given command string. See the structures chapter for a more detailed description.
<sect2>Rectangle functions <sect2>Rectangle functions
@ -652,7 +652,7 @@ For some purposes you might consider using the <tt/dio.h/ interface to disk acce
<p> <p>
All GEOS disk functions return an error code in the X register. In some cases this is returned by the All GEOS disk functions return an error code in the X register. In some cases this is returned by the
GEOSLib function (if its type is <tt/char/), but in all cases the last error is saved in the <tt/__oserror/ GEOSLib function (if its type is <tt/char/), but in all cases the last error is saved in the <tt/__oserror/
location. If it is nonzero - an error occured. See <tt/gdisk.h/ for the list of possible errorcodes. location. If it is nonzero - an error occurred. See <tt/gdisk.h/ for the list of possible errorcodes.
You need to include <tt/errno.h/ to get <tt/__oserror/, together with the standard <tt/errno/. The You need to include <tt/errno.h/ to get <tt/__oserror/, together with the standard <tt/errno/. The
latter gives less verbose, but still usable information and can be used with <tt/strerror/. latter gives less verbose, but still usable information and can be used with <tt/strerror/.
Probably you will get more information using <tt/_stroserror/ in a similar way. Probably you will get more information using <tt/_stroserror/ in a similar way.

View file

@ -7,7 +7,7 @@
<url url="mailto:greg.king5@verizon.net" name="Greg King"> <url url="mailto:greg.king5@verizon.net" name="Greg King">
<abstract> <abstract>
This document describes a compiler that can create GEOS headers and menues for This document describes a compiler that can create GEOS headers and menus for
cc65-compiled programs. cc65-compiled programs.
</abstract> </abstract>
@ -24,7 +24,7 @@ Optional resources might be menu definitions, other headers (e.g., for data
files of an app.), dialog definitions, etc. Without an application's header, files of an app.), dialog definitions, etc. Without an application's header,
GEOS is unable to load and start it. GEOS is unable to load and start it.
Currently, <bf/grc65/ supports only menues and the required header definition, Currently, <bf/grc65/ supports only menus and the required header definition,
along with support for building applications with VLIR-structured overlays. along with support for building applications with VLIR-structured overlays.
<bf/grc65/ generates output in two formats: C header and <bf/ca65/ source (.s). <bf/grc65/ generates output in two formats: C header and <bf/ca65/ source (.s).
@ -345,7 +345,7 @@ for addresses.
<!-- <appendix> --> <!-- <appendix> -->
<sect>Appendix A -- example.grc<label id="example-grc"> <sect>Appendix A -- example.grc<label id="example-grc">
<p><tscreen><verb> <p><tscreen><verb>
; Note that MENU can define both menues and submenues. ; Note that MENU can define both menus and submenus.
; If you want to use any C operators (such as "|", "&", etc.), do it WITHOUT ; If you want to use any C operators (such as "|", "&", etc.), do it WITHOUT
; any spaces between the arguments (the parser is simple and weak). ; any spaces between the arguments (the parser is simple and weak).

View file

@ -172,6 +172,9 @@
<tag><htmlurl url="supervision.html" name="supervision.html"></tag> <tag><htmlurl url="supervision.html" name="supervision.html"></tag>
Topics specific to the Watara Supervision Console. Topics specific to the Watara Supervision Console.
<tag><htmlurl url="sym1.html" name="sym1.html"></tag>
Topics specific to the Synertek Systems Sym-1.
<tag><htmlurl url="telestrat.html" name="telestrat.html"></tag> <tag><htmlurl url="telestrat.html" name="telestrat.html"></tag>
Topics specific to the Oric Telestrat. Topics specific to the Oric Telestrat.

View file

@ -555,7 +555,7 @@ feature on.
</quote> </quote>
<quote> <quote>
In VICE, got to <bf/Settings/ -> <bf/Settings/, then <bf/Peripherial devices/ -> In VICE, got to <bf/Settings/ -> <bf/Settings/, then <bf/Peripheral devices/ ->
<bf/Drive/. Then, you must enable the <bf/True drive emulation/ checkbox. <bf/Drive/. Then, you must enable the <bf/True drive emulation/ checkbox.
</quote> </quote>

View file

@ -886,7 +886,7 @@ also for a segment. The value must be an integer between 0 and 255. It is used
as the fill value for space reserved by the assembler's <tt/.ALIGN/ and <tt/.RES/ as the fill value for space reserved by the assembler's <tt/.ALIGN/ and <tt/.RES/
commands. It is also used as the fill value for space between sections (part of a commands. It is also used as the fill value for space between sections (part of a
segment that comes from one object file) caused by alignment, but not for segment that comes from one object file) caused by alignment, but not for
space that preceeds the first section. space that precedes the first section.
To suppress the warning, the linker issues if it encounters a segment that is To suppress the warning, the linker issues if it encounters a segment that is
not found in any of the input files, use "<tt/optional=yes/" as an additional not found in any of the input files, use "<tt/optional=yes/" as an additional

View file

@ -59,6 +59,9 @@ Functions that are <em/not/ available:
Functions not available on all supported systems: Functions not available on all supported systems:
<itemize> <itemize>
<item><tt>clock</tt>: Support depends on the capabilities of the target
machine.
<p>
<item><tt>fopen/fread/fwrite/fclose/fputs/fgets/fscanf</tt>: The functions <item><tt>fopen/fread/fwrite/fclose/fputs/fgets/fscanf</tt>: The functions
are built on open/read/write/close. Those latter functions are not available are built on open/read/write/close. Those latter functions are not available
on all systems. on all systems.

View file

@ -85,7 +85,7 @@ Please note:
<item> The macro '<tt>SMC_StoreValue</tt>' takes care, that the store <item> The macro '<tt>SMC_StoreValue</tt>' takes care, that the store
operation will occur on the value-position of a SMC-instruction. As operation will occur on the value-position of a SMC-instruction. As
you will see, other macros influence other instruction part positions. you will see, other macros influence other instruction part positions.
There is no consistency check, if the targeted SMC instruction acually There is no consistency check, if the targeted SMC instruction actually
contains a value. Storing a 'value' on an immplied SMC instruction contains a value. Storing a 'value' on an immplied SMC instruction
would corrupt the following memory cell! would corrupt the following memory cell!
</enum> </enum>
@ -582,7 +582,7 @@ into a single instruction line. These can be changed of course too.
Line 10,11: These lines construct a branch operation for line 8: The Line 10,11: These lines construct a branch operation for line 8: The
X-register will be used to change it from 'inc StoreAccuFirstSection+2' X-register will be used to change it from 'inc StoreAccuFirstSection+2'
(high-byte operation) to 'beq restoreCode'. Please note: To calculate the (high-byte operation) to 'beq restoreCode'. Please note: To calculate the
relaive branch offset, we introduced a second label relative branch offset, we introduced a second label
('RestoreCodeBranchBaseAdr') for to calculate it. Some could also use the ('RestoreCodeBranchBaseAdr') for to calculate it. Some could also use the
internal name of the SMC label, but you should abstain to do so - it may be internal name of the SMC label, but you should abstain to do so - it may be
changed in the future... changed in the future...

132
doc/sym1.sgml Normal file
View file

@ -0,0 +1,132 @@
<!doctype linuxdoc system>
<article>
<title>Synertek Systems Sym-1 specific information for cc65
<author><url url="mailto:wayne@parhamdata.com" name="Wayne Parham">
<abstract>
An overview over the Sym-1 runtime system as it is implemented for the cc65 C compiler.
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin the document -->
<sect>Overview<p>
This file contains an overview of the Sym-1 runtime system as it comes with the cc65 C compiler. It describes the memory layout, Sym-1 specific header files, available drivers, and any pitfalls specific to the platform.
Please note that Sym-1 specific functions are just mentioned here, they are described in detail in the separate <url url="funcref.html" name="function reference">. Even functions marked as "platform dependent" may be available on more than one platform. Please see the function reference for more information.
<sect>Binary format<p>
The output format generated by the linker for the Sym-1 target is a raw binary BIN file, which is essentially a memory image. You can convert this to a HEX file using BIN2HEX, which is a popular open-source conversion utility program. A HEX file has ASCII representations of the hexadecimal byte values of the machine-language program. So the HEX file can be transferred to the Sym-1 using the RS-232 terminal port, just as if the machine-code was entered by hand. Enter 'm 200' in the monitor and start the HEX file transfer.
<p>
Included with this distribution is a 4k configuration file and a 32k config file. The Sym-1 on-board memory is limited to 4 kbytes but system memory can be increased to 32 kbytes of contiguous RAM with aftermarket add-on boards. So choose the config file that matches your system configuration before compiling and linking user programs.
<sect>Memory layout<p>
The ROMs and I/O areas are defined in the configuration files, as are most of the entry points for useful subroutines in the Sym-1 monitor ROM. cc65 generated programs compiled and linked using 4k config run in the memory range of &dollar;200 - &dollar;0FFF. The 32k config expands this range to &dollar;7FFF. The starting memory location and entry point for running the program is &dollar;200, so when the program is transferred to the Sym-1, it is executed by typing 'g 200'. The system returns control back to the monitor ROM when the program terminates, providing the '.' prompt.
Special locations:
<descrip>
<tag/Text screen/
Conio support is not currently available for the Sym-1. But stdio console functions are available.
<tag/Stack/
The C runtime stack is located at &dollar;0FFF on 4KB Syms, or at &dollar;7FFFfor 32KB systems. The stack always grows downwards.
<tag/Heap/
The C heap is located at the end of the program and grows towards the C runtime stack.
</descrip><p>
<sect>Platform specific header files<p>
Programs containing Sym-1 code may use the <tt/sym1.h/ header file. See the header file for more information.
<sect1>Hardware access<p>
The pseudo variables declared in the <tt/sym1.inc/ include file allow access to hardware located in the address space. See the include file for more information.
<sect>Loadable drivers<p>
<sect1>Graphics drivers<p>
No graphics drivers are currently available for the Sym-1.
<sect1>Extended memory drivers<p>
No extended memory drivers are currently available for the Sym-1.
<sect1>Joystick drivers<p>
No joystick driver is currently available for the Sym-1.
<sect1>Mouse drivers<p>
No mouse drivers are currently available for the Sym-1.
<sect1>RS232 device drivers<p>
No communication port drivers are currently available for the Sym-1. It has only the &quot;master console&quot; e.g. stdin and stdout.
<sect>Limitations<p>
<sect1>Disk I/O<p>
The existing library for the Sym-1 doesn't implement C file I/O.
To be more specific, this limitation means that you cannot use any of the following functions (and a few others):
<itemize>
<item>fopen
<item>fclose
<item>fread
<item>fwrite
<item>...
</itemize>
<sect>Other hints<p>
<sect1>sym1.h<p>
This header exposes Sym-specific I/O functions that are useful for reading and writing its ports and front panel. See the <tt/sym1.h/ include file for a list of the functions available.
<sect2>Limited memory applications<p>
As stated earlier, there are config files for 4KB and 32KB systems. If you have 32KB RAM, then you will probably want to use the sym1-32k configuration, but if not - if you are using the sym1-4k configuration - then you may want to use functions like getchar, putchar, gets and puts rather than functions like scanf and printf. Printf, for example, requires about 1KB because it needs to know how to process all the format specifiers.
<sect3>Sample programs<p>
All the samples will run on the &quot;stock&quot; 4KB Sym-1, except for symIO and symNotepad, which require 32KB. These sample programs can be found in the targettest/sym1 directory:
<itemize>
<item>symHello prints &quot;Hello World!&quot; and then inputs characters, which are echoed on the screen. It also makes a &quot;beep&quot; sound.</item>
<item>symTiny does the same as symHello, but does it with puts() rather than printf() to show the difference in compiled binary size.</item>
<item>symDisplay allows entry of a message, which is then displayed by scrolling it across the front panel display.</item>
<item>symIO allows access to the Sym-1 digital I/O ports.</item>
<item>symNotepad is a simple text entry/retrieval program that uses tape storage.</item>
</itemize>
<sect>License<p>
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:
<enum>
<item> 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.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
</enum>
</article>

165
include/sym1.h Normal file
View file

@ -0,0 +1,165 @@
/*****************************************************************************/
/* */
/* sym1.h */
/* */
/* Sym-1 system-specific definitions */
/* */
/* */
/* */
/* (C) 2020 Wayne Parham */
/* EMail: wayne@parhamdata.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 _SYM1_H
#define _SYM1_H
/* Check for errors */
#if !defined(__SYM1__)
# error This module may only be used when compiling for the Sym-1!
#endif
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Display character definitions */
#define DISP_1 0x06 // '1'
#define DISP_2 0x5B // '2'
#define DISP_3 0x4F // '3'
#define DISP_4 0x66 // '4'
#define DISP_5 0x6D // '5'
#define DISP_6 0x7C // '6'
#define DISP_7 0x07 // '7'
#define DISP_8 0x7F // '8'
#define DISP_9 0x67 // '9'
#define DISP_0 0x3F // '0'
#define DISP_A 0x77 // 'A'
#define DISP_b 0x7C // 'b'
#define DISP_C 0x39 // 'C'
#define DISP_c 0x58 // 'c'
#define DISP_d 0x5E // 'd'
#define DISP_E 0x79 // 'E'
#define DISP_e 0x7B // 'e'
#define DISP_F 0x71 // 'F'
#define DISP_G 0x7D // 'G'
#define DISP_g 0x6F // 'g'
#define DISP_H 0x76 // 'H'
#define DISP_h 0x74 // 'h'
#define DISP_I 0x06 // 'I'
#define DISP_i 0x04 // 'i'
#define DISP_J 0x1E // 'J'
#define DISP_K 0x74 // 'K'
#define DISP_L 0x38 // 'L'
#define DISP_M_1 0x33 // 'M'
#define DISP_M_2 0x27 // 2nd half
#define DISP_n 0x54 // 'n'
#define DISP_O 0x3F // 'O'
#define DISP_o 0x5C // 'o'
#define DISP_P 0x73 // 'P'
#define DISP_q 0x67 // 'q'
#define DISP_r 0x50 // 'r'
#define DISP_S 0x6D // 'S'
#define DISP_t 0x46 // 't'
#define DISP_U 0x3E // 'U'
#define DISP_u 0x1C // 'u'
#define DISP_V_1 0x64 // 'V'
#define DISP_V_2 0x52 // 2nd half
#define DISP_W_1 0x3C // 'W'
#define DISP_W_2 0x1E // 2nd half
#define DISP_Y 0x6E // 'Y'
#define DISP_Z 0x5B // 'Z'
#define DISP_SPACE 0x00 // ' '
#define DISP_PERIOD 0x80 // '.'
#define DISP_HYPHEN 0x40 // '-'
#define DISP_APOSTR 0x20 // '''
#define DISP_EQUAL 0x41 // '='
#define DISP_3_BAR 0x49 // '='
#define DISP_BOTTOM 0x08 // '_'
#define DISP_TOP 0x01 // Top segment
#define DISP_LEFT 0x30 // '|' Left side, both segments
#define DISP_RIGHT 0x06 // '|' Right side, both segments
#define DISP_DEGREE 0x63 // 'o' An 'o' character in the upper segments
#define DISP_HAT 0x23 // 'n' An 'n' character in the upper segments
#define DISP_FORK 0x62 // 'u' A 'u' character in the upper segments
#define DISP_SLASH 0x51 // '/'
#define DISP_BACKSLASH 0x34 // '\'
#define DISP_TOP_RIGHT 0x02 // Top right segment
#define DISP_TOP_LEFT 0x20 // Top left segment
#define DISP_LOW_RIGHT 0x04 // Lower right segment
#define DISP_LOW_LEFT 0x10 // Lower left segment
/*****************************************************************************/
/* Hardware */
/*****************************************************************************/
#include <_6522.h>
#define VIA1 (*(struct __6522*)0xA000) // U25
#define VIA2 (*(struct __6522*)0xA800) // U28
#define VIA3 (*(struct __6522*)0xAC00) // U29
struct _display {
unsigned char d0; // left-most seven-segment display
unsigned char d1; // second seven-segment display
unsigned char d2; // third seven-segment display
unsigned char d3; // fouth seven-segment display
unsigned char d4; // fifth seven-segment display
unsigned char d5; // sixth seven-segment display
unsigned char d6; // buffer byte to the right
};
#define DISPLAY (*(struct _display*)0xA640)
/*****************************************************************************/
/* Code */
/*****************************************************************************/
void beep (void);
/* Beep sound. */
void fdisp (void);
/* Flash display */
int __fastcall__ loadt (unsigned char);
/* Read from tape */
int __fastcall__ dumpt (unsigned char, const void*, const void*);
/* Write to tape */
/* End of sym1.h */
#endif

View file

@ -34,6 +34,7 @@ TARGETS = apple2 \
sim6502 \ sim6502 \
sim65c02 \ sim65c02 \
supervision \ supervision \
sym1 \
telestrat telestrat
DRVTYPES = emd \ DRVTYPES = emd \

View file

@ -93,9 +93,7 @@ joy1: lda #$7F
sta CIA1_PRA sta CIA1_PRA
lda CIA1_PRB lda CIA1_PRB
cli cli
and #$1F jmp end
eor #$1F
rts
; Read joystick 2 ; Read joystick 2
@ -107,8 +105,6 @@ joy2: ldx #0
lda CIA1_PRA lda CIA1_PRA
sty CIA1_DDRA sty CIA1_DDRA
cli cli
and #$1F end: and #$1F
eor #$1F eor #$1F
rts rts

View file

@ -75,7 +75,7 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
} }
/* Test alignment: is it a power of two? There must be only one bit set. */ /* Test alignment: is it a power of two? There must be only one bit set. */
if (alignment == 0 || (alignment & --alignment) != 0) { if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
*memptr = NULL; *memptr = NULL;
return EINVAL; return EINVAL;
} }
@ -86,7 +86,7 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
** overhead added one time; and, the worst thing that might happen is that ** overhead added one time; and, the worst thing that might happen is that
** we cannot free the upper and lower blocks. ** we cannot free the upper and lower blocks.
*/ */
b = malloc (size + alignment); b = malloc (--alignment + size);
/* Handle out-of-memory */ /* Handle out-of-memory */
if (b == NULL) { if (b == NULL) {
@ -169,6 +169,3 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
return EOK; return EOK;
} }

18
libsrc/sym1/beep.s Normal file
View file

@ -0,0 +1,18 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; void beep (void);
;
.include "sym1.inc"
.export _beep
.segment "CODE"
.proc _beep: near
jsr BEEP ; Beep
rts
.endproc

57
libsrc/sym1/crt0.s Normal file
View file

@ -0,0 +1,57 @@
;
; Startup code for cc65 (Sym-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 "sym1.inc"
; Place the startup code in a special segment
.segment "STARTUP"
; A little light housekeeping
_init: jsr ACCESS ; Unlock System RAM
cld ; Clear decimal mode
; Turn off console echo
lda TECHO
and #$7F
sta TECHO
; 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)
_exit: jsr donelib ; Run destructors
lda TECHO
ora #$80 ; Re-enable console echo
sta TECHO
jsr NACCES ; Lock System RAM
rts ; Re-enter Sym-1 monitor

5
libsrc/sym1/ctype.s Normal file
View file

@ -0,0 +1,5 @@
; Character specification table.
;
; uses the "common" definition
.include "ctype_common.inc"

18
libsrc/sym1/display.s Normal file
View file

@ -0,0 +1,18 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; void fdisp (void);
;
.include "sym1.inc"
.export _fdisp
.segment "CODE"
.proc _fdisp: near
jsr SCAND ; Flash Display
rts
.endproc

53
libsrc/sym1/read.s Normal file
View file

@ -0,0 +1,53 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; int __fastcall__ read (int fd, void* buf, unsigned count);
;
.include "sym1.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
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

46
libsrc/sym1/tapeio.s Normal file
View file

@ -0,0 +1,46 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; int __fastcall__ loadt (unsigned char id);
; int __fastcall__ dumpt (unsigned char id, void* start_addr, void* end_addr);
;
.include "sym1.inc"
.import popa, popax, return0, return1
.export _loadt, _dumpt
.segment "CODE"
.proc _loadt: near
sta P1L ; Tape record ID to P1L
ldx #$00
stx P1H
ldy #$80
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 P3L ; End address
stx P3H
jsr popax
sta P2L ; Start address
stx P2H
jsr popa
sta P1L ; Tape Record ID
ldx #$00
stx P1H
ldy #$80
jsr DUMPT ; Write data to tape
bcs error
jmp return0 ; Return 0 if sucessful
error: jmp return1 ; or 1 if not
.endproc

51
libsrc/sym1/write.s Normal file
View file

@ -0,0 +1,51 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; int __fastcall__ write (int fd, const void* buf, int count);
;
.include "sym1.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

View file

@ -301,6 +301,9 @@ EXELIST_sim65c02 = $(EXELIST_sim6502)
EXELIST_supervision = \ EXELIST_supervision = \
notavailable notavailable
EXELIST_sym1 = \
notavailable
EXELIST_telestrat = \ EXELIST_telestrat = \
ascii \ ascii \

View file

@ -334,6 +334,10 @@ static void SetSys (const char* Sys)
CBMSystem ("__CX16__"); CBMSystem ("__CX16__");
break; break;
case TGT_SYM1:
NewSymbol ("__SYM1__", 1);
break;
default: default:
AbEnd ("Invalid target name: '%s'", Sys); AbEnd ("Invalid target name: '%s'", Sys);

View file

@ -286,7 +286,7 @@ static void ParseAutoDecl (Declaration* Decl)
** We abuse the Collection somewhat by using it to store line ** We abuse the Collection somewhat by using it to store line
** numbers. ** numbers.
*/ */
CollReplace (&CurrentFunc->LocalsBlockStack, (void *)(long)GetCurrentLine (), CollReplace (&CurrentFunc->LocalsBlockStack, (void *)(size_t)GetCurrentLine (),
CollCount (&CurrentFunc->LocalsBlockStack) - 1); CollCount (&CurrentFunc->LocalsBlockStack) - 1);
} else { } else {

View file

@ -290,6 +290,10 @@ static void SetSys (const char* Sys)
cbmsys ("__CX16__"); cbmsys ("__CX16__");
break; break;
case TGT_SYM1:
DefineNumericMacro ("__SYM1__", 1);
break;
default: default:
AbEnd ("Unknown target system '%s'", Sys); AbEnd ("Unknown target system '%s'", Sys);
} }

View file

@ -115,7 +115,7 @@ struct CodeEntry;
typedef struct DefOrRef DefOrRef; typedef struct DefOrRef DefOrRef;
struct DefOrRef { struct DefOrRef {
unsigned Line; unsigned Line;
long LocalsBlockId; size_t LocalsBlockId;
unsigned Flags; unsigned Flags;
int StackPtr; int StackPtr;
unsigned Depth; unsigned Depth;

View file

@ -951,7 +951,7 @@ DefOrRef* AddDefOrRef (SymEntry* E, unsigned Flags)
DOR = xmalloc (sizeof (DefOrRef)); DOR = xmalloc (sizeof (DefOrRef));
CollAppend (E->V.L.DefsOrRefs, DOR); CollAppend (E->V.L.DefsOrRefs, DOR);
DOR->Line = GetCurrentLine (); DOR->Line = GetCurrentLine ();
DOR->LocalsBlockId = (long)CollLast (&CurrentFunc->LocalsBlockStack); DOR->LocalsBlockId = (size_t)CollLast (&CurrentFunc->LocalsBlockStack);
DOR->Flags = Flags; DOR->Flags = Flags;
DOR->StackPtr = StackPtr; DOR->StackPtr = StackPtr;
DOR->Depth = CollCount (&CurrentFunc->LocalsBlockStack); 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 /* Are we jumping into a block with initalization of an object that
** has automatic storage duration? Let's emit a warning. ** 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 || (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 " Warning ("Goto at line %d to label %s jumps into a block with "
"initialization of an object that has automatic storage duration", "initialization of an object that has automatic storage duration",
GetCurrentLine (), Name); 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 /* Are we jumping into a block with initalization of an object that
** has automatic storage duration? Let's emit a warning. ** 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 || (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 " Warning ("Goto at line %d to label %s jumps into a block with "
"initialization of an object that has automatic storage duration", "initialization of an object that has automatic storage duration",
DOR->Line, Name); DOR->Line, Name);

View file

@ -174,6 +174,7 @@ static const TargetEntry TargetMap[] = {
{ "sim6502", TGT_SIM6502 }, { "sim6502", TGT_SIM6502 },
{ "sim65c02", TGT_SIM65C02 }, { "sim65c02", TGT_SIM65C02 },
{ "supervision", TGT_SUPERVISION }, { "supervision", TGT_SUPERVISION },
{ "sym1", TGT_SYM1 },
{ "telestrat", TGT_TELESTRAT }, { "telestrat", TGT_TELESTRAT },
{ "vic20", TGT_VIC20 }, { "vic20", TGT_VIC20 },
}; };
@ -215,6 +216,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = {
{ "gamate", CPU_6502, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone },
{ "c65", CPU_4510, BINFMT_BINARY, CTPET }, { "c65", CPU_4510, BINFMT_BINARY, CTPET },
{ "cx16", CPU_65C02, BINFMT_BINARY, CTPET }, { "cx16", CPU_65C02, BINFMT_BINARY, CTPET },
{ "sym1", CPU_6502, BINFMT_BINARY, CTNone },
}; };
/* Target system */ /* Target system */

View file

@ -85,6 +85,7 @@ typedef enum {
TGT_GAMATE, TGT_GAMATE,
TGT_C65, TGT_C65,
TGT_CX16, TGT_CX16,
TGT_SYM1,
TGT_COUNT /* Number of target systems */ TGT_COUNT /* Number of target systems */
} target_t; } target_t;

View file

@ -183,7 +183,7 @@ typedef struct DbgInfo DbgInfo;
struct DbgInfo { struct DbgInfo {
/* First we have all items in collections sorted by id. The ids are /* 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 ** The collections are also used when the objects are deleted, so they're
** actually the ones that "own" the items. ** actually the ones that "own" the items.
*/ */
@ -680,7 +680,7 @@ static char* SB_StrDup (const StrBuf* B)
static Collection* CollInit (Collection* C) static Collection* CollInit (Collection* C)
/* Initialize a collection and return it. */ /* Initialize a collection and return it. */
{ {
/* Intialize the fields. */ /* Initialize the fields. */
C->Count = 0; C->Count = 0;
C->Size = 0; C->Size = 0;
C->Items = 0; C->Items = 0;
@ -1349,7 +1349,7 @@ static int CompareFileInfoByName (const void* L, const void* R)
static LibInfo* NewLibInfo (const StrBuf* Name) 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 */ /* Allocate memory */
LibInfo* L = xmalloc (sizeof (LibInfo) + SB_GetLen (Name)); 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) 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 */ /* Allocate memory */
ModInfo* M = xmalloc (sizeof (ModInfo) + SB_GetLen (Name)); 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) 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 */ /* Allocate memory */
ScopeInfo* S = xmalloc (sizeof (ScopeInfo) + SB_GetLen (Name)); 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) static SpanInfo* NewSpanInfo (void)
/* Create a new SpanInfo struct, intialize and return it */ /* Create a new SpanInfo struct, initialize and return it */
{ {
/* Allocate memory */ /* Allocate memory */
SpanInfo* S = xmalloc (sizeof (SpanInfo)); SpanInfo* S = xmalloc (sizeof (SpanInfo));
@ -1779,7 +1779,7 @@ static int CompareSpanInfoByAddr (const void* L, const void* R)
static SymInfo* NewSymInfo (const StrBuf* Name) 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 */ /* Allocate memory */
SymInfo* S = xmalloc (sizeof (SymInfo) + SB_GetLen (Name)); 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; I += GT_GET_SIZE (A[I]) + 1;
} else { } else {
/* Unknown type in type string */ /* 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; return 0;
} }
break; break;
@ -2733,7 +2733,7 @@ static int StrConstFollows (InputData* D)
static int Consume (InputData* D, Token Tok, const char* Name) 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. ** 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) 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 /* 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 ** returns NULL if no scope with this id was found, otherwise a list of the
** direct childs. ** direct children.
*/ */
{ {
const DbgInfo* Info; const DbgInfo* Info;

View file

@ -196,7 +196,7 @@ static void StrVal (void)
default: default:
CfgWarning (&CfgErrorPos, CfgWarning (&CfgErrorPos,
"Unkown escape sequence '%%%c'", C); "Unknown escape sequence '%%%c'", C);
SB_AppendChar (&CfgSVal, '%'); SB_AppendChar (&CfgSVal, '%');
SB_AppendChar (&CfgSVal, C); SB_AppendChar (&CfgSVal, C);
NextChar (); NextChar ();

51
targettest/sym1/Makefile Normal file
View file

@ -0,0 +1,51 @@
# 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
all: symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin
symHello.bin: symHello.c
$(CL) -t sym1 -O -o symHello.bin symHello.c
symTiny.bin: symTiny.c
$(CL) -t sym1 -O -o symTiny.bin symTiny.c
symDisplay.bin: symDisplay.c
$(CL) -t sym1 -O -o symDisplay.bin symDisplay.c
symIO.bin: symIO.c
$(CL) -t sym1 -C sym1-32k.cfg -O -o symIO.bin symIO.c
symNotepad.bin: symNotepad.c
$(CL) -t sym1 -C sym1-32k.cfg -O -o symNotepad.bin symNotepad.c
clean:
@$(DEL) symHello.bin 2>$(NULLDEV)
@$(DEL) symTiny.bin 2>$(NULLDEV)
@$(DEL) symDisplay.bin 2>$(NULLDEV)
@$(DEL) symIO.bin 2>$(NULLDEV)
@$(DEL) symNotepad.bin 2>$(NULLDEV)

View file

@ -0,0 +1,358 @@
// --------------------------------------------------------------------------
// Sym-1 front panel display example
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
#include <stdio.h>
#include <sym1.h>
int main (void) {
int delay = 10;
int flashes = 255;
int displayable = 1;
int e = 0;
int r = 0;
int d = 0;
int i = 0;
int l = 0;
int t = 0;
int z = 0;
char c = 0x00;
char buffer[41] = { 0x00 };
puts ("\nType a message (40 chars max) and press ENTER, please:\n");
while ( (c != '\n') && (i < 40) ) {
c = getchar();
buffer[i] = c;
i++;
if ( i == 40 ) {
puts ("\n\n--- Reached 40 character limit. ---");
}
}
i--; // index is one past end
while ( z == 0 ) {
puts ("\n\nHow many times (0 for forever) to repeat?");
c = getchar();
if ( (c >= '0') && (c <= '9') ) {// between 1 and 9 loops allowed
z = 1; // a number was pressed
t = c - '0'; // convert char to int
puts ("\n\nLook at the front panel.\n");
}
else {
puts ("\nWhat?");
z = 0; // keep asking for a number
}
}
z = 0;
while ( (z < t) || (t == 0) ) {
z++;
putchar ( '\r' ); // Send CR to console
DISPLAY.d0 = DISP_SPACE; // Clear the display
DISPLAY.d1 = DISP_SPACE;
DISPLAY.d2 = DISP_SPACE;
DISPLAY.d3 = DISP_SPACE;
DISPLAY.d4 = DISP_SPACE;
DISPLAY.d5 = DISP_SPACE;
DISPLAY.d6 = DISP_SPACE;
for ( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
for ( l = 0; l <= i; l++ ) {
displayable = 1; // Assume character is mapped
switch ( buffer[l] ) { // Put the typed charaters
case '1': // into the display buffer
DISPLAY.d6 = DISP_1; // one at a time
break;
case '2':
DISPLAY.d6 = DISP_2;
break;
case '3':
DISPLAY.d6 = DISP_3;
break;
case '4':
DISPLAY.d6 = DISP_4;
break;
case '5':
DISPLAY.d6 = DISP_5;
break;
case '6':
DISPLAY.d6 = DISP_6;
break;
case '7':
DISPLAY.d6 = DISP_7;
break;
case '8':
DISPLAY.d6 = DISP_8;
break;
case '9':
DISPLAY.d6 = DISP_9;
break;
case '0':
DISPLAY.d6 = DISP_0;
break;
case 'A':
DISPLAY.d6 = DISP_A;
break;
case 'a':
DISPLAY.d6 = DISP_A;
break;
case 'B':
DISPLAY.d6 = DISP_b;
break;
case 'b':
DISPLAY.d6 = DISP_b;
break;
case 'C':
DISPLAY.d6 = DISP_C;
break;
case 'c':
DISPLAY.d6 = DISP_c;
break;
case 'D':
DISPLAY.d6 = DISP_d;
break;
case 'd':
DISPLAY.d6 = DISP_d;
break;
case 'E':
DISPLAY.d6 = DISP_E;
break;
case 'e':
DISPLAY.d6 = DISP_e;
break;
case 'F':
DISPLAY.d6 = DISP_F;
break;
case 'f':
DISPLAY.d6 = DISP_F;
break;
case 'G':
DISPLAY.d6 = DISP_G;
break;
case 'g':
DISPLAY.d6 = DISP_g;
break;
case 'H':
DISPLAY.d6 = DISP_H;
break;
case 'h':
DISPLAY.d6 = DISP_h;
break;
case 'I':
DISPLAY.d6 = DISP_I;
break;
case 'i':
DISPLAY.d6 = DISP_i;
break;
case 'J':
DISPLAY.d6 = DISP_J;
break;
case 'j':
DISPLAY.d6 = DISP_J;
break;
case 'K':
DISPLAY.d6 = DISP_K;
break;
case 'k':
DISPLAY.d6 = DISP_K;
break;
case 'L':
DISPLAY.d6 = DISP_L;
break;
case 'l':
DISPLAY.d6 = DISP_L;
break;
case 'M':
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_M_1;
DISPLAY.d6 = DISP_M_2;
break;
case 'm':
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_M_1;
DISPLAY.d6 = DISP_M_2;
break;
case 'N':
DISPLAY.d6 = DISP_n;
break;
case 'n':
DISPLAY.d6 = DISP_n;
break;
case 'O':
DISPLAY.d6 = DISP_O;
break;
case 'o':
DISPLAY.d6 = DISP_o;
break;
case 'P':
DISPLAY.d6 = DISP_P;
break;
case 'p':
DISPLAY.d6 = DISP_P;
break;
case 'Q':
DISPLAY.d6 = DISP_q;
break;
case 'q':
DISPLAY.d6 = DISP_q;
break;
case 'R':
DISPLAY.d6 = DISP_r;
break;
case 'r':
DISPLAY.d6 = DISP_r;
break;
case 'S':
DISPLAY.d6 = DISP_S;
break;
case 's':
DISPLAY.d6 = DISP_S;
break;
case 'T':
DISPLAY.d6 = DISP_t;
break;
case 't':
DISPLAY.d6 = DISP_t;
break;
case 'U':
DISPLAY.d6 = DISP_U;
break;
case 'u':
DISPLAY.d6 = DISP_u;
break;
case 'V':
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_V_1;
DISPLAY.d6 = DISP_V_2;
break;
case 'v':
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_V_1;
DISPLAY.d6 = DISP_V_2;
break;
case 'W':
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_W_1;
DISPLAY.d6 = DISP_W_2;
break;
case 'w':
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_W_1;
DISPLAY.d6 = DISP_W_2;
break;
case 'Y':
DISPLAY.d6 = DISP_Y;
break;
case 'y':
DISPLAY.d6 = DISP_Y;
break;
case 'Z':
DISPLAY.d6 = DISP_Z;
break;
case 'z':
DISPLAY.d6 = DISP_Z;
break;
case ' ':
DISPLAY.d6 = DISP_SPACE;
break;
case '.':
DISPLAY.d6 = DISP_PERIOD;
break;
case '-':
DISPLAY.d6 = DISP_HYPHEN;
break;
case '\'':
DISPLAY.d6 = DISP_APOSTR;
break;
case '"':
DISPLAY.d6 = DISP_APOSTR;
break;
case '=':
DISPLAY.d6 = DISP_EQUAL;
break;
case '_':
DISPLAY.d6 = DISP_BOTTOM;
break;
case '/':
DISPLAY.d6 = DISP_SLASH;
break;
case '\\':
DISPLAY.d6 = DISP_BACKSLASH;
break;
default:
displayable = 0; // Character not mapped
}
if ( displayable ) {
putchar ( buffer[l] ); // Send it to the console
DISPLAY.d0 = DISPLAY.d1; // Scroll to the left
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISPLAY.d6;
for ( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
}
}
for ( e = 0; e < 6; e++ ) { // Gradually fill the
DISPLAY.d0 = DISPLAY.d1; // display with spaces
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_SPACE;
DISPLAY.d6 = DISP_SPACE;
for ( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
}
}
puts ("\n\nEnjoy your day!\n\n");
return 0;
}

View file

@ -0,0 +1,39 @@
// --------------------------------------------------------------------------
// Hello World for Sym-1
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
#include <stdio.h>
#include <sym1.h>
int main (void) {
char c = 0x00;
int d = 0x00;
int l = 0x00;
printf ("\nHello World!\n\n");
for ( l = 0; l < 2; l++ ) {
beep();
for ( d = 0; d < 10 ; d++ ) {
}
}
printf ("Type a line and press ENTER, please.\n\n");
while ( c != '\n' ) {
c = getchar();
}
printf ("\n\nThanks!\n\n");
for ( l = 0; l < 5; l++ ) {
beep();
for ( d = 0; d < 10 ; d++ ) {
}
}
return 0;
}

172
targettest/sym1/symIO.c Normal file
View file

@ -0,0 +1,172 @@
// --------------------------------------------------------------------------
// Sym-1 digital I/O interface example
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
#include <sym1.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void) {
unsigned char ddr1a = 0x00;
unsigned char ior1a = 0x00;
unsigned char ddr1b = 0x00;
unsigned char ior1b = 0x00;
unsigned char ddr2a = 0x00;
unsigned char ior2a = 0x00;
unsigned char ddr2b = 0x00;
unsigned char ior2b = 0x00;
unsigned char ddr3a = 0x00;
unsigned char ior3a = 0x00;
unsigned char ddr3b = 0x00;
unsigned char ior3b = 0x00;
unsigned char val = 0x00;
int going = 0x01;
int instr = 0x01;
int l = 0x00;
char* vp = 0x00;
char cmd[20] = { 0x00 };
while ( going ) {
putchar ( '\r' );
for ( l = 0; l < 25; l++ ) {
putchar ( '\n' );
}
ddr1a = VIA1.ddra;
ior1a = VIA1.pra;
ddr1b = VIA1.ddrb;
ior1b = VIA1.prb;
ddr2a = VIA2.ddra;
ior2a = VIA2.pra;
ddr2b = VIA2.ddrb;
ior2b = VIA2.prb;
ddr3a = VIA3.ddra;
ior3a = VIA3.pra;
ddr3b = VIA3.ddrb;
ior3b = VIA3.prb;
puts ("================== Digital I/O Status ==================");
puts (" Port1A Port1B Port2A Port2B Port3A Port3B" );
printf ("DDR %02X %02X %02X %02X %02X %02X\n\r",ddr1a,ddr1b,ddr2a,ddr2b,ddr3a,ddr3b);
printf ("IOR %02X %02X %02X %02X %02X %02X\n\r",ior1a,ior1b,ior2a,ior2b,ior3a,ior3b);
puts ("========================================================\n");
if ( instr ) {
puts ("You can set any register by typing 'register value' so");
puts ("as an example, to set register IOR2A with the top five");
puts ("bits off and the bottom three on, type 'IOR2A 07'.");
puts ("Press ENTER without any command to see register values");
puts ("without changing any of them. Type 'help' to see these");
puts ("instructions again and type 'quit' to end the program.\n");
puts ("Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A");
puts ("IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B.");
instr = 0;
}
printf ("\n Command: ");
fgets ( cmd, sizeof(cmd)-1, stdin );
cmd[strlen(cmd)-1] = '\0';
if ( strncasecmp(cmd, "quit", 4) == 0 ) {
going = 0;
}
else if ( strncasecmp(cmd, "help", 4) == 0 ) {
instr = 1;
}
else if ( strncasecmp(cmd, "ddr1a", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.ddra = val;
}
}
else if ( strncasecmp(cmd, "ior1a", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.pra = val;
}
}
else if ( strncasecmp(cmd, "ddr1b", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.ddrb = val;
}
}
else if ( strncasecmp(cmd, "ior1b", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.prb = val;
}
}
else if ( strncasecmp(cmd, "ddr2a", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.ddra = val;
}
}
else if ( strncasecmp(cmd, "ior2a", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.pra = val;
}
}
else if ( strncasecmp(cmd, "ddr2b", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.ddrb = val;
}
}
else if ( strncasecmp(cmd, "ior2b", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.prb = val;
}
}
else if ( strncasecmp(cmd, "ddr3a", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.ddra = val;
}
}
else if ( strncasecmp(cmd, "ior3a", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.pra = val;
}
}
else if ( strncasecmp(cmd, "ddr3b", 5) == 0 ) {
vp = strchr ( cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.ddrb = val;
}
}
else if ( strncasecmp(cmd, "ior3b", 5) == 0 ) {
vp = strchr (cmd, ' ' );
if ( vp ) {
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.prb = val;
}
}
}
puts ("\n\nEnjoy your day!\n\n");
return 0;
}

View file

@ -0,0 +1,192 @@
// --------------------------------------------------------------------------
// Sym-1 Notepad
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
//
// Note: This program requires RAM memory in locations 0xE000 - 0xEFFF
// Alternatively, the tape I/O buffer location and size can be
// changed by altering the defined TAPIO values below.
//
// --------------------------------------------------------------------------
#include <sym1.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAPIO_ADDRESS 0xE000
#define TAPIO_MAX_SIZE 0x0FFF
int main (void) {
char c = 0x00;
int l = 0x00;
int p = 0x00;
int error = 0x00;
int running = 0x01;
int writing = 0x01;
int instruction_needed = 0x01;
int heap_size = 0x00;
char* tapio = (char*) TAPIO_ADDRESS;
char* buffer;
heap_size = _heapmaxavail();
if ( heap_size > TAPIO_MAX_SIZE ) { // No need to malloc more than
heap_size = TAPIO_MAX_SIZE; // the interface allows
}
buffer = malloc ( heap_size );
memset ( buffer, 0x00, heap_size );
if ( buffer == 0x00 ) {
puts ("Memory full.");
running = 0;
}
tapio[0] = 0x00; // Check tape interface memory
if ( tapio[0] != 0x00 )
error = 1;
tapio[0] = 0xFF;
if ( tapio[0] != 0xFF )
error = 1;
tapio[TAPIO_MAX_SIZE] = 0x00;
if ( tapio[TAPIO_MAX_SIZE] != 0x00 )
error = 1;
tapio[TAPIO_MAX_SIZE] = 0xFF;
if ( tapio[TAPIO_MAX_SIZE] != 0xFF )
error = 1;
if ( error ) {
printf ("\nNo memory at location %p, aborting.\n", tapio);
running = 0;
}
else {
memset ( tapio, 0, TAPIO_MAX_SIZE );
}
while ( running ) {
putchar ( '\r' );
for ( l = 0; l < 25; l++ ) {
putchar ( '\n' );
}
puts ("===================== Sym-1 Notepad ====================");
if ( instruction_needed ) {
puts ("Enter text and you can save it to tape for reloading");
puts ("later. There are four special 'command' characters:\n");
puts (" Control-S Save to tape");
puts (" Control-L Load from tape");
puts (" Control-C Clear memory");
puts (" Control-X Exit");
puts ("========================================================\n");
}
while ( writing ) {
c = getchar();
if ( c == 0x08 ) { // Backspace
if ( p > 0 ) {
buffer[p] = 0x00;
p--;
}
}
else if ( c == 0x13 ) { // Save
puts ("\n========================= Save =========================");
puts ("\nPress any key to save.");
c = getchar();
for ( l = 0; l <= p; l++ ) {
tapio[l] = buffer[l];
}
l++;
tapio[l] = 0x00;
puts ("Saving to tape.");
error = dumpt ( 'N', tapio, tapio+p );
if ( error ) {
puts ("\nTape error.");
}
else
{
putchar ( '\r' );
for ( l = 0; l < 25; l++ ) {
putchar ( '\n' );
}
}
puts ("===================== Sym-1 Notepad ====================\n");
for ( l = 0; l <= p; l++ ) {
putchar ( buffer[l] );
}
}
else if ( c == 0x0C ) { // Load
p = 0;
puts ("\nLoading from tape.");
memset ( buffer, 0, heap_size );
memset ( tapio, 0, TAPIO_MAX_SIZE );
error = loadt ( 'N' );
if ( error ) {
puts ("\nTape error.");
puts ("===================== Sym-1 Notepad ====================\n");
}
else
{
for ( l = 0; l <= heap_size; l++ ) {
buffer[l] = tapio[l];
}
p = strlen ( buffer );
putchar ( '\r' );
for ( l = 0; l < 25; l++ ) {
putchar ( '\n' );
}
puts ("===================== Sym-1 Notepad ====================\n");
for ( l = 0; l <= p; l++ ) {
putchar ( buffer[l] );
}
}
}
else if ( c == 0x03 ) { // Clear
p = 0;
memset ( buffer, 0, heap_size );
putchar ( '\r' );
for ( l = 0; l < 25; l++ ) {
putchar ( '\n' );
}
puts ("===================== Sym-1 Notepad ====================\n");
}
else if ( c == 0x18 ) { // Exit
writing = 0;
running = 0;
}
else {
if ( p >= heap_size - 1 ) {
puts ("\n========================= End =========================");
puts ("Buffer full.");
}
else {
if ( c == '\n' ) {
putchar ( '\n' );
}
buffer[p] = c;
}
p++;
}
}
}
free ( buffer );
puts ("\nEnjoy your day!\n");
return 0;
}

42
targettest/sym1/symTiny.c Normal file
View file

@ -0,0 +1,42 @@
// --------------------------------------------------------------------------
// Hello World for Sym-1
//
// Uses only getchar, putchar and puts, generating smaller code than printf
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
#include <stdio.h>
#include <sym1.h>
int main (void) {
char c = 0x00;
int d = 0x00;
int l = 0x00;
puts ("Hello World!\n");
puts ("Type a line and press ENTER, please:\n");
for ( l = 0; l < 2; l++ ) {
beep();
for ( d = 0; d < 10 ; d++ ) {
}
}
while ( c != '\n' ) {
c = getchar();
}
puts ("\n\nThanks!\n");
for ( l = 0; l < 5; l++ ) {
beep();
for ( d = 0; d < 10 ; d++ ) {
}
}
return 0;
}