1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 05:29:30 +00:00

Merge pull request #1500 from WayneParham/master

Synertek Systems Sym-1 files
This commit is contained in:
Oliver Schmidt 2021-11-23 22:59:48 +01:00 committed by GitHub
commit 37e7e65f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 1744 additions and 0 deletions

View File

@ -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.

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 ;

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

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

@ -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).

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 \

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 = \
notavailable
EXELIST_sym1 = \
notavailable
EXELIST_telestrat = \
ascii \

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

@ -290,6 +290,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;

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