1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-16 02:10:52 +00:00

Merge branch 'master' into master

This commit is contained in:
Bob Andrews 2021-12-11 22:35:50 +01:00 committed by GitHub
commit 332742b688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 2462 additions and 136 deletions

View File

@ -0,0 +1,56 @@
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:
- 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 linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass
- name: Build
id: build
shell: bash
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
- 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

@ -0,0 +1,69 @@
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:
- 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 linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass
- name: Build
id: build
shell: bash
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
- name: Upload Snapshot Zip
uses: actions/upload-artifact@v2
with:
name: cc65-snapshot-win32.zip
path: cc65.zip
# TODO: Update docs at https://github.com/cc65/doc
# TODO: Publish snapshot zip at https://github.com/cc65/cc65.github.io

View File

@ -9,14 +9,14 @@ jobs:
- sudo apt-get update
- sudo apt-get install linuxdoc-tools linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass
script:
- make bin USER_CFLAGS=-Werror
- make lib QUIET=1
- make -j2 bin USER_CFLAGS=-Werror
- make -j2 lib QUIET=1
- make test QUIET=1
- make samples
- make -j2 samples
- make -C src clean
- make bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
- make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
- make -C samples clean
- make doc zip
- make -j2 doc zip
after_success:
- make -f Makefile.travis

View File

@ -4,7 +4,7 @@
[Wiki](https://github.com/cc65/wiki/wiki)
[![Build Status](https://api.travis-ci.org/cc65/cc65.svg?branch=master)](https://travis-ci.org/cc65/cc65/builds)
[![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
a powerful macro assembler, a C compiler, linker, librarian and several
@ -36,6 +36,7 @@ including
- the Lynx console.
- the Ohio Scientific Challenger 1P.
- the Commander X16.
- the Synertek Systems Sym-1.
The libraries are fairly portable, so creating a version for other 6502s
shouldn't be too much work.

View File

@ -77,6 +77,8 @@ VIC_SPR_EXP_Y := $D017
VIC_SPR_EXP_X := $D01D
VIC_SPR_MCOLOR := $D01C
VIC_SPR_BG_PRIO := $D01B
VIC_SPR_COLL := $D01E
VIC_SPR_BG_COLL := $D01F
VIC_SPR_MCOLOR0 := $D025
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

@ -428,8 +428,8 @@ The names in the parentheses denote the symbols to be used for static linking of
<tag><tt/a2.ssc.ser (a2_ssc_ser)/</tag>
Driver for the Apple&nbsp;II Super Serial Card. Supports up to 19200 baud,
hardware flow control (RTS/CTS) and interrupt driven receives. Note
that because of the peculiarities of the 6551 chip transmits are not
requires hardware flow control (RTS/CTS) and does interrupt driven receives.
Note that because of the peculiarities of the 6551 chip transmits are not
interrupt driven, and the transceiver blocks if the receiver asserts
flow control because of a full buffer.

View File

@ -428,8 +428,8 @@ The names in the parentheses denote the symbols to be used for static linking of
<tag><tt/a2e.ssc.ser (a2e_ssc_ser)/</tag>
Driver for the Apple&nbsp;II Super Serial Card. Supports up to 19200 baud,
hardware flow control (RTS/CTS) and interrupt driven receives. Note
that because of the peculiarities of the 6551 chip transmits are not
requires hardware flow control (RTS/CTS) and does interrupt driven receives.
Note that because of the peculiarities of the 6551 chip transmits are not
interrupt driven, and the transceiver blocks if the receiver asserts
flow control because of a full buffer.

View File

@ -675,9 +675,9 @@ The default callbacks definition (<tt/mouse_def_callbacks/) is an alias for the
<sect1>RS232 device drivers<p>
Currently there is one RS232 driver. It uses the R: device (therefore
an R: driver needs to be installed) and was tested with the 850
interface module.
Currently there is one RS232 driver. It supports up to 9600 baud, requires hardware flow control
(RTS/CTS) and uses the R: device (therefore an R: driver needs to be installed). It was tested
with the 850 interface module.
<table>
<tabular ca="rr">

View File

@ -176,10 +176,11 @@ No mouse drivers are currently available for the Atmos.
<tag><tt/atmos-acia.ser (atmos_acia_ser)/</tag>
Driver for the Telestrat integrated serial controller and the Atmos with a
serial add-on.
Note that, because of the peculiarities of the 6551 chip, together with the
use of the NMI, transmits are not interrupt driven; and, the transceiver
blocks if the receiver asserts flow control because of a full buffer.
serial add-on. Supports up to 19200 baud, requires hardware flow control
(RTS/CTS) and does interrupt driven receives. Note that, because of the
peculiarities of the 6551 chip, together with the use of the NMI, transmits
are not interrupt driven; and, the transceiver blocks if the receiver
asserts flow control because of a full buffer.
</descrip><p>

View File

@ -324,9 +324,9 @@ The default drivers, <tt/mouse_stddrv (mouse_static_stddrv)/, point to <tt/c128-
<descrip>
<tag><tt/c128-swlink.ser (c128_swlink_ser)/</tag>
Driver for the SwiftLink cartridge. Supports up to 38400 BPS, hardware flow
control (RTS/CTS), and interrupt-driven receives. Note that, because of the
peculiarities of the 6551 chip, together with the use of the NMI, transmits
Driver for the SwiftLink cartridge. Supports up to 38400 baud, requires hardware
flow control (RTS/CTS) and does interrupt driven receives. Note that, because of
the peculiarities of the 6551 chip, together with the use of the NMI, transmits
are not interrupt driven; and, the transceiver blocks if the receiver asserts
flow control because of a full buffer.

View File

@ -410,9 +410,9 @@ The default drivers, <tt/mouse_stddrv (mouse_static_stddrv)/, point to <tt/c64-1
<descrip>
<tag><tt/c64-swlink.ser (c64_swlink_ser)/</tag>
Driver for the SwiftLink cartridge. Supports up to 38400 BPS, hardware flow
control (RTS/CTS), and interrupt-driven receives. Note that, because of the
peculiarities of the 6551 chip, together with the use of the NMI, transmits
Driver for the SwiftLink cartridge. Supports up to 38400 baud, requires hardware
flow control (RTS/CTS) and does interrupt driven receives. Note that, because of
the peculiarities of the 6551 chip, together with the use of the NMI, transmits
are not interrupt driven; and, the transceiver blocks if the receiver asserts
flow control because of a full buffer.

View File

@ -4786,6 +4786,7 @@ compiler, depending on the target system selected:
<item><tt/__SIM6502__/ - Target system is <tt/sim6502/
<item><tt/__SIM65C02__/ - Target system is <tt/sim65c02/
<item><tt/__SUPERVISION__/ - Target system is <tt/supervision/
<item><tt/__SYM1__/ - Target system is <tt/sym1/
<item><tt/__VIC20__/ - Target system is <tt/vic20/
</itemize>

View File

@ -231,10 +231,10 @@ The default drivers, <tt/mouse_stddrv (mouse_static_stddrv)/, point to <tt/cbm51
<tag><tt/cbm510-std.ser (cbm510_std_ser)/</tag>
Driver for the 6551 ACIA chip built into the Commodore 510. Supports up to
19200 BPS, hardware flow control (RTS/CTS), and interrupt-driven receives.
Note that, because of the peculiarities of the 6551 chip, transmits are not
interrupt driven; and, the transceiver blocks if the receiver asserts flow
control because of a full buffer.
19200 baud, requires hardware flow control (RTS/CTS) and does interrupt driven
receives. Note that, because of the peculiarities of the 6551 chip, transmits
are not interrupt driven; and, the transceiver blocks if the receiver asserts
flow control because of a full buffer.
</descrip><p>

View File

@ -212,10 +212,10 @@ No mouse drivers are currently available for the Commodore 610.
<tag><tt/cbm610-std.ser (cbm610_std_ser)/</tag>
Driver for the 6551 ACIA chip built into the Commodore 610. Supports up to
19200 BPS, hardware flow control (RTS/CTS), and interrupt-driven receives.
Note that, because of the peculiarities of the 6551 chip, transmits are not
interrupt driven; and, the transceiver blocks if the receiver asserts flow
control because of a full buffer.
19200 baud, requires hardware flow control (RTS/CTS) and does interrupt driven
receives. Note that, because of the peculiarities of the 6551 chip, transmits
are not interrupt driven; and, the transceiver blocks if the receiver asserts
flow control because of a full buffer.
</descrip><p>

View File

@ -1022,6 +1022,10 @@ The compiler defines several macros at startup:
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>
This macro is defined if the target is the Telestrat (-t telestrat).

View File

@ -3,7 +3,7 @@
<article>
<title>Gamate System specific information for cc65
<author>
<url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen">
<url url="mailto:groepaz@gmx.net" name="Groepaz">
<abstract>
An overview over the Gamate runtime system as it is implemented for the
@ -117,14 +117,7 @@ following functions (and a few others):
<sect>Other hints<p>
<itemize>
<item>The Gamate is emulated by MESS (<url url="http://www.mess.org/">),
run like this: <tt>mess gamate -debug -window -skip_gameinfo -cart test.bin</tt>
</itemize>
some resources on the Gamate:
<itemize>
<item><url url="http://en.wikipedia.org/wiki/Gamate">
<item>some resources on the Gamate: <url url="http://en.wikipedia.org/wiki/Gamate">
</itemize>
<sect>License<p>

View File

@ -172,6 +172,9 @@
<tag><htmlurl url="supervision.html" name="supervision.html"></tag>
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>
Topics specific to the Oric Telestrat.

View File

@ -6,6 +6,7 @@
<url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:cbmnut@hushmail.com" name="CbmNut">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">,<newline>
<url url="mailto:groepaz@gmx.net" name="Groepaz">,<newline>
<url url="mailto:stephan.muehlstrasser@web.de" name="Stephan M&uuml;hlstrasser">
<abstract>
@ -458,12 +459,8 @@ Substitute the name of a Commodore computer for that <tt/&lt;sys&gt;/:
Start the desired version of the emulator (CBM610 programs run on
the CBM II &lsqb;<tt/xcbm2/&rsqb; emulator).
In the Windows versions of VICE, choose <bf>File&gt;Autoboot disk/tape
image...</bf>, choose your executable, and click <bf/OK/.
In the Unix versions, hold down the mouse's first button. Move the pointer to
<bf>Smart-attach disk/tape...</bf>, and release the button. Choose your
executable, and click <bf/Autostart/.
Choose <bf>File&gt;Autostart disk/tape image...</bf>, choose your executable,
and click <bf/OK/.
The file has a 14-byte header which corresponds to a PRG-format BASIC program,
consisting of a single line, similar to this:
@ -499,6 +496,29 @@ The output will appear on a separate line, and you will be returned to a BASIC
prompt.
<sect1>Gamate<p>
Before you can run the cartridge image produced by the linker, the binary has to
be patched using the <bf/gamate-fixcart/ tool that is included in the cc65
package in the util/gamata directory.
<tscreen><verb>
gamate-fixcart <image.bin>
</verb></tscreen>
<sect2>MESS<p>
Available at <url
url="https://www.mamedev.org">:
MESS (Multiple Emulator Super System) is a multi system emulator that emulates
various cc65 targets. It once started as a MAME fork, but was marged into MAME
again at some point.
<tscreen><verb>
mess gamate -debug -window -skip_gameinfo -cart <image.bin>
</verb></tscreen>
<sect1>GEOS<p>
Available at <it/Click Here Software's/ <url
url="http://cbmfiles.com/geos/index.html" name="GEOS download section">:
@ -535,17 +555,8 @@ feature on.
</quote>
<quote>
VICE even has different ways that depend on which operating system is running
the emulator.
<itemize>
<item>In Windows, you must click on <bf/Options/ (in an always visible menu).
Then, you must click on <bf/True drive emulation/.
<item>In Unix, you must <em/hold down/ the second button on your mouse. Move
the pointer down to <bf/Drive settings/. Then, move the pointer over to
<bf/Enable true drive emulation/. (If there is a check-mark in front of
those words, that feature already is turned on -- then, move the pointer
off of that menu.) Release the mouse button.
</itemize>
In VICE, got to <bf/Settings/ -> <bf/Settings/, then <bf/Peripherial devices/ ->
<bf/Drive/. Then, you must enable the <bf/True drive emulation/ checkbox.
</quote>
Find the <bf/CONVERT/ program on the boot disk &lsqb;tap the 6-key; then, you
@ -572,6 +583,29 @@ directory notePad. Look at the eight file-positions on each page until you see
The output is shown in a GEOS dialog box; click <bf/OK/ when you have finished
reading it.
Alternatively you can use the <bf/c1541/ program that comes with VICE to write the
file to a disk image directly in GEOS format, so it can be used in GEOS directly
without having to use the <bf/CONVERT/ program.
<tscreen><verb>
c1541 -attach geos.d64 -geoswrite hello1
</verb></tscreen>
<sect1>Nintendo Entertainment System<p>
<sect2>Mednafen (NES)<p>
Available at <url
url="https://mednafen.github.io/releases/">:
Mednafen is a multi system emulator that emulates a couple of the supported
targets of cc65: Apple II/II+, Atari Lynx, Nintendo Entertainment System and
PC Engine/TurboGrafx 16.
<tscreen><verb>
mednafen -force_module nes <image.bin>
</verb></tscreen>
<sect1>Ohio Scientific Challenger 1P<p>
The <tt/osic1p/ runtime library returns to the boot prompt when the main()
@ -694,6 +728,32 @@ Press <RETURN>.
After hitting the RETURN key, you should see the boot prompt again.
<sect1>PC Engine/TurboGrafx 16<p>
For the cartridge image produced by the linker to work in emulators and on real
hardware, its content must be rearranged so the first 8k block becomes the last
8k block in the image.
For example, for a 32k image this can be done using <bf/dd/ as follows:
<tscreen><verb>
dd if=infile.bin bs=8K skip=3 > outfile.pce
dd if=infile.bin bs=8K count=3 >> outfile.pce
</verb></tscreen>
<sect2>Mednafen<p>
Available at <url
url="https://mednafen.github.io/releases/">:
Mednafen is a multi system emulator that emulates a couple of the supported
targets of cc65: Apple II/II+, Atari Lynx, Nintendo Entertainment System and
PC Engine/TurboGrafx 16.
<tscreen><verb>
mednafen -force_module pce <image.pce>
</verb></tscreen>
<sect1>Contributions wanted<p>
We need your help! Recommended emulators and instructions for other targets

View File

@ -59,6 +59,9 @@ Functions that are <em/not/ available:
Functions not available on all supported systems:
<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
are built on open/read/write/close. Those latter functions are not available
on all systems.

View File

@ -2,7 +2,7 @@
<article>
<title>PC-Engine (TurboGrafx 16) System-specific information for cc65
<author><url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen">,<newline>
<author><url url="mailto:groepaz@gmx.net" name="Groepaz">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<abstract>
@ -206,11 +206,6 @@ following functions (and a few others):
<sect>Other hints<p>
<itemize>
<item><url url="https://mednafen.github.io/" name= "Mednafen"> is a good
emulator to use for the PC-Engine.
</itemize>
Some useful resources on PCE coding:
<itemize>

View File

@ -195,10 +195,10 @@ No mouse drivers are currently available for the Plus/4.
<tag><tt/plus4-stdser.ser (plus4_stdser_ser)/</tag>
Driver for the 6551 ACIA chip built into the Plus/4. Supports up to 19200
baud, hardware flow control (RTS/CTS) and interrupt driven receives. Note
that because of the peculiarities of the 6551 chip transmits are not
interrupt driven, and the transceiver blocks if the receiver asserts flow
control because of a full buffer.
baud, requires hardware flow control (RTS/CTS) and does interrupt driven
receives. Note that because of the peculiarities of the 6551 chip transmits
are not interrupt driven, and the transceiver blocks if the receiver asserts
flow control because of a full buffer.
You need an adapter to use the builtin port, since the output levels
available at the user port don't follow the RS232 standard.

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 \
sim65c02 \
supervision \
sym1 \
telestrat
DRVTYPES = emd \

View File

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

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

@ -154,7 +154,7 @@ endif
# Lists of subdirectories
# disasm depends on cpp
DIRLIST = tutorial geos
DIRLIST = tutorial geos atari2600 supervision cbm
# --------------------------------------------------------------------------
# Lists of executables
@ -205,28 +205,22 @@ EXELIST_bbc = \
EXELIST_c64 = \
ascii \
enumdevdir \
fire \
gunzip65 \
hello \
mandelbrot \
mousedemo \
multdemo \
nachtm \
ovrldemo \
plasma \
sieve \
tgidemo
EXELIST_c128 = \
ascii \
enumdevdir \
fire \
gunzip65 \
hello \
mandelbrot \
mousedemo \
nachtm \
plasma \
sieve \
tgidemo
@ -237,19 +231,15 @@ EXELIST_c16 = \
EXELIST_cbm510 = \
ascii \
fire \
gunzip65 \
hello \
mousedemo \
nachtm \
plasma \
sieve
EXELIST_cbm610 = \
ascii \
gunzip65 \
hello \
nachtm \
sieve
EXELIST_creativision = \
@ -302,7 +292,6 @@ EXELIST_plus4 = \
enumdevdir \
gunzip65 \
hello \
plasma \
sieve
EXELIST_sim6502 = \
@ -311,7 +300,10 @@ EXELIST_sim6502 = \
EXELIST_sim65c02 = $(EXELIST_sim6502)
EXELIST_supervision = \
supervisionhello
notavailable
EXELIST_sym1 = \
notavailable
EXELIST_telestrat = \
ascii \
@ -398,7 +390,7 @@ $(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),s >$(
endef # D64_WRITE_SEQ_recipe
samples.d64: samples
@$(C1541) -format samples,AA d64 $@ >$(NULLDEV)
@$(C1541) -format "samples,00" d64 $@ >$(NULLDEV)
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_PRG_recipe))
$(foreach file,$(OVERLAYLIST),$(D64_WRITE_PRG_recipe))
$(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_SEQ_recipe))
@ -460,11 +452,17 @@ install:
$(INSTALL) -d $(DESTDIR)$(samplesdir)
$(INSTALL) -d $(DESTDIR)$(samplesdir)/geos
$(INSTALL) -d $(DESTDIR)$(samplesdir)/tutorial
$(INSTALL) -d $(DESTDIR)$(samplesdir)/atari2600
$(INSTALL) -d $(DESTDIR)$(samplesdir)/cbm
$(INSTALL) -d $(DESTDIR)$(samplesdir)/supervision
$(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir)
$(INSTALL) -m0644 readme.txt $(DESTDIR)$(samplesdir)
$(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir)
$(INSTALL) -m0644 geos/*.* $(DESTDIR)$(samplesdir)/geos
$(INSTALL) -m0644 tutorial/*.* $(DESTDIR)$(samplesdir)/tutorial
$(INSTALL) -m0644 atari2600/*.* $(DESTDIR)$(samplesdir)/atari2600
$(INSTALL) -m0644 cbm/*.* $(DESTDIR)$(samplesdir)/cbm
$(INSTALL) -m0644 supervision/*.* $(DESTDIR)$(samplesdir)/supervision
# --------------------------------------------------------------------------
# Packaging rules

View File

@ -0,0 +1,59 @@
# Run 'make SYS=<target>'; or, set a SYS env.
# var. to build for another target system.
SYS ?= atari2600
# 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
SP = $(CC65_HOME)/bin/sp65
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)
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
endif
EXELIST_atari2600 = \
hello
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: atari 2600 samples not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
hello: hello.c
$(CL) -t $(SYS) -O -o hello -m hello.map hello.c
clean:
@$(DEL) $(EXELIST_atari2600) 2>$(NULLDEV)
@$(DEL) *.map 2>$(NULLDEV)

164
samples/cbm/Makefile Normal file
View File

@ -0,0 +1,164 @@
# Run 'make SYS=<target>'; or, set a SYS env.
# var. to build for another target system.
SYS ?= c64
# 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
SP = $(CC65_HOME)/bin/sp65
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)
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
endif
ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),)
ifdef CC65_HOME
TARGET_PATH = $(CC65_HOME)/target
else
TARGET_PATH := $(if $(wildcard ../target),../target,$(shell $(CL) --print-target-path))
endif
# If TARGET_PATH contains spaces then it is presumed to contain escaped spaces. GNU make
# has very limited support for paths containing spaces. $(wildcard) is the only function
# that is aware of escaped spaces. However, $(wildcard) never returns paths with escaped
# spaces !!! So if it e.g. finds 4 files in a path with 2 spaces then one ends up with a
# return value consisting of 12 plain words :-((
#
# Fortunately we can work around that behaviour here because we know that the files we
# are looking for have known extensions. So we can $(filter) the in our example above 12
# words for file extensions so we come up with 4 path fragments. Then we remove those
# path fragments with $(notdir) from the file names.
#
# So far so good. But here we want to process files from different paths in a single
# recipe further down below and therefore want to prepend the paths to the files with
# $(addprefix). However, $(foreach) isn't aware of escaped spaces (only $(wildcard) is).
# Therefore, we need to replace the spaces with some other character temporarily in order
# to have $(foreach) generate one invocation per file. We use the character '?' for that
# purpose here, just because it is known to not be part of file names.
#
# Inside the recipe generated per file we then replace the '?' again with a space. As we
# want to be compatible with cmd.exe for execution we're not using an escaped space but
# rather double-quote the whole path.
#
# Note: The "strange" $(wildcard) further down below just serves the purpose to unescape
# spaces for cmd.exe. This could have as well been done with another $(subst).
SUBST_TARGET_PATH := $(subst \$(SPACE),?,$(TARGET_PATH))
EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*)
MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*)
TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*)
EMD := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/emd/,$(notdir $(filter %.emd,$(EMD))))
MOU := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/mou/,$(notdir $(filter %.mou,$(MOU))))
TGI := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/tgi/,$(notdir $(filter %.tgi,$(TGI))))
# This one comes with the VICE emulator.
# See http://vice-emu.sourceforge.net/
C1541 ?= c1541
endif
DISK_c64 = samples.d64
EXELIST_c64 = \
fire \
plasma \
nachtm
EXELIST_c128 = \
fire \
plasma \
nachtm
EXELIST_cbm510 = \
fire \
plasma \
nachtm
EXELIST_cbm610 = \
nachtm
EXELIST_plus4 = \
plasma
EXELIST_c16 = \
notavailable
EXELIST_pet = \
notavailable
EXELIST_vic20 = \
notavailable
ifneq ($(EXELIST_$(SYS)),)
samples: $(EXELIST_$(SYS))
else
samples: notavailable
endif
disk: $(DISK_$(SYS))
# empty target used to skip systems that will not work with any program in this dir
notavailable:
ifeq ($(MAKELEVEL),0)
@echo "info: cbm samples not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
fire: fire.c
$(CL) -t $(SYS) -O -o fire -m fire.map fire.c
plasma: plasma.c
$(CL) -t $(SYS) -O -o plasma -m plasma.map plasma.c
nachtm: nachtm.c
$(CL) -t $(SYS) -O -o nachtm -m nachtm.map nachtm.c
# --------------------------------------------------------------------------
# Rule to make a CBM disk with all samples. Needs the c1541 program that comes
# with the VICE emulator.
define D64_WRITE_PRG_recipe
$(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),p >$(NULLDEV)
endef # D64_WRITE_PRG_recipe
define D64_WRITE_SEQ_recipe
$(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),s >$(NULLDEV)
endef # D64_WRITE_SEQ_recipe
samples.d64: samples
@$(C1541) -format "samples,00" d64 $@ >$(NULLDEV)
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_PRG_recipe))
# $(foreach file,$(OVERLAYLIST),$(D64_WRITE_PRG_recipe))
# $(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_SEQ_recipe))
clean:
@$(DEL) $(EXELIST_$(SYS)) 2>$(NULLDEV)
@$(DEL) *.map 2>$(NULLDEV)
@$(DEL) $(DISK_$(SYS)) 2>$(NULLDEV)

View File

@ -10,11 +10,13 @@ Please note:
similar systems. If you're using Windows, then consider installing Cygwin
or MSys2.
* The makefile specifies the C64 as the default target system because all
but three of the programs run on that platform. When compiling for another
system, you will have to change the line that specifies the target system
at the top of the makefile, specify the system with SYS=<target> on the
make command line, or set a SYS environment variable.
* The makefile specifies the C64 as the default target system because most
of the programs run on that platform. When compiling for another system,
you will have to change the line that specifies the target system at the
top of the makefile, specify the system with SYS=<target> on the make
command line, or set a SYS environment variable. For example:
make SYS=apple2
* Use "make disk" to build a disk image with all sample programs.
@ -31,11 +33,6 @@ Description: Shows the ASCII (or ATASCII, PETSCII) codes of typed
<greg.king5@verizon.com>.
Platforms: All platforms with conio or stdio (compile time configurable).
-----------------------------------------------------------------------------
Name: atari2600hello
Description: A "Hello world" type program.
Platforms: Runs on only the Atari 2600 Video Console System.
-----------------------------------------------------------------------------
Name: diodemo
Description: A disc copy program written and contributed by Oliver
@ -52,12 +49,6 @@ Platforms: All systems with device enumeration and directory access
(currently the Commodore machines, the Commander X16,
and the Apple ][).
-----------------------------------------------------------------------------
Name: fire
Description: Another graphics demo written by groepaz/hitmen.
Platforms: The program currently is running on only the C64, but should
be portable to the C128 and CBM510 (and maybe more machines).
-----------------------------------------------------------------------------
Name: gunzip65
Description: A gunzip utility for 6502-based machines, written by Piotr
@ -76,8 +67,8 @@ Platforms: Runs on all platforms that support conio, which means:
-----------------------------------------------------------------------------
Name: mandelbrot
Description: A mandelbrot demo using integer arithmetic. The demo was
written by groepaz/hitmen, and converted to cc65 using TGI
graphics by Stephan Haubenthal.
written by groepaz, and converted to cc65 using TGI graphics
by Stephan Haubenthal.
Platforms: Runs on all platforms that have TGI support:
Apple ][, Atari, C64, C128, Oric Atmos and Telestrat, GEOS,
NES, and Lynx.
@ -97,13 +88,6 @@ Platforms: All systems with an overlay linker config., disk directory
access, and EMD support (currently the C64, the C128,
the Atari, and the Apple ][).
-----------------------------------------------------------------------------
Name: nachtm
Description: Plays "Eine kleine Nachtmusik" by Wolfgang Amadeus Mozart.
Platforms: All systems that have the Commodore SID (Sound Interface
Device):
C64, C128, CBM510, CBM610.
-----------------------------------------------------------------------------
Name: overlaydemo
Description: Shows how to load overlay files from disk. Written and
@ -111,13 +95,6 @@ Description: Shows how to load overlay files from disk. Written and
Platforms: All systems with an overlay linker config. (currently the C64,
the C128, the Atari, and the Apple ][).
-----------------------------------------------------------------------------
Name: plasma
Description: A fancy graphics demo written by groepaz/hitmen.
Platforms: The program needs a VIC-II or a TED, so it runs on the following
systems:
C64, C128, CBM510, Plus/4.
-----------------------------------------------------------------------------
Name: sieve
Description: Implements the "Sieve of Eratosthenes" as a way to find all
@ -128,11 +105,6 @@ Platforms: All systems with conio and clock support:
Commander X16, Apple ][ (without timing due to missing clock
support).
-----------------------------------------------------------------------------
Name: supervisionhello
Description: A "Hello world" type program.
Platforms: Runs on only the Watara Supervision game console.
-----------------------------------------------------------------------------
Name: tgidemo
Description: Shows some of the graphics capabilities of the "Tiny Graphics
@ -140,3 +112,46 @@ Description: Shows some of the graphics capabilities of the "Tiny Graphics
Platforms: Runs on all platforms that have TGI support:
Apple ][, Atari, C64, C128, Oric Atmos and Telestrat, GEOS,
NES, and Lynx.
=============================================================================
Platform specific samples follow:
atari 2600:
-----------
Name: hello
Description: A "Hello world" type program.
Platforms: Runs on only the Atari 2600 Video Console System.
-----------------------------------------------------------------------------
cbm:
----
Name: fire
Description: Another graphics demo written by groepaz.
Platforms: C64, C128, CBM510
-----------------------------------------------------------------------------
Name: nachtm
Description: Plays "Eine kleine Nachtmusik" by Wolfgang Amadeus Mozart.
Platforms: All systems that have the Commodore SID (Sound Interface
Device):
C64, C128, CBM510, CBM610.
-----------------------------------------------------------------------------
Name: plasma
Description: A fancy graphics demo written by groepaz.
Platforms: The program needs a VIC-II or a TED, so it runs on the following
systems:
C64, C128, CBM510, Plus/4.
-----------------------------------------------------------------------------
supervision:
------------
Name: hello
Description: A "Hello world" type program.
Platforms: Runs on only the Watara Supervision game console.
----------------------------------------------------------------------------

View File

@ -0,0 +1,59 @@
# Run 'make SYS=<target>'; or, set a SYS env.
# var. to build for another target system.
SYS ?= supervision
# 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
SP = $(CC65_HOME)/bin/sp65
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)
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
endif
EXELIST_supervision = \
hello
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: supervision samples not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
hello: hello.c
$(CL) -t $(SYS) -O -o hello -m hello.map hello.c
clean:
@$(DEL) $(EXELIST_supervision) 2>$(NULLDEV)
@$(DEL) *.map 2>$(NULLDEV)

View File

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

View File

@ -1113,9 +1113,9 @@ static unsigned Opt_a_toscmpbool (StackOpData* D, const char* BoolTransformer)
D->IP = D->OpIndex + 1;
if (!D->RhsMultiChg &&
(D->Rhs.A.LoadEntry->Flags & CEF_DONT_REMOVE) == 0 &&
(D->Rhs.A.Flags & LI_DIRECT) != 0) {
if (!D->RhsMultiChg &&
(D->Rhs.A.Flags & LI_DIRECT) != 0 &&
(D->Rhs.A.LoadEntry->Flags & CEF_DONT_REMOVE) == 0) {
/* cmp */
AddOpLow (D, OP65_CMP, &D->Rhs);

View File

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

View File

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

View File

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

View File

@ -5,13 +5,13 @@ MEMORY {
ZP: file = "", define = yes, start = $0082, size = $007E;
# First memory segment in file, show message
LOADER: file = %O, start = $680, size = 128;
# First memory segment in file, load over COLOR registers:
# Second memory segment in file, load over COLOR registers:
COLOR: file = %O, start = $2C4, size = 5;
# Second memory segment, load at page 6:
# Third memory segment, load at page 6:
PAGE6: file = %O, start = $600, size = 128;
# Third memory segment in file, load over SDLST register:
# Fourth memory segment in file, load over SDLST register:
SDLST: file = %O, start = $230, size = 2;
# Main segment, load at "STARTADDRESS"
# Fifth/Main segment, load at "STARTADDRESS"
MAIN: file = %O, start = %S, size = $BC20 - %S;
}
FILES {

View File

@ -9,9 +9,9 @@
int main(void)
{
char *rev;
unsigned int t, v;
unsigned char palntsc;
unsigned char *rev;
unsigned char minor;
unsigned char c;

View File

@ -42,14 +42,15 @@ else
COUNT := 1
endif
all: conio.pce
all: conio.bin
%.bin: %.c
$(CL) -t pce $< -Wl -D__CARTSIZE__=${CARTSIZE} -m $*.map -o $@
@echo "use 'make conio.pce' to produce a .pce file using dd"
%.pce: %.bin
dd if=$< bs=8K skip=${COUNT} > $@
dd if=$< bs=8K count=${COUNT} >> $@
%.bin: %.c
$(CL) -t pce $< -Wl -D__CARTSIZE__=${CARTSIZE} -m $*.map -o $@
clean:
@$(DEL) conio.o conio.??? 2>$(NULLDEV)

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;
}

42
test/val/bug1552.c Normal file
View File

@ -0,0 +1,42 @@
/*
bug #1552 - crash in fuzix xec.c
cc65 -t none -O bug1552.c
*/
#include <stdio.h>
typedef struct trenod *TREPTR;
typedef struct whnod *WHPTR;
struct trenod {
int tretyp;
};
struct whnod {
int whtyp;
TREPTR whtre;
};
int execute(TREPTR argt, int execflg, int *pf1, int *pf2)
{
register TREPTR t;
int type;
switch (type)
{
case 6:
{
while ((execute(((WHPTR) t)->whtre, 0, NULL, NULL) == 0) == (type == 5)) {
}
break;
}
}
return 0;
}
int main(void)
{
return execute((TREPTR)42, 2, (int *)3, (int *)4);
}

30
test/val/bug1562.c Normal file
View File

@ -0,0 +1,30 @@
/* bug 1562: cc65 generates incorrect code for logical expression with -O */
#include <stdio.h>
#include <string.h>
int failures = 0;
char input[256];
#define DEBUGTRUE(x) printf("%s=%d\n", #x, (x)); failures += (x) ? 0 : 1
#define DEBUGFALSE(x) printf("%s=%d\n", #x, (x)); failures += (x) ? 1 : 0
int main(void) {
char* r;
strcpy(input, "\"XYZ\"");
r = input+4;
DEBUGFALSE(*r != '"'); // = false
DEBUGTRUE(*r == '"'); // = true
DEBUGFALSE(*(r+1) == '"'); // = false
// Next answer should be false because
// (false || true && false) is false, but it is true with -O.
DEBUGFALSE(*r != '"' || *r == '"' && *(r+1) == '"');
// Adding parens fixes it even with -O.
DEBUGFALSE(*r != '"' || (*r == '"' && *(r+1) == '"'));
printf("failures: %d\n", failures);
return failures;
}