From 6e79379405f09d3c51765db44a16c69b28289797 Mon Sep 17 00:00:00 2001 From: Wayne Parham Date: Sun, 9 May 2021 16:34:53 -0500 Subject: [PATCH 01/47] Synertek Systems Sym-1 machine-specific files --- libsrc/sym1/beep.s | 24 ++ libsrc/sym1/bitio.s | 230 +++++++++++++++++ libsrc/sym1/crt0.s | 65 +++++ libsrc/sym1/display.s | 154 ++++++++++++ libsrc/sym1/getchar.s | 21 ++ libsrc/sym1/libref.s | 3 + libsrc/sym1/putchar.s | 23 ++ libsrc/sym1/read.s | 54 ++++ libsrc/sym1/tapeio.s | 58 +++++ libsrc/sym1/write.s | 53 ++++ samples/symDisplay.c | 384 +++++++++++++++++++++++++++++ samples/symHello.c | 39 +++ samples/symIO.c | 170 +++++++++++++ samples/symTiny.c | 42 ++++ samples/tutorial/sym1/build | 36 +++ samples/tutorial/sym1/build_32k | 36 +++ samples/tutorial/sym1/build_4k | 36 +++ samples/tutorial/sym1/clean | 14 ++ samples/tutorial/sym1/readme.txt | 11 + samples/tutorial/sym1/symDisplay.c | 384 +++++++++++++++++++++++++++++ samples/tutorial/sym1/symHello.c | 39 +++ samples/tutorial/sym1/symIO.c | 170 +++++++++++++ samples/tutorial/sym1/symTiny.c | 42 ++++ 23 files changed, 2088 insertions(+) create mode 100644 libsrc/sym1/beep.s create mode 100644 libsrc/sym1/bitio.s create mode 100644 libsrc/sym1/crt0.s create mode 100644 libsrc/sym1/display.s create mode 100644 libsrc/sym1/getchar.s create mode 100644 libsrc/sym1/libref.s create mode 100644 libsrc/sym1/putchar.s create mode 100644 libsrc/sym1/read.s create mode 100644 libsrc/sym1/tapeio.s create mode 100644 libsrc/sym1/write.s create mode 100644 samples/symDisplay.c create mode 100644 samples/symHello.c create mode 100644 samples/symIO.c create mode 100644 samples/symTiny.c create mode 100644 samples/tutorial/sym1/build create mode 100644 samples/tutorial/sym1/build_32k create mode 100644 samples/tutorial/sym1/build_4k create mode 100644 samples/tutorial/sym1/clean create mode 100644 samples/tutorial/sym1/readme.txt create mode 100644 samples/tutorial/sym1/symDisplay.c create mode 100644 samples/tutorial/sym1/symHello.c create mode 100644 samples/tutorial/sym1/symIO.c create mode 100644 samples/tutorial/sym1/symTiny.c diff --git a/libsrc/sym1/beep.s b/libsrc/sym1/beep.s new file mode 100644 index 000000000..a1f978563 --- /dev/null +++ b/libsrc/sym1/beep.s @@ -0,0 +1,24 @@ +; --------------------------------------------------------------------------- +; beep.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.export _beep + +.segment "CODE" + +.proc _beep: near +; --------------------------------------------------------------------------- + jsr BEEP ; Beep + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc diff --git a/libsrc/sym1/bitio.s b/libsrc/sym1/bitio.s new file mode 100644 index 000000000..5aa0fde8b --- /dev/null +++ b/libsrc/sym1/bitio.s @@ -0,0 +1,230 @@ +; --------------------------------------------------------------------------- +; bitio.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.export _set_DDR1A, _get_DDR1A, _set_IOR1A, _get_IOR1A +.export _set_DDR1B, _get_DDR1B, _set_IOR1B, _get_IOR1B +.export _set_DDR2A, _get_DDR2A, _set_IOR2A, _get_IOR2A +.export _set_DDR2B, _get_DDR2B, _set_IOR2B, _get_IOR2B +.export _set_DDR3A, _get_DDR3A, _set_IOR3A, _get_IOR3A +.export _set_DDR3B, _get_DDR3B, _set_IOR3B, _get_IOR3B + +.segment "CODE" + +.proc _set_DDR1A: near +; --------------------------------------------------------------------------- + sta DDR1A ; Write data direction register for port 1A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR1A: near +; --------------------------------------------------------------------------- + lda DDR1A ; Read data direction register for port 1A + ldx #$00 ; + rts ; Return DDR1A +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR1A: near +; --------------------------------------------------------------------------- + sta OR1A ; Write I/O register for port 1A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR1A: near +; --------------------------------------------------------------------------- + lda OR1A ; Read I/O register for port 1A + ldx #$00 ; + rts ; Return OR1A +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR1B: near +; --------------------------------------------------------------------------- + sta DDR1B ; Write data direction register for port 1B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR1B: near +; --------------------------------------------------------------------------- + lda DDR1B ; Read data direction register for port 1B + ldx #$00 ; + rts ; Return DDR1B +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR1B: near +; --------------------------------------------------------------------------- + sta OR1B ; Write I/O register for port 1B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR1B: near +; --------------------------------------------------------------------------- + lda OR1B ; Read I/O register for port 1B + ldx #$00 ; + rts ; Return OR1B +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR2A: near +; --------------------------------------------------------------------------- + sta DDR2A ; Write data direction register for port 2A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR2A: near +; --------------------------------------------------------------------------- + lda DDR2A ; Read data direction register for port 2A + ldx #$00 ; + rts ; Return DDR2A +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR2A: near +; --------------------------------------------------------------------------- + sta OR2A ; Write I/O register for port 2A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR2A: near +; --------------------------------------------------------------------------- + lda OR2A ; Read I/O register for port 2A + ldx #$00 ; + rts ; Return OR2A +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR2B: near +; --------------------------------------------------------------------------- + sta DDR2B ; Write data direction register for port 2B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR2B: near +; --------------------------------------------------------------------------- + lda DDR2B ; Read data direction register for port 2B + ldx #$00 ; + rts ; Return DDR2B +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR2B: near +; --------------------------------------------------------------------------- + sta OR2B ; Write I/O register for port 2B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR2B: near +; --------------------------------------------------------------------------- + lda OR2B ; Read I/O register for port 2B + ldx #$00 ; + rts ; Return OR2B +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR3A: near +; --------------------------------------------------------------------------- + sta DDR3A ; Write data direction register for port 3A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR3A: near +; --------------------------------------------------------------------------- + lda DDR3A ; Read data direction register for port 3A + ldx #$00 ; + rts ; Return DDR3A +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR3A: near +; --------------------------------------------------------------------------- + sta OR3A ; Write I/O register for port 3A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR3A: near +; --------------------------------------------------------------------------- + lda OR3A ; Read I/O register for port 3A + ldx #$00 ; + rts ; Return OR3A +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR3B: near +; --------------------------------------------------------------------------- + sta DDR3B ; Write data direction register for port 3B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR3B: near +; --------------------------------------------------------------------------- + lda DDR3B ; Read data direction register for port 3B + ldx #$00 ; + rts ; Return DDR3B +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR3B: near +; --------------------------------------------------------------------------- + sta OR3B ; Write I/O register for port 3B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR3B: near +; --------------------------------------------------------------------------- + lda OR3B ; Read I/O register for port 3B + ldx #$00 ; + rts ; Return OR3B +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/crt0.s b/libsrc/sym1/crt0.s new file mode 100644 index 000000000..a85887991 --- /dev/null +++ b/libsrc/sym1/crt0.s @@ -0,0 +1,65 @@ +; --------------------------------------------------------------------------- +; crt0.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + + .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 +; --------------------------------------------------------------------------- + diff --git a/libsrc/sym1/display.s b/libsrc/sym1/display.s new file mode 100644 index 000000000..530435d87 --- /dev/null +++ b/libsrc/sym1/display.s @@ -0,0 +1,154 @@ +; --------------------------------------------------------------------------- +; display.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.export _fdisp, _set_D0, _get_D0 +.export _set_D1, _get_D1, _set_D2, _get_D2 +.export _set_D3, _get_D3, _set_D4, _get_D4 +.export _set_D5, _get_D5, _set_D6, _get_D6 + +.segment "CODE" + +.proc _fdisp: near +; --------------------------------------------------------------------------- + jsr SCAND ; Flash Display + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D0: near +; --------------------------------------------------------------------------- + sta DISBUF0 ; Write Digit 0 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D0: near +; --------------------------------------------------------------------------- + lda DISBUF0 ; Read Digit 0 + ldx #$00 ; + rts ; Return DISBUF0 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D1: near +; --------------------------------------------------------------------------- + sta DISBUF1 ; Write Digit 1 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D1: near +; --------------------------------------------------------------------------- + lda DISBUF1 ; Read Digit 1 + ldx #$00 ; + rts ; Return DISBUF1 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D2: near +; --------------------------------------------------------------------------- + sta DISBUF2 ; Write Digit 2 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D2: near +; --------------------------------------------------------------------------- + lda DISBUF2 ; Read Digit 2 + ldx #$00 ; + rts ; Return DISBUF2 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D3: near +; --------------------------------------------------------------------------- + sta DISBUF3 ; Write Digit 3 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D3: near +; --------------------------------------------------------------------------- + lda DISBUF3 ; Read Digit 3 + ldx #$00 ; + rts ; Return DISBUF3 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D4: near +; --------------------------------------------------------------------------- + sta DISBUF4 ; Write Digit 4 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D4: near +; --------------------------------------------------------------------------- + lda DISBUF4 ; Read Digit 4 + ldx #$00 ; + rts ; Return DISBUF4 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D5: near +; --------------------------------------------------------------------------- + sta DISBUF5 ; Write Digit 5 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D5: near +; --------------------------------------------------------------------------- + lda DISBUF5 ; Read Digit 5 + ldx #$00 ; + rts ; Return DISBUF5 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D6: near +; --------------------------------------------------------------------------- + sta DISBUF6 ; Write byte to the right of display + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D6: near +; --------------------------------------------------------------------------- + lda DISBUF6 ; Read byte to the right of display + ldx #$00 ; + rts ; Return DISBUF6 +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/getchar.s b/libsrc/sym1/getchar.s new file mode 100644 index 000000000..d82519ce0 --- /dev/null +++ b/libsrc/sym1/getchar.s @@ -0,0 +1,21 @@ +; --------------------------------------------------------------------------- +; getchar.s +; +; for Sym-1 +; +; Wayne Parham +; --------------------------------------------------------------------------- + +.include "sym1.inc" +.export _getchar + +.segment "CODE" + +.proc _getchar: near +; --------------------------------------------------------------------------- + jsr INTCHR ; Get character using Monitor ROM call + and #$7F ; Strip off top bit + ldx #$00 ; + rts ; Return char +; --------------------------------------------------------------------------- +.endproc diff --git a/libsrc/sym1/libref.s b/libsrc/sym1/libref.s new file mode 100644 index 000000000..9356d18dc --- /dev/null +++ b/libsrc/sym1/libref.s @@ -0,0 +1,3 @@ + + .import _exit + diff --git a/libsrc/sym1/putchar.s b/libsrc/sym1/putchar.s new file mode 100644 index 000000000..1b84416fe --- /dev/null +++ b/libsrc/sym1/putchar.s @@ -0,0 +1,23 @@ +; --------------------------------------------------------------------------- +; putchar.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" +.export _putchar + +.segment "CODE" + +.proc _putchar: near +; --------------------------------------------------------------------------- + jsr OUTCHR ; Send character using Monitor ROM call + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s new file mode 100644 index 000000000..f0b0194d2 --- /dev/null +++ b/libsrc/sym1/read.s @@ -0,0 +1,54 @@ +; --------------------------------------------------------------------------- +; read.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.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 hi bit and check for '\r' + cmp #$0D + bne putch + lda #$0A ; Replace with '\n' and set count to zero + +putch: ldy #$00 ; Put char into return buffer + sta (ptr1),y + inc ptr1 ; Increment pointer + bne begin + inc ptr1+1 + bne begin + +done: lda ptr3 + ldx ptr3+1 + rts ; Return count +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s new file mode 100644 index 000000000..3a0c1fa5b --- /dev/null +++ b/libsrc/sym1/tapeio.s @@ -0,0 +1,58 @@ +; --------------------------------------------------------------------------- +; tapeio.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.import popax + +.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 + lda #$00 + ldx #$00 ; Return 0000 if successful + jmp done +error: ldx #$00 + lda #$FF ; or 00FF if not +done: rts +; --------------------------------------------------------------------------- +.endproc + +.proc _dumpt: near +; --------------------------------------------------------------------------- + sta P3L ; End address + stx P3H + jsr popax + sta P2L ; Start address + stx P2H + jsr popax + sta P1L ; Tape Record ID + ldx #$00 + stx P1H + ldy #$80 + jsr DUMPT ; Write data to tape + bcs error + lda #$00 + ldx #$00 ; Return 0000 if successful + jmp done +error: ldx #$00 + lda #$FF ; or 00FF if not +done: rts +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/write.s b/libsrc/sym1/write.s new file mode 100644 index 000000000..843dddf1f --- /dev/null +++ b/libsrc/sym1/write.s @@ -0,0 +1,53 @@ +; --------------------------------------------------------------------------- +; write.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.import popax, popptr1 +.importzp ptr1, ptr2, ptr3, tmp1 + +.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 #$0A + bne next + lda #$0D ; If it is LF, add CR + jsr OUTCHR + +next: inc ptr1 + bne begin + inc ptr1+1 + jmp begin + +done: lda ptr3 + ldx ptr3+1 + rts ; Return count +; --------------------------------------------------------------------------- +.endproc + diff --git a/samples/symDisplay.c b/samples/symDisplay.c new file mode 100644 index 000000000..41eaf8b49 --- /dev/null +++ b/samples/symDisplay.c @@ -0,0 +1,384 @@ +// -------------------------------------------------------------------------- +// Sym-1 front panel display example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include + +void 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 != '\r') && (i < 41) ) { + c = getchar(); + putchar( c ); + 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(); + putchar( c ); + 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 + + + set_D0( DISP_SPACE ); // Clear the display + set_D1( DISP_SPACE ); + set_D2( DISP_SPACE ); + set_D3( DISP_SPACE ); + set_D4( DISP_SPACE ); + set_D5( DISP_SPACE ); + set_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 + set_D6( DISP_1 ); // one at a time + break; + case '2': + set_D6( DISP_2 ); + break; + case '3': + set_D6( DISP_3 ); + break; + case '4': + set_D6( DISP_4 ); + break; + case '5': + set_D6( DISP_5 ); + break; + case '6': + set_D6( DISP_6 ); + break; + case '7': + set_D6( DISP_7 ); + break; + case '8': + set_D6( DISP_8 ); + break; + case '9': + set_D6( DISP_9 ); + break; + case '0': + set_D6( DISP_0 ); + break; + case 'A': + set_D6( DISP_A ); + break; + case 'a': + set_D6( DISP_A ); + break; + case 'B': + set_D6( DISP_b ); + break; + case 'b': + set_D6( DISP_b ); + break; + case 'C': + set_D6( DISP_C ); + break; + case 'c': + set_D6( DISP_c ); + break; + case 'D': + set_D6( DISP_d ); + break; + case 'd': + set_D6( DISP_d ); + break; + case 'E': + set_D6( DISP_E ); + break; + case 'e': + set_D6( DISP_e ); + break; + case 'F': + set_D6( DISP_F ); + break; + case 'f': + set_D6( DISP_F ); + break; + case 'G': + set_D6( DISP_G ); + break; + case 'g': + set_D6( DISP_g ); + break; + case 'H': + set_D6( DISP_H ); + break; + case 'h': + set_D6( DISP_h ); + break; + case 'I': + set_D6( DISP_I ); + break; + case 'i': + set_D6( DISP_i ); + break; + case 'J': + set_D6( DISP_J ); + break; + case 'j': + set_D6( DISP_J ); + break; + case 'K': + set_D6( DISP_K ); + break; + case 'k': + set_D6( DISP_K ); + break; + case 'L': + set_D6( DISP_L ); + break; + case 'l': + set_D6( DISP_L ); + break; + case 'M': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_M_2 ); + break; + case 'm': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_M_2 ); + break; + case 'N': + set_D6( DISP_n ); + break; + case 'n': + set_D6( DISP_n ); + break; + case 'O': + set_D6( DISP_O ); + break; + case 'o': + set_D6( DISP_o ); + break; + case 'P': + set_D6( DISP_P ); + break; + case 'p': + set_D6( DISP_P ); + break; + case 'Q': + set_D6( DISP_q ); + break; + case 'q': + set_D6( DISP_q ); + break; + case 'R': + set_D6( DISP_r ); + break; + case 'r': + set_D6( DISP_r ); + break; + case 'S': + set_D6( DISP_S ); + break; + case 's': + set_D6( DISP_S ); + break; + case 'T': + set_D6( DISP_t ); + break; + case 't': + set_D6( DISP_t ); + break; + case 'U': + set_D6( DISP_U ); + break; + case 'u': + set_D6( DISP_u ); + break; + case 'V': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_V_2 ); + break; + case 'v': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_V_2 ); + break; + case 'W': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_W_2 ); + break; + case 'w': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_W_2 ); + break; + case 'Y': + set_D6( DISP_Y ); + break; + case 'y': + set_D6( DISP_Y ); + break; + case 'Z': + set_D6( DISP_Z ); + break; + case 'z': + set_D6( DISP_Z ); + break; + case ' ': + set_D6( DISP_SPACE ); + break; + case '.': + set_D6( DISP_PERIOD ); + break; + case '-': + set_D6( DISP_HYPHEN ); + break; + case '\'': + set_D6( DISP_APOSTR ); + break; + case '"': + set_D6( DISP_APOSTR ); + break; + case '=': + set_D6( DISP_EQUAL ); + break; + case '_': + set_D6( DISP_BOTTOM ); + break; + case '/': + set_D6( DISP_SLASH ); + break; + case '\\': + set_D6( DISP_BACKSLASH ); + break; + default: + displayable = 0; // Character not mapped + } + + if( displayable ) { + + putchar( buffer[l] ); // Send it to the console + + set_D0( get_D1() ); // Scroll to the left + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + } + } + + for( e = 0; e < 6; e++ ) { // Gradually fill the + set_D0( get_D1() ); // display with spaces + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( DISP_SPACE ); + set_D6( DISP_SPACE ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + } + } + + puts( "\n\nEnjoy your day!\n\n" ); + + return; +} diff --git a/samples/symHello.c b/samples/symHello.c new file mode 100644 index 000000000..99b4c57df --- /dev/null +++ b/samples/symHello.c @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------- +// Hello World for Sym-1 +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; + +void 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 != '\r' ) { + c = getchar(); + putchar( c ); + } + + printf( "\n\nThanks!\n\n" ); + + for( l = 0; l < 5; l++ ) { + beep(); + for( d = 0; d < 10 ; d++ ) { + } + } + + return; +} diff --git a/samples/symIO.c b/samples/symIO.c new file mode 100644 index 000000000..c52a71b11 --- /dev/null +++ b/samples/symIO.c @@ -0,0 +1,170 @@ +// -------------------------------------------------------------------------- +// Sym-1 digital I/O interface example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; +#include ; +#include ; +#include ; + +void main(void) { + int ddr1a = 0x00; + int ior1a = 0x00; + int ddr1b = 0x00; + int ior1b = 0x00; + int ddr2a = 0x00; + int ior2a = 0x00; + int ddr2b = 0x00; + int ior2b = 0x00; + int ddr3a = 0x00; + int ior3a = 0x00; + int ddr3b = 0x00; + int ior3b = 0x00; + int l = 0x00; + int val = 0x00; + int going = 0x01; + int instr = 0x01; + char* vp = 0x00; + char cmd[20] = { 0x00 }; + + while( going ) { + + putchar( '\r' ); + for( l = 0; l < 25; l++ ) { + putchar( '\n' ); + } + + ddr1a = get_DDR1A(); + ior1a = get_IOR1A(); + ddr1b = get_DDR1B(); + ior1b = get_IOR1B(); + ddr2a = get_DDR2A(); + ior2a = get_IOR2A(); + ddr2b = get_DDR2B(); + ior2b = get_IOR2B(); + ddr3a = get_DDR3A(); + ior3a = get_IOR3A(); + ddr3b = get_DDR3B(); + ior3b = get_IOR3B(); + + 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 'stop' 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, "stop", 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 = atoi( vp ); + set_DDR1A( val ); + } + } + else if( strncasecmp(cmd, "ior1a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR1A( val ); + } + } + else if( strncasecmp(cmd, "ddr1b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR1B( val ); + } + } + else if( strncasecmp(cmd, "ior1b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR1B( val ); + } + } + else if( strncasecmp(cmd, "ddr2a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR2A( val ); + } + } + else if( strncasecmp(cmd, "ior2a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR2A( val ); + } + } + else if( strncasecmp(cmd, "ddr2b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR2B( val ); + } + } + else if( strncasecmp(cmd, "ior2b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR2B( val ); + } + } + else if( strncasecmp(cmd, "ddr3a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR3A( val ); + } + } + else if( strncasecmp(cmd, "ior3a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR3A( val ); + } + } + else if( strncasecmp(cmd, "ddr3b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR3B( val ); + } + } + else if( strncasecmp(cmd, "ior3b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR3B( val ); + } + } + } + + return; +} diff --git a/samples/symTiny.c b/samples/symTiny.c new file mode 100644 index 000000000..b82e952ac --- /dev/null +++ b/samples/symTiny.c @@ -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 ; + +void 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 != '\r' ) { + c = getchar(); + putchar( c ); + } + + puts( "\n\nThanks!\n" ); + + for( l = 0; l < 5; l++ ) { + beep(); + for( d = 0; d < 10 ; d++ ) { + } + } + + return; +} diff --git a/samples/tutorial/sym1/build b/samples/tutorial/sym1/build new file mode 100644 index 000000000..6688da0a3 --- /dev/null +++ b/samples/tutorial/sym1/build @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# build.sh + +if [ -f $1.c ]; then + echo + echo "--- Building $1 ---" + + if [ -f $1.s ]; then + rm $1.s + fi + if [ -f $1.o ]; then + rm $1.o + fi + if [ -f $1.bin ]; then + rm $1.bin + fi + if [ -f $1.hex ]; then + rm $1.hex + fi + + cc65 -t sym1 -O $1.c + ca65 $1.s + ld65 -C sym1.cfg -m $1.map -o $1.bin $1.o sym1.lib + if [ -f $1.bin ]; then + bin2hex $1.bin $1.hex > /dev/null 2>&1 + fi + if [ -f $1.hex ]; then + echo "--- $1.hex made ---" + else + echo "--- $1.hex FAIL ---" + fi + + +fi + diff --git a/samples/tutorial/sym1/build_32k b/samples/tutorial/sym1/build_32k new file mode 100644 index 000000000..555bda0b4 --- /dev/null +++ b/samples/tutorial/sym1/build_32k @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# build.sh + +if [ -f $1.c ]; then + echo + echo "--- Building $1 ---" + + if [ -f $1.s ]; then + rm $1.s + fi + if [ -f $1.o ]; then + rm $1.o + fi + if [ -f $1.bin ]; then + rm $1.bin + fi + if [ -f $1.hex ]; then + rm $1.hex + fi + + cc65 -t sym1 -O $1.c + ca65 $1.s + ld65 -C sym1-32k.cfg -m $1.map -o $1.bin $1.o sym1.lib + if [ -f $1.bin ]; then + bin2hex $1.bin $1.hex > /dev/null 2>&1 + fi + if [ -f $1.hex ]; then + echo "--- $1.hex made ---" + else + echo "--- $1.hex FAIL ---" + fi + + +fi + diff --git a/samples/tutorial/sym1/build_4k b/samples/tutorial/sym1/build_4k new file mode 100644 index 000000000..502bb6aa9 --- /dev/null +++ b/samples/tutorial/sym1/build_4k @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# build.sh + +if [ -f $1.c ]; then + echo + echo "--- Building $1 ---" + + if [ -f $1.s ]; then + rm $1.s + fi + if [ -f $1.o ]; then + rm $1.o + fi + if [ -f $1.bin ]; then + rm $1.bin + fi + if [ -f $1.hex ]; then + rm $1.hex + fi + + cc65 -t sym1 -O $1.c + ca65 $1.s + ld65 -C sym1-4k.cfg -m $1.map -o $1.bin $1.o sym1.lib + if [ -f $1.bin ]; then + bin2hex $1.bin $1.hex > /dev/null 2>&1 + fi + if [ -f $1.hex ]; then + echo "--- $1.hex made ---" + else + echo "--- $1.hex FAIL ---" + fi + + +fi + diff --git a/samples/tutorial/sym1/clean b/samples/tutorial/sym1/clean new file mode 100644 index 000000000..c0d77390e --- /dev/null +++ b/samples/tutorial/sym1/clean @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# +# clean.sh + +if [ -f $1.c ]; then + echo + echo "--- Cleaning $1 ---" + + rm $1.s $1.o $1.map $1.bin $1.hex > /dev/null 2>&1 + + echo "--- Cleaned $1 ---" + +fi + diff --git a/samples/tutorial/sym1/readme.txt b/samples/tutorial/sym1/readme.txt new file mode 100644 index 000000000..74bcb5527 --- /dev/null +++ b/samples/tutorial/sym1/readme.txt @@ -0,0 +1,11 @@ +These simple build scripts can be used to build any single-file C program +you might write. Notice the diference in the linker line for the 4k build +compared with the 32k build. Small programs can be compiled with either +build script, but they won't run on a 4k machine if compiled for a 32k +system. So if you have a program that's small enough to fit in 4k, it is +probably better to build with the 4k script so it will run on Sym-1 machines +that do not have an expansion memory board. + +Usage: build (don't include the .c extension) + clean (removes intermediate and output files) + diff --git a/samples/tutorial/sym1/symDisplay.c b/samples/tutorial/sym1/symDisplay.c new file mode 100644 index 000000000..41eaf8b49 --- /dev/null +++ b/samples/tutorial/sym1/symDisplay.c @@ -0,0 +1,384 @@ +// -------------------------------------------------------------------------- +// Sym-1 front panel display example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include + +void 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 != '\r') && (i < 41) ) { + c = getchar(); + putchar( c ); + 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(); + putchar( c ); + 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 + + + set_D0( DISP_SPACE ); // Clear the display + set_D1( DISP_SPACE ); + set_D2( DISP_SPACE ); + set_D3( DISP_SPACE ); + set_D4( DISP_SPACE ); + set_D5( DISP_SPACE ); + set_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 + set_D6( DISP_1 ); // one at a time + break; + case '2': + set_D6( DISP_2 ); + break; + case '3': + set_D6( DISP_3 ); + break; + case '4': + set_D6( DISP_4 ); + break; + case '5': + set_D6( DISP_5 ); + break; + case '6': + set_D6( DISP_6 ); + break; + case '7': + set_D6( DISP_7 ); + break; + case '8': + set_D6( DISP_8 ); + break; + case '9': + set_D6( DISP_9 ); + break; + case '0': + set_D6( DISP_0 ); + break; + case 'A': + set_D6( DISP_A ); + break; + case 'a': + set_D6( DISP_A ); + break; + case 'B': + set_D6( DISP_b ); + break; + case 'b': + set_D6( DISP_b ); + break; + case 'C': + set_D6( DISP_C ); + break; + case 'c': + set_D6( DISP_c ); + break; + case 'D': + set_D6( DISP_d ); + break; + case 'd': + set_D6( DISP_d ); + break; + case 'E': + set_D6( DISP_E ); + break; + case 'e': + set_D6( DISP_e ); + break; + case 'F': + set_D6( DISP_F ); + break; + case 'f': + set_D6( DISP_F ); + break; + case 'G': + set_D6( DISP_G ); + break; + case 'g': + set_D6( DISP_g ); + break; + case 'H': + set_D6( DISP_H ); + break; + case 'h': + set_D6( DISP_h ); + break; + case 'I': + set_D6( DISP_I ); + break; + case 'i': + set_D6( DISP_i ); + break; + case 'J': + set_D6( DISP_J ); + break; + case 'j': + set_D6( DISP_J ); + break; + case 'K': + set_D6( DISP_K ); + break; + case 'k': + set_D6( DISP_K ); + break; + case 'L': + set_D6( DISP_L ); + break; + case 'l': + set_D6( DISP_L ); + break; + case 'M': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_M_2 ); + break; + case 'm': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_M_2 ); + break; + case 'N': + set_D6( DISP_n ); + break; + case 'n': + set_D6( DISP_n ); + break; + case 'O': + set_D6( DISP_O ); + break; + case 'o': + set_D6( DISP_o ); + break; + case 'P': + set_D6( DISP_P ); + break; + case 'p': + set_D6( DISP_P ); + break; + case 'Q': + set_D6( DISP_q ); + break; + case 'q': + set_D6( DISP_q ); + break; + case 'R': + set_D6( DISP_r ); + break; + case 'r': + set_D6( DISP_r ); + break; + case 'S': + set_D6( DISP_S ); + break; + case 's': + set_D6( DISP_S ); + break; + case 'T': + set_D6( DISP_t ); + break; + case 't': + set_D6( DISP_t ); + break; + case 'U': + set_D6( DISP_U ); + break; + case 'u': + set_D6( DISP_u ); + break; + case 'V': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_V_2 ); + break; + case 'v': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_V_2 ); + break; + case 'W': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_W_2 ); + break; + case 'w': + set_D0( get_D1() ); + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + set_D6( DISP_W_2 ); + break; + case 'Y': + set_D6( DISP_Y ); + break; + case 'y': + set_D6( DISP_Y ); + break; + case 'Z': + set_D6( DISP_Z ); + break; + case 'z': + set_D6( DISP_Z ); + break; + case ' ': + set_D6( DISP_SPACE ); + break; + case '.': + set_D6( DISP_PERIOD ); + break; + case '-': + set_D6( DISP_HYPHEN ); + break; + case '\'': + set_D6( DISP_APOSTR ); + break; + case '"': + set_D6( DISP_APOSTR ); + break; + case '=': + set_D6( DISP_EQUAL ); + break; + case '_': + set_D6( DISP_BOTTOM ); + break; + case '/': + set_D6( DISP_SLASH ); + break; + case '\\': + set_D6( DISP_BACKSLASH ); + break; + default: + displayable = 0; // Character not mapped + } + + if( displayable ) { + + putchar( buffer[l] ); // Send it to the console + + set_D0( get_D1() ); // Scroll to the left + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( get_D6() ); + + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + } + } + + for( e = 0; e < 6; e++ ) { // Gradually fill the + set_D0( get_D1() ); // display with spaces + set_D1( get_D2() ); + set_D2( get_D3() ); + set_D3( get_D4() ); + set_D4( get_D5() ); + set_D5( DISP_SPACE ); + set_D6( DISP_SPACE ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + } + } + + puts( "\n\nEnjoy your day!\n\n" ); + + return; +} diff --git a/samples/tutorial/sym1/symHello.c b/samples/tutorial/sym1/symHello.c new file mode 100644 index 000000000..99b4c57df --- /dev/null +++ b/samples/tutorial/sym1/symHello.c @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------- +// Hello World for Sym-1 +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; + +void 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 != '\r' ) { + c = getchar(); + putchar( c ); + } + + printf( "\n\nThanks!\n\n" ); + + for( l = 0; l < 5; l++ ) { + beep(); + for( d = 0; d < 10 ; d++ ) { + } + } + + return; +} diff --git a/samples/tutorial/sym1/symIO.c b/samples/tutorial/sym1/symIO.c new file mode 100644 index 000000000..c52a71b11 --- /dev/null +++ b/samples/tutorial/sym1/symIO.c @@ -0,0 +1,170 @@ +// -------------------------------------------------------------------------- +// Sym-1 digital I/O interface example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; +#include ; +#include ; +#include ; + +void main(void) { + int ddr1a = 0x00; + int ior1a = 0x00; + int ddr1b = 0x00; + int ior1b = 0x00; + int ddr2a = 0x00; + int ior2a = 0x00; + int ddr2b = 0x00; + int ior2b = 0x00; + int ddr3a = 0x00; + int ior3a = 0x00; + int ddr3b = 0x00; + int ior3b = 0x00; + int l = 0x00; + int val = 0x00; + int going = 0x01; + int instr = 0x01; + char* vp = 0x00; + char cmd[20] = { 0x00 }; + + while( going ) { + + putchar( '\r' ); + for( l = 0; l < 25; l++ ) { + putchar( '\n' ); + } + + ddr1a = get_DDR1A(); + ior1a = get_IOR1A(); + ddr1b = get_DDR1B(); + ior1b = get_IOR1B(); + ddr2a = get_DDR2A(); + ior2a = get_IOR2A(); + ddr2b = get_DDR2B(); + ior2b = get_IOR2B(); + ddr3a = get_DDR3A(); + ior3a = get_IOR3A(); + ddr3b = get_DDR3B(); + ior3b = get_IOR3B(); + + 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 'stop' 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, "stop", 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 = atoi( vp ); + set_DDR1A( val ); + } + } + else if( strncasecmp(cmd, "ior1a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR1A( val ); + } + } + else if( strncasecmp(cmd, "ddr1b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR1B( val ); + } + } + else if( strncasecmp(cmd, "ior1b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR1B( val ); + } + } + else if( strncasecmp(cmd, "ddr2a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR2A( val ); + } + } + else if( strncasecmp(cmd, "ior2a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR2A( val ); + } + } + else if( strncasecmp(cmd, "ddr2b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR2B( val ); + } + } + else if( strncasecmp(cmd, "ior2b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR2B( val ); + } + } + else if( strncasecmp(cmd, "ddr3a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR3A( val ); + } + } + else if( strncasecmp(cmd, "ior3a", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR3A( val ); + } + } + else if( strncasecmp(cmd, "ddr3b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_DDR3B( val ); + } + } + else if( strncasecmp(cmd, "ior3b", 5) == 0) { + vp = strchr(cmd, ' '); + if( vp ) { + val = atoi( vp ); + set_IOR3B( val ); + } + } + } + + return; +} diff --git a/samples/tutorial/sym1/symTiny.c b/samples/tutorial/sym1/symTiny.c new file mode 100644 index 000000000..b82e952ac --- /dev/null +++ b/samples/tutorial/sym1/symTiny.c @@ -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 ; + +void 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 != '\r' ) { + c = getchar(); + putchar( c ); + } + + puts( "\n\nThanks!\n" ); + + for( l = 0; l < 5; l++ ) { + beep(); + for( d = 0; d < 10 ; d++ ) { + } + } + + return; +} From 044a0838a377fe17559a308bbb10ca21374e4ca1 Mon Sep 17 00:00:00 2001 From: Wayne Parham Date: Sun, 9 May 2021 16:51:17 -0500 Subject: [PATCH 02/47] Changes to existing cc65 source to support Synertek Systems Sym-1 --- README.md | 1 + libsrc/Makefile | 49 +++++++++++++++++++++++++++++++-------------- samples/Makefile | 30 ++++++++++++++++++++------- src/cc65/main.c | 3 +++ src/common/target.c | 2 ++ src/common/target.h | 1 + 6 files changed, 64 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 2c84b7430..c1b8a8b59 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ including - the Lynx console. - the Ohio Scientific Challenger 1P. - the Commander X16. +- the Synertek Syetms Sym-1. The libraries are fairly portable, so creating a version for other 6502s shouldn't be too much work. diff --git a/libsrc/Makefile b/libsrc/Makefile index 3fac513af..eee18d0da 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -34,6 +34,7 @@ TARGETS = apple2 \ sim6502 \ sim65c02 \ supervision \ + sym1 \ telestrat DRVTYPES = emd \ @@ -148,18 +149,26 @@ GEOSDIRS = common \ runtime \ system +# MACHINE set independently of TARGET lets us easily define new targets +# without changing target.h and target.c in cc65/src/common. Useful +# for initial testing of ports to new systems. + ifeq ($(TARGET),apple2enh) SRCDIR = apple2 OBJPFX = a2 DRVPFX = a2e + MACHINE = $(TARGET) else ifeq ($(TARGET),atarixl) SRCDIR = atari OBJPFX = atr DRVPFX = atrx + MACHINE = $(TARGET) else ifeq ($(TARGET),sim65c02) SRCDIR = sim6502 + MACHINE = $(TARGET) else SRCDIR = $(TARGET) + MACHINE = $(TARGET) endif SRCDIRS = $(SRCDIR) @@ -173,16 +182,26 @@ ifeq ($(TARGET),$(filter $(TARGET),$(GEOS))) SRCDIRS += $(addprefix geos-common/,$(GEOSDIRS)) endif -SRCDIRS += common \ - conio \ - dbg \ - em \ - joystick \ - mouse \ - runtime \ - serial \ - tgi \ - zlib +ifeq ($(TARGET),sym1) + SRCDIRS += common \ + conio \ + dbg \ + em \ + runtime \ + serial \ + sym1 +else + SRCDIRS += common \ + conio \ + dbg \ + em \ + joystick \ + mouse \ + runtime \ + serial \ + tgi \ + zlib +endif vpath %.s $(SRCDIRS) vpath %.c $(SRCDIRS) @@ -231,7 +250,7 @@ $1_DRVS = $$(patsubst $$($1_DYNPAT),$$($1_DRVPAT),$$($1_DYNS)) $$($1_STCPAT): $$($1_SRCPAT) @echo $$(TARGET) - $$< - static - @$$(CA65) -t $$(TARGET) -D DYN_DRV=0 $$(CA65FLAGS) --create-dep $$(@:.o=.d) -o $$@ $$< + @$$(CA65) -t $$(MACHINE) -D DYN_DRV=0 $$(CA65FLAGS) --create-dep $$(@:.o=.d) -o $$@ $$< OBJS += $$($1_STCS) DEPS += $$($1_STCS:.o=.d) @@ -263,15 +282,15 @@ export CC65_HOME := $(abspath ..) define ASSEMBLE_recipe $(if $(QUIET),,@echo $(TARGET) - $<) -@$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:.o=.d) -o $@ $< +@$(CA65) -t $(MACHINE) $(CA65FLAGS) --create-dep $(@:.o=.d) -o $@ $< endef # ASSEMBLE_recipe define COMPILE_recipe $(if $(QUIET),,@echo $(TARGET) - $<) -@$(CC65) -t $(TARGET) $(CC65FLAGS) --create-dep $(@:.o=.d) --dep-target $@ -o $(@:.o=.s) $< -@$(CA65) -t $(TARGET) -o $@ $(@:.o=.s) +@$(CC65) -t $(MACHINE) $(CC65FLAGS) --create-dep $(@:.o=.d) --dep-target $@ -o $(@:.o=.s) $< +@$(CA65) -t $(MACHINE) -o $@ $(@:.o=.s) endef # COMPILE_recipe @@ -283,7 +302,7 @@ endef # COMPILE_recipe $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib @echo $(TARGET) - $($(NULLDEV) + @$(DEL) *.lbl *.map *.bin *.hex *.o *.s 2>$(NULLDEV) clean: mostlyclean @$(DEL) $(EXELIST_$(SYS)) $(DISK_$(SYS)) 2>$(NULLDEV) @$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV) - $(foreach dir,$(DIRLIST),$(SUBDIR_recipe)) + @$(foreach dir,$(DIRLIST),$(SUBDIR_recipe)) + diff --git a/src/cc65/main.c b/src/cc65/main.c index 0b156fb74..9e9fab6b4 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -290,6 +290,9 @@ static void SetSys (const char* Sys) cbmsys ("__CX16__"); break; + case TGT_NONE: + break; + default: AbEnd ("Unknown target system type %d", Target); } diff --git a/src/common/target.c b/src/common/target.c index a21ef2125..a35bf67a8 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -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 */ diff --git a/src/common/target.h b/src/common/target.h index 50c400e2e..7f85713cf 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -85,6 +85,7 @@ typedef enum { TGT_GAMATE, TGT_C65, TGT_CX16, + TGT_SYM1, TGT_COUNT /* Number of target systems */ } target_t; From aea5db48cbc9207b5d947f0483f6f65e2ea2c31e Mon Sep 17 00:00:00 2001 From: Wayne Parham Date: Sun, 9 May 2021 16:55:17 -0500 Subject: [PATCH 03/47] fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1b8a8b59..76b4cfcac 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ including - the Lynx console. - the Ohio Scientific Challenger 1P. - the Commander X16. -- the Synertek Syetms Sym-1. +- the Synertek Systems Sym-1. The libraries are fairly portable, so creating a version for other 6502s shouldn't be too much work. From f81aefe8bdc0b113bfb1d2ac7e5c7d8a40c33778 Mon Sep 17 00:00:00 2001 From: Wayne Parham Date: Sun, 9 May 2021 17:13:24 -0500 Subject: [PATCH 04/47] Synertek Systems Sym-1 config files --- asminc/sym1.inc | 186 +++++++++++++++++++++++++++++++++++++++++++ cfg/sym1-32k.cfg | 46 +++++++++++ cfg/sym1-4k.cfg | 46 +++++++++++ cfg/sym1.cfg | 46 +++++++++++ doc/sym1.sgml | 135 +++++++++++++++++++++++++++++++ include/symio.h | 148 ++++++++++++++++++++++++++++++++++ samples/helloworld.c | 9 +++ src/ca65/main.c | 3 + 8 files changed, 619 insertions(+) create mode 100644 asminc/sym1.inc create mode 100644 cfg/sym1-32k.cfg create mode 100644 cfg/sym1-4k.cfg create mode 100644 cfg/sym1.cfg create mode 100644 doc/sym1.sgml create mode 100644 include/symio.h create mode 100644 samples/helloworld.c diff --git a/asminc/sym1.inc b/asminc/sym1.inc new file mode 100644 index 000000000..b6a6f17fe --- /dev/null +++ b/asminc/sym1.inc @@ -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 ; diff --git a/cfg/sym1-32k.cfg b/cfg/sym1-32k.cfg new file mode 100644 index 000000000..14ddfb98f --- /dev/null +++ b/cfg/sym1-32k.cfg @@ -0,0 +1,46 @@ +# sym1-32k.cfg (32k) +# +# for Sym-1 with 32kb RAM +# +# ld65 --config sym1-32k.cfg -o .bin .o + +FEATURES { + STARTADDRESS: default = $0200; + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + __STACKSIZE__: type = weak, value = $0200; # 512 byte program stack + __STARTADDRESS__: type = export, value = %S; +} + +MEMORY { + ZP: start = $0000, size = $00F7, define = yes, file = %O; + CPUSTACK: start = $0100, size = $0100, define = yes; + RAM: start = %S, size = $8000 - %S - __STACKSIZE__, define = yes, file = %O; + MONROM: start = $8000, size = $1000, define = yes; + EXT: start = $9000, size = $1000, define = yes; + IO: start = $A000, size = $1000, define = yes; + RAE1: start = $B000, size = $1000, define = yes; + BASROM: start = $C000, size = $1000, define = yes; + RAE2: start = $E000, size = $1000, define = yes; + TOP: start = $F000, size = $1000, define = yes; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; +} + diff --git a/cfg/sym1-4k.cfg b/cfg/sym1-4k.cfg new file mode 100644 index 000000000..240d7bc82 --- /dev/null +++ b/cfg/sym1-4k.cfg @@ -0,0 +1,46 @@ +# sym1-4k.cfg (4k) +# +# for Sym-1 with 4kb RAM +# +# ld65 --config sym1-4k.cfg -o .bin .o + +FEATURES { + STARTADDRESS: default = $0200; + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack + __STARTADDRESS__: type = export, value = %S; +} + +MEMORY { + ZP: start = $0000, size = $00F7, define = yes, file = %O; + CPUSTACK: start = $0100, size = $0100, define = yes; + RAM: start = %S, size = $1000 - %S - __STACKSIZE__, define = yes, file = %O; + MONROM: start = $8000, size = $1000, define = yes; + EXT: start = $9000, size = $1000, define = yes; + IO: start = $A000, size = $1000, define = yes; + RAE1: start = $B000, size = $1000, define = yes; + BASROM: start = $C000, size = $1000, define = yes; + RAE2: start = $E000, size = $1000, define = yes; + TOP: start = $F000, size = $1000, define = yes; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; +} + diff --git a/cfg/sym1.cfg b/cfg/sym1.cfg new file mode 100644 index 000000000..240d7bc82 --- /dev/null +++ b/cfg/sym1.cfg @@ -0,0 +1,46 @@ +# sym1-4k.cfg (4k) +# +# for Sym-1 with 4kb RAM +# +# ld65 --config sym1-4k.cfg -o .bin .o + +FEATURES { + STARTADDRESS: default = $0200; + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack + __STARTADDRESS__: type = export, value = %S; +} + +MEMORY { + ZP: start = $0000, size = $00F7, define = yes, file = %O; + CPUSTACK: start = $0100, size = $0100, define = yes; + RAM: start = %S, size = $1000 - %S - __STACKSIZE__, define = yes, file = %O; + MONROM: start = $8000, size = $1000, define = yes; + EXT: start = $9000, size = $1000, define = yes; + IO: start = $A000, size = $1000, define = yes; + RAE1: start = $B000, size = $1000, define = yes; + BASROM: start = $C000, size = $1000, define = yes; + RAE2: start = $E000, size = $1000, define = yes; + TOP: start = $F000, size = $1000, define = yes; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; +} + diff --git a/doc/sym1.sgml b/doc/sym1.sgml new file mode 100644 index 000000000..d02e3b1b1 --- /dev/null +++ b/doc/sym1.sgml @@ -0,0 +1,135 @@ + + +
+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 standard binary output format generated by the linker for the Sym-1 target is a 4 kbyte machine language program. It is, of course, possible to change this behavior by using one of the different linker configs. + +<p> + +Included with this distribution is a 4k configuration file and a 32k config file. The Sym-1 on-board memory is limited to 4k 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 $200 - $0FFF. The 32k config expands this range to $7FFF. The starting memory location and entry point for running the program is $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 $0FFF on 4kb Syms, or at $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/symio.h/ header file. See the header file for more information. + +<sect1>Hardware access<p> + +The following 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 "master console" 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>symio.h<p> +You can use stdio.h if you wish, which provides console I/O (like printf) but does not have access to a filesystem, as mentioned above. + +But there is another header available, which exposes Sym-specific I/O functions that are useful for reading and writing its ports and front panel. It also exposes functions normally included using stdio.h but <i>only</i> the console I/O functions and not the filesystem functions. See the symio.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_32k configuration - then you may want to use functions like getchar, putchar, gets and puts rather than printf. Printf 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 "stock" 4k Sym-1, except for symio.c, which requires 8k. Information on building and running it is in the samples/tutorial/sym1 directory. + +<itemize> +<item>helloworld is the traditional "Hello World!" program, using printf().</item> +<item>symHello prints "Hello World!" and then inputs characters, which are echoed on the screen. It also makes a "beep" 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> +</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> diff --git a/include/symio.h b/include/symio.h new file mode 100644 index 000000000..bd90a42f9 --- /dev/null +++ b/include/symio.h @@ -0,0 +1,148 @@ +// symio.h +// +// I/O primitives for Sym-1 +// +// Wayne Parham + +#ifndef _SYMIO_H +#define _SYMIO_H + +#include <stddef.h> +#include <stdarg.h> + +int __fastcall__ beep (void); // Beep sound +int __fastcall__ set_D0 (char); // Set display digit 0 +int __fastcall__ get_D0 (void); // Get value of display digit 0 +int __fastcall__ set_D1 (char); // Set display digit 1 +int __fastcall__ get_D1 (void); // Get value of display digit 1 +int __fastcall__ set_D2 (char); // Set display digit 2 +int __fastcall__ get_D2 (void); // Get value of display digit 2 +int __fastcall__ set_D3 (char); // Set display digit 3 +int __fastcall__ get_D3 (void); // Get value of display digit 3 +int __fastcall__ set_D4 (char); // Set display digit 4 +int __fastcall__ get_D4 (void); // Get value of display digit 4 +int __fastcall__ set_D5 (char); // Set display digit 5 +int __fastcall__ get_D5 (void); // Get value of display digit 5 +int __fastcall__ set_D6 (char); // Set byte to the right of display (leading buffer) +int __fastcall__ get_D6 (void); // Get value of memory byte to the right of display +int __fastcall__ fdisp (void); // Flash display + +int __fastcall__ loadt (int); // Read from tape (id) +int __fastcall__ dumpt (int, int, int); // Write to tape (id, start_addr, end_addr) + +int __fastcall__ set_DDR1A (int); // Set data direction register 1A (U25) +int __fastcall__ get_DDR1A (void); // Get value of data direction register 1A +int __fastcall__ set_IOR1A (int); // Set I/O register 1A +int __fastcall__ get_IOR1A (void); // Get value of I/O register 1A + +int __fastcall__ set_DDR1B (int); // Set data direction register 1B (U25) +int __fastcall__ get_DDR1B (void); // Get value of data direction register 1B +int __fastcall__ set_IOR1B (int); // Set I/O register 1B +int __fastcall__ get_IOR1B (void); // Get value of I/O register 1B + +int __fastcall__ set_DDR2A (int); // Set data direction register 2A (U28) +int __fastcall__ get_DDR2A (void); // Get value of data direction register 2A +int __fastcall__ set_IOR2A (int); // Set I/O register 2A +int __fastcall__ get_IOR2A (void); // Get value of I/O register 2A + +int __fastcall__ set_DDR2B (int); // Set data direction register 2B (U28) +int __fastcall__ get_DDR2B (void); // Get value of data direction register 2B +int __fastcall__ set_IOR2B (int); // Set I/O register 2B +int __fastcall__ get_IOR2B (void); // Get value of I/O register 2B + +int __fastcall__ set_DDR3A (int); // Set data direction register 3A (U29) +int __fastcall__ get_DDR3A (void); // Get value of data direction register 3A +int __fastcall__ set_IOR3A (int); // Set I/O register 3A +int __fastcall__ get_IOR3A (void); // Get value of I/O register 3A + +int __fastcall__ set_DDR3B (int); // Set data direction register 3B (U29) +int __fastcall__ get_DDR3B (void); // Get value of data direction register 3B +int __fastcall__ set_IOR3B (int); // Set I/O register 3B +int __fastcall__ get_IOR3B (void); // Get value of I/O register 3B + +#ifndef _STDIO_H + +int __fastcall__ putchar (char); +int __fastcall__ puts (const char* s); +int printf (const char* format, ...); +int sprintf (char* buf, const char* format, ...); +int __fastcall__ vprintf (const char* format, va_list ap); +int __fastcall__ vsnprintf (char* buf, size_t size, const char* format, va_list ap); +int __fastcall__ vsprintf (char* buf, const char* format, va_list ap); +char __fastcall__ getchar (void); +char* __fastcall__ gets (char* s); +int scanf (const char* format, ...); +int sscanf (const char* s, const char* format, ...); +int __fastcall__ vscanf (const char* format, va_list ap); +int __fastcall__ vsscanf (const char* s, const char* format, va_list ap); + +#endif + +// 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 0x04 // '_' +#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 + +#endif diff --git a/samples/helloworld.c b/samples/helloworld.c new file mode 100644 index 000000000..057a153e8 --- /dev/null +++ b/samples/helloworld.c @@ -0,0 +1,9 @@ +// Traditional "Hello World" program + +#include <stdio.h> + +void main (void) +{ + printf( "Hello World!\n" ); + return; +} diff --git a/src/ca65/main.c b/src/ca65/main.c index ab19d0b4d..bb0607b7c 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -334,6 +334,9 @@ static void SetSys (const char* Sys) CBMSystem ("__CX16__"); break; + case TGT_SYM1: + break; + default: AbEnd ("Invalid target name: '%s'", Sys); From 27e04b36b0e85cc73bd24f17e4d13417cd7290e2 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 9 May 2021 17:24:15 -0500 Subject: [PATCH 05/47] Makefile updates --- samples/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/Makefile b/samples/Makefile index e3b28057f..8a3edc412 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -8,6 +8,10 @@ # var. to build for another target system. SYS ?= c64 +# New targets can define MACHINE separately +# from target if needed. +MACHINE=$(SYS) + # Just the usual way to define a variable # containing a single space character. SPACE := From a2def19de5dba20f52fcff6eb2cdfa9df899504e Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 10 May 2021 15:20:49 +0100 Subject: [PATCH 06/47] Added TGT_SYM1 --- src/cc65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/main.c b/src/cc65/main.c index 9e9fab6b4..d0d756b3f 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -290,7 +290,7 @@ static void SetSys (const char* Sys) cbmsys ("__CX16__"); break; - case TGT_NONE: + case TGT_SYM1: break; default: From f09ffb2a45e38338348ccd44cb36a5a9de63d614 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 12 May 2021 01:08:13 +0100 Subject: [PATCH 07/47] symNotepad.c --- doc/sym1.sgml | 1 + samples/symNotepad.c | 198 +++++++++++++++++++++++++++++ samples/tutorial/sym1/symNotepad.c | 198 +++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 samples/symNotepad.c create mode 100644 samples/tutorial/sym1/symNotepad.c diff --git a/doc/sym1.sgml b/doc/sym1.sgml index d02e3b1b1..f04f36ae1 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -113,6 +113,7 @@ All the samples will run on the "stock" 4k Sym-1, except for symio.c, <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> diff --git a/samples/symNotepad.c b/samples/symNotepad.c new file mode 100644 index 000000000..e9866e526 --- /dev/null +++ b/samples/symNotepad.c @@ -0,0 +1,198 @@ +// -------------------------------------------------------------------------- +// 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 <symio.h>; +#include <stdlib.h>; +#include <string.h>; + +#define TAPIO_ADDRESS 0xE000 +#define TAPIO_MAX_SIZE 0x0FFF + +void 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', (int) tapio, (int) 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] ); + if( buffer[l] == '\r' ) { + putchar( '\n' ); + } + } + } + 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] ); + if( buffer[l] == '\r' ) { + putchar( '\n' ); + } + } + } + } + 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 == '\r' ) { + putchar( '\n' ); + } + buffer[p] = c; + putchar( c ); + } + p++; + } + } + } + + free( buffer ); + + puts( "\nEnjoy your day!\n" ); + + return; +} diff --git a/samples/tutorial/sym1/symNotepad.c b/samples/tutorial/sym1/symNotepad.c new file mode 100644 index 000000000..e9866e526 --- /dev/null +++ b/samples/tutorial/sym1/symNotepad.c @@ -0,0 +1,198 @@ +// -------------------------------------------------------------------------- +// 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 <symio.h>; +#include <stdlib.h>; +#include <string.h>; + +#define TAPIO_ADDRESS 0xE000 +#define TAPIO_MAX_SIZE 0x0FFF + +void 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', (int) tapio, (int) 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] ); + if( buffer[l] == '\r' ) { + putchar( '\n' ); + } + } + } + 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] ); + if( buffer[l] == '\r' ) { + putchar( '\n' ); + } + } + } + } + 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 == '\r' ) { + putchar( '\n' ); + } + buffer[p] = c; + putchar( c ); + } + p++; + } + } + } + + free( buffer ); + + puts( "\nEnjoy your day!\n" ); + + return; +} From 321bac417845f589492182af522144aa821cb94f Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Thu, 13 May 2021 14:43:16 -0500 Subject: [PATCH 08/47] Remove TAB characters --- cfg/sym1-32k.cfg | 8 ++++---- cfg/sym1-4k.cfg | 8 ++++---- cfg/sym1.cfg | 8 ++++---- samples/symDisplay.c | 19 ++++++++++--------- samples/symIO.c | 2 +- samples/symNotepad.c | 7 ++++--- samples/tutorial/sym1/symDisplay.c | 19 ++++++++++--------- samples/tutorial/sym1/symIO.c | 2 +- samples/tutorial/sym1/symNotepad.c | 7 ++++--- 9 files changed, 42 insertions(+), 38 deletions(-) diff --git a/cfg/sym1-32k.cfg b/cfg/sym1-32k.cfg index 14ddfb98f..0665c8cf2 100644 --- a/cfg/sym1-32k.cfg +++ b/cfg/sym1-32k.cfg @@ -22,10 +22,10 @@ SYMBOLS { } MEMORY { - ZP: start = $0000, size = $00F7, define = yes, file = %O; + ZP: start = $0000, size = $00F7, define = yes, file = %O; CPUSTACK: start = $0100, size = $0100, define = yes; RAM: start = %S, size = $8000 - %S - __STACKSIZE__, define = yes, file = %O; - MONROM: start = $8000, size = $1000, define = yes; + MONROM: start = $8000, size = $1000, define = yes; EXT: start = $9000, size = $1000, define = yes; IO: start = $A000, size = $1000, define = yes; RAE1: start = $B000, size = $1000, define = yes; @@ -35,8 +35,8 @@ MEMORY { } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - STARTUP: load = RAM, type = ro, define = yes; + 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; diff --git a/cfg/sym1-4k.cfg b/cfg/sym1-4k.cfg index 240d7bc82..de1be0b8a 100644 --- a/cfg/sym1-4k.cfg +++ b/cfg/sym1-4k.cfg @@ -22,10 +22,10 @@ SYMBOLS { } MEMORY { - ZP: start = $0000, size = $00F7, define = yes, file = %O; + ZP: start = $0000, size = $00F7, define = yes, file = %O; CPUSTACK: start = $0100, size = $0100, define = yes; RAM: start = %S, size = $1000 - %S - __STACKSIZE__, define = yes, file = %O; - MONROM: start = $8000, size = $1000, define = yes; + MONROM: start = $8000, size = $1000, define = yes; EXT: start = $9000, size = $1000, define = yes; IO: start = $A000, size = $1000, define = yes; RAE1: start = $B000, size = $1000, define = yes; @@ -35,8 +35,8 @@ MEMORY { } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - STARTUP: load = RAM, type = ro, define = yes; + 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; diff --git a/cfg/sym1.cfg b/cfg/sym1.cfg index 240d7bc82..de1be0b8a 100644 --- a/cfg/sym1.cfg +++ b/cfg/sym1.cfg @@ -22,10 +22,10 @@ SYMBOLS { } MEMORY { - ZP: start = $0000, size = $00F7, define = yes, file = %O; + ZP: start = $0000, size = $00F7, define = yes, file = %O; CPUSTACK: start = $0100, size = $0100, define = yes; RAM: start = %S, size = $1000 - %S - __STACKSIZE__, define = yes, file = %O; - MONROM: start = $8000, size = $1000, define = yes; + MONROM: start = $8000, size = $1000, define = yes; EXT: start = $9000, size = $1000, define = yes; IO: start = $A000, size = $1000, define = yes; RAE1: start = $B000, size = $1000, define = yes; @@ -35,8 +35,8 @@ MEMORY { } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - STARTUP: load = RAM, type = ro, define = yes; + 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; diff --git a/samples/symDisplay.c b/samples/symDisplay.c index 41eaf8b49..8a72d5863 100644 --- a/samples/symDisplay.c +++ b/samples/symDisplay.c @@ -43,7 +43,7 @@ void main (void) { 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" ); + puts( "\n\nLook at the front panel.\n" ); } else { puts( "\nWhat?" ); @@ -185,7 +185,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -198,7 +198,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -259,7 +259,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -272,7 +272,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -285,7 +285,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -298,7 +298,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -344,10 +344,10 @@ void main (void) { set_D6( DISP_BACKSLASH ); break; default: - displayable = 0; // Character not mapped + displayable = 0; // Character not mapped } - if( displayable ) { + if( displayable ) { putchar( buffer[l] ); // Send it to the console @@ -382,3 +382,4 @@ void main (void) { return; } + diff --git a/samples/symIO.c b/samples/symIO.c index c52a71b11..d887c18b9 100644 --- a/samples/symIO.c +++ b/samples/symIO.c @@ -66,7 +66,7 @@ void main(void) { puts( "instructions again and type 'stop' to end the program.\n"); puts( "Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A" ); puts( "IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B." ); - instr = 0; + instr = 0; } printf( "\n Command: " ); diff --git a/samples/symNotepad.c b/samples/symNotepad.c index e9866e526..bc28ef4b5 100644 --- a/samples/symNotepad.c +++ b/samples/symNotepad.c @@ -99,21 +99,21 @@ void main(void) { p--; } } - else if( c == 0x13 ) { // Save + 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++; + l++; tapio[l] = 0x00; puts( "Saving to tape." ); error = dumpt( 'N', (int) tapio, (int) tapio+p ); if( error ) { puts( "\nTape error." ); } - else + else { putchar( '\r' ); for( l = 0; l < 25; l++ ) { @@ -196,3 +196,4 @@ void main(void) { return; } + diff --git a/samples/tutorial/sym1/symDisplay.c b/samples/tutorial/sym1/symDisplay.c index 41eaf8b49..8a72d5863 100644 --- a/samples/tutorial/sym1/symDisplay.c +++ b/samples/tutorial/sym1/symDisplay.c @@ -43,7 +43,7 @@ void main (void) { 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" ); + puts( "\n\nLook at the front panel.\n" ); } else { puts( "\nWhat?" ); @@ -185,7 +185,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -198,7 +198,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -259,7 +259,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -272,7 +272,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -285,7 +285,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -298,7 +298,7 @@ void main (void) { set_D3( get_D4() ); set_D4( get_D5() ); set_D5( get_D6() ); - set_D6( DISP_M_1 ); + set_D6( DISP_M_1 ); for( d = 0; d < flashes ; d++ ) { fdisp(); // Display } @@ -344,10 +344,10 @@ void main (void) { set_D6( DISP_BACKSLASH ); break; default: - displayable = 0; // Character not mapped + displayable = 0; // Character not mapped } - if( displayable ) { + if( displayable ) { putchar( buffer[l] ); // Send it to the console @@ -382,3 +382,4 @@ void main (void) { return; } + diff --git a/samples/tutorial/sym1/symIO.c b/samples/tutorial/sym1/symIO.c index c52a71b11..d887c18b9 100644 --- a/samples/tutorial/sym1/symIO.c +++ b/samples/tutorial/sym1/symIO.c @@ -66,7 +66,7 @@ void main(void) { puts( "instructions again and type 'stop' to end the program.\n"); puts( "Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A" ); puts( "IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B." ); - instr = 0; + instr = 0; } printf( "\n Command: " ); diff --git a/samples/tutorial/sym1/symNotepad.c b/samples/tutorial/sym1/symNotepad.c index e9866e526..bc28ef4b5 100644 --- a/samples/tutorial/sym1/symNotepad.c +++ b/samples/tutorial/sym1/symNotepad.c @@ -99,21 +99,21 @@ void main(void) { p--; } } - else if( c == 0x13 ) { // Save + 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++; + l++; tapio[l] = 0x00; puts( "Saving to tape." ); error = dumpt( 'N', (int) tapio, (int) tapio+p ); if( error ) { puts( "\nTape error." ); } - else + else { putchar( '\r' ); for( l = 0; l < 25; l++ ) { @@ -196,3 +196,4 @@ void main(void) { return; } + From db395e59887fedbc3f690c0e13b076e0c24885a4 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 23 May 2021 13:31:28 -0500 Subject: [PATCH 09/47] Improved sample program symDisplay.c --- samples/symDisplay.c | 41 ++++++------------------------ samples/tutorial/sym1/symDisplay.c | 41 ++++++------------------------ 2 files changed, 16 insertions(+), 66 deletions(-) diff --git a/samples/symDisplay.c b/samples/symDisplay.c index 8a72d5863..fa94ce598 100644 --- a/samples/symDisplay.c +++ b/samples/symDisplay.c @@ -184,12 +184,8 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } - set_D6( DISP_M_2 ); + set_D5( DISP_M_1 ); + set_D6( DISP_M_2 ); break; case 'm': set_D0( get_D1() ); @@ -197,12 +193,8 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } - set_D6( DISP_M_2 ); + set_D5( DISP_M_1 ); + set_D6( DISP_M_2 ); break; case 'N': set_D6( DISP_n ); @@ -258,11 +250,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_V_1 ); set_D6( DISP_V_2 ); break; case 'v': @@ -271,11 +259,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_V_1 ); set_D6( DISP_V_2 ); break; case 'W': @@ -284,11 +268,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_W_1 ); set_D6( DISP_W_2 ); break; case 'w': @@ -297,11 +277,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_W_1 ); set_D6( DISP_W_2 ); break; case 'Y': @@ -382,4 +358,3 @@ void main (void) { return; } - diff --git a/samples/tutorial/sym1/symDisplay.c b/samples/tutorial/sym1/symDisplay.c index 8a72d5863..fa94ce598 100644 --- a/samples/tutorial/sym1/symDisplay.c +++ b/samples/tutorial/sym1/symDisplay.c @@ -184,12 +184,8 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } - set_D6( DISP_M_2 ); + set_D5( DISP_M_1 ); + set_D6( DISP_M_2 ); break; case 'm': set_D0( get_D1() ); @@ -197,12 +193,8 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } - set_D6( DISP_M_2 ); + set_D5( DISP_M_1 ); + set_D6( DISP_M_2 ); break; case 'N': set_D6( DISP_n ); @@ -258,11 +250,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_V_1 ); set_D6( DISP_V_2 ); break; case 'v': @@ -271,11 +259,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_V_1 ); set_D6( DISP_V_2 ); break; case 'W': @@ -284,11 +268,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_W_1 ); set_D6( DISP_W_2 ); break; case 'w': @@ -297,11 +277,7 @@ void main (void) { set_D2( get_D3() ); set_D3( get_D4() ); set_D4( get_D5() ); - set_D5( get_D6() ); - set_D6( DISP_M_1 ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } + set_D5( DISP_W_1 ); set_D6( DISP_W_2 ); break; case 'Y': @@ -382,4 +358,3 @@ void main (void) { return; } - From ae9434e02e36cc629c76f68b5d9e18b7ddcb0dbb Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 23 May 2021 15:22:33 -0500 Subject: [PATCH 10/47] seven-segment display update --- include/symio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/symio.h b/include/symio.h index bd90a42f9..73b3ce18e 100644 --- a/include/symio.h +++ b/include/symio.h @@ -131,7 +131,7 @@ int __fastcall__ vsscanf (const char* s, const char* format, va_list ap); #define DISP_APOSTR 0x20 // ''' #define DISP_EQUAL 0x41 // '=' #define DISP_3_BAR 0x49 // '=' -#define DISP_BOTTOM 0x04 // '_' +#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 From 69e2313a63a37543032fb40658fcaacf64465431 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 6 Jun 2021 23:20:54 +0100 Subject: [PATCH 11/47] First round of requested code changes --- cfg/sym1-32k.cfg | 56 +++++++++---------- cfg/sym1-4k.cfg | 56 +++++++++---------- cfg/sym1.cfg | 56 +++++++++---------- doc/ca65.sgml | 1 + doc/cc65.sgml | 4 ++ libsrc/sym1/ctype.s | 5 ++ src/ca65/main.c | 1 + src/cc65/main.c | 1 + {samples/tutorial => targettest}/sym1/build | 0 .../tutorial => targettest}/sym1/build_32k | 0 .../tutorial => targettest}/sym1/build_4k | 0 {samples/tutorial => targettest}/sym1/clean | 0 .../tutorial => targettest}/sym1/readme.txt | 0 .../tutorial => targettest}/sym1/symDisplay.c | 0 .../tutorial => targettest}/sym1/symHello.c | 0 {samples/tutorial => targettest}/sym1/symIO.c | 0 .../tutorial => targettest}/sym1/symNotepad.c | 0 .../tutorial => targettest}/sym1/symTiny.c | 0 18 files changed, 96 insertions(+), 84 deletions(-) create mode 100644 libsrc/sym1/ctype.s rename {samples/tutorial => targettest}/sym1/build (100%) rename {samples/tutorial => targettest}/sym1/build_32k (100%) rename {samples/tutorial => targettest}/sym1/build_4k (100%) rename {samples/tutorial => targettest}/sym1/clean (100%) rename {samples/tutorial => targettest}/sym1/readme.txt (100%) rename {samples/tutorial => targettest}/sym1/symDisplay.c (100%) rename {samples/tutorial => targettest}/sym1/symHello.c (100%) rename {samples/tutorial => targettest}/sym1/symIO.c (100%) rename {samples/tutorial => targettest}/sym1/symNotepad.c (100%) rename {samples/tutorial => targettest}/sym1/symTiny.c (100%) diff --git a/cfg/sym1-32k.cfg b/cfg/sym1-32k.cfg index 0665c8cf2..9af125eaa 100644 --- a/cfg/sym1-32k.cfg +++ b/cfg/sym1-32k.cfg @@ -5,42 +5,42 @@ # 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__; + 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; + __STACKSIZE__: type = weak, value = $0200; # 512 byte program stack + __STARTADDRESS__: type = export, value = %S; } MEMORY { - ZP: start = $0000, size = $00F7, define = yes, file = %O; - CPUSTACK: start = $0100, size = $0100, define = yes; - RAM: start = %S, size = $8000 - %S - __STACKSIZE__, define = yes, file = %O; - MONROM: start = $8000, size = $1000, define = yes; - EXT: start = $9000, size = $1000, define = yes; - IO: start = $A000, size = $1000, define = yes; - RAE1: start = $B000, size = $1000, define = yes; - BASROM: start = $C000, size = $1000, define = yes; - RAE2: start = $E000, size = $1000, define = yes; - TOP: start = $F000, size = $1000, define = yes; + 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; } diff --git a/cfg/sym1-4k.cfg b/cfg/sym1-4k.cfg index de1be0b8a..eefb48a49 100644 --- a/cfg/sym1-4k.cfg +++ b/cfg/sym1-4k.cfg @@ -5,42 +5,42 @@ # 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__; + 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; + __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack + __STARTADDRESS__: type = export, value = %S; } MEMORY { - ZP: start = $0000, size = $00F7, define = yes, file = %O; - CPUSTACK: start = $0100, size = $0100, define = yes; - RAM: start = %S, size = $1000 - %S - __STACKSIZE__, define = yes, file = %O; - MONROM: start = $8000, size = $1000, define = yes; - EXT: start = $9000, size = $1000, define = yes; - IO: start = $A000, size = $1000, define = yes; - RAE1: start = $B000, size = $1000, define = yes; - BASROM: start = $C000, size = $1000, define = yes; - RAE2: start = $E000, size = $1000, define = yes; - TOP: start = $F000, size = $1000, define = yes; + 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; } diff --git a/cfg/sym1.cfg b/cfg/sym1.cfg index de1be0b8a..eefb48a49 100644 --- a/cfg/sym1.cfg +++ b/cfg/sym1.cfg @@ -5,42 +5,42 @@ # 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__; + 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; + __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack + __STARTADDRESS__: type = export, value = %S; } MEMORY { - ZP: start = $0000, size = $00F7, define = yes, file = %O; - CPUSTACK: start = $0100, size = $0100, define = yes; - RAM: start = %S, size = $1000 - %S - __STACKSIZE__, define = yes, file = %O; - MONROM: start = $8000, size = $1000, define = yes; - EXT: start = $9000, size = $1000, define = yes; - IO: start = $A000, size = $1000, define = yes; - RAE1: start = $B000, size = $1000, define = yes; - BASROM: start = $C000, size = $1000, define = yes; - RAE2: start = $E000, size = $1000, define = yes; - TOP: start = $F000, size = $1000, define = yes; + 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; } diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 3fc534066..8ae8eabd9 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -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> diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 004061518..821e76586 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -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). diff --git a/libsrc/sym1/ctype.s b/libsrc/sym1/ctype.s new file mode 100644 index 000000000..1301965eb --- /dev/null +++ b/libsrc/sym1/ctype.s @@ -0,0 +1,5 @@ +; Character specification table. +; +; uses the "common" definition + + .include "ctype_common.inc" diff --git a/src/ca65/main.c b/src/ca65/main.c index bb0607b7c..0eaf4ba6b 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -335,6 +335,7 @@ static void SetSys (const char* Sys) break; case TGT_SYM1: + NewSymbol ("__SYM1__", 1); break; default: diff --git a/src/cc65/main.c b/src/cc65/main.c index d0d756b3f..89c1b190e 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -291,6 +291,7 @@ static void SetSys (const char* Sys) break; case TGT_SYM1: + DefineNumericMacro ("__SYM1__", 1); break; default: diff --git a/samples/tutorial/sym1/build b/targettest/sym1/build similarity index 100% rename from samples/tutorial/sym1/build rename to targettest/sym1/build diff --git a/samples/tutorial/sym1/build_32k b/targettest/sym1/build_32k similarity index 100% rename from samples/tutorial/sym1/build_32k rename to targettest/sym1/build_32k diff --git a/samples/tutorial/sym1/build_4k b/targettest/sym1/build_4k similarity index 100% rename from samples/tutorial/sym1/build_4k rename to targettest/sym1/build_4k diff --git a/samples/tutorial/sym1/clean b/targettest/sym1/clean similarity index 100% rename from samples/tutorial/sym1/clean rename to targettest/sym1/clean diff --git a/samples/tutorial/sym1/readme.txt b/targettest/sym1/readme.txt similarity index 100% rename from samples/tutorial/sym1/readme.txt rename to targettest/sym1/readme.txt diff --git a/samples/tutorial/sym1/symDisplay.c b/targettest/sym1/symDisplay.c similarity index 100% rename from samples/tutorial/sym1/symDisplay.c rename to targettest/sym1/symDisplay.c diff --git a/samples/tutorial/sym1/symHello.c b/targettest/sym1/symHello.c similarity index 100% rename from samples/tutorial/sym1/symHello.c rename to targettest/sym1/symHello.c diff --git a/samples/tutorial/sym1/symIO.c b/targettest/sym1/symIO.c similarity index 100% rename from samples/tutorial/sym1/symIO.c rename to targettest/sym1/symIO.c diff --git a/samples/tutorial/sym1/symNotepad.c b/targettest/sym1/symNotepad.c similarity index 100% rename from samples/tutorial/sym1/symNotepad.c rename to targettest/sym1/symNotepad.c diff --git a/samples/tutorial/sym1/symTiny.c b/targettest/sym1/symTiny.c similarity index 100% rename from samples/tutorial/sym1/symTiny.c rename to targettest/sym1/symTiny.c From 7d5fc7eb439b0a9ee3ba58cf07ca2f892e85e4ac Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 6 Jun 2021 17:51:24 -0500 Subject: [PATCH 12/47] Changed kb references to KB --- doc/sym1.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/sym1.sgml b/doc/sym1.sgml index f04f36ae1..a52cf93de 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -38,7 +38,7 @@ Special locations: 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 $0FFF on 4kb Syms, or at $7FFFfor 32kb systems. The stack always grows downwards. + The C runtime stack is located at $0FFF on 4KB Syms, or at $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 @@ -101,7 +101,7 @@ But there is another header available, which exposes Sym-specific I/O functions <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_32k configuration - then you may want to use functions like getchar, putchar, gets and puts rather than printf. Printf requires about 1kb because it needs to know how to process all the format specifiers. +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_32k configuration - then you may want to use functions like getchar, putchar, gets and puts rather than printf. Printf requires about 1KB because it needs to know how to process all the format specifiers. <sect3>Sample programs<p> From e687f2f0480d1ba55c958e771139a1cd93ab34d6 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 6 Jun 2021 17:55:58 -0500 Subject: [PATCH 13/47] Clarified 'Limited memory applications' section --- doc/sym1.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sym1.sgml b/doc/sym1.sgml index a52cf93de..5e3e44dfd 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -101,7 +101,7 @@ But there is another header available, which exposes Sym-specific I/O functions <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_32k configuration - then you may want to use functions like getchar, putchar, gets and puts rather than printf. Printf requires about 1KB because it needs to know how to process all the format specifiers. +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 printf. Printf requires about 1KB because it needs to know how to process all the format specifiers. <sect3>Sample programs<p> From 6c4c959141161eba4ce02fb3b1f18be5ad5c21c2 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 6 Jun 2021 21:28:03 -0500 Subject: [PATCH 14/47] Sym-1 lib changes --- doc/sym1.sgml | 8 +- include/sym1.h | 154 ++++++++++++++++++++++++++++++++++++ include/symio.h | 148 ----------------------------------- libsrc/sym1/beep.s | 16 ++-- libsrc/sym1/bitio.s | 178 ++++++++++++++++++++---------------------- libsrc/sym1/crt0.s | 24 +++--- libsrc/sym1/display.s | 123 +++++++++++++---------------- libsrc/sym1/getchar.s | 21 ----- libsrc/sym1/putchar.s | 23 ------ libsrc/sym1/read.s | 12 +-- libsrc/sym1/tapeio.s | 17 ++-- libsrc/sym1/write.s | 12 +-- samples/symDisplay.c | 3 +- samples/symHello.c | 3 +- samples/symIO.c | 8 +- samples/symNotepad.c | 7 +- samples/symTiny.c | 3 +- 17 files changed, 339 insertions(+), 421 deletions(-) create mode 100644 include/sym1.h delete mode 100644 include/symio.h delete mode 100644 libsrc/sym1/getchar.s delete mode 100644 libsrc/sym1/putchar.s diff --git a/doc/sym1.sgml b/doc/sym1.sgml index 5e3e44dfd..59d1db3b7 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -48,7 +48,7 @@ Special locations: <sect>Platform specific header files<p> -Programs containing Sym-1 code may use the <tt/symio.h/ header file. See the header file for more information. +Programs containing Sym-1 code may use the <tt/sym1.h/ header file. See the header file for more information. <sect1>Hardware access<p> @@ -94,10 +94,8 @@ To be more specific, this limitation means that you cannot use any of the follow <sect>Other hints<p> -<sect1>symio.h<p> -You can use stdio.h if you wish, which provides console I/O (like printf) but does not have access to a filesystem, as mentioned above. - -But there is another header available, which exposes Sym-specific I/O functions that are useful for reading and writing its ports and front panel. It also exposes functions normally included using stdio.h but <i>only</i> the console I/O functions and not the filesystem functions. See the symio.h include file for a list of the functions available. +<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 sym1.h include file for a list of the functions available. <sect2>Limited memory applications<p> diff --git a/include/sym1.h b/include/sym1.h new file mode 100644 index 000000000..0a919f84d --- /dev/null +++ b/include/sym1.h @@ -0,0 +1,154 @@ +// sym1.h +// +// I/O primitives for Sym-1 +// +// Wayne Parham + + + +#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 + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +int __fastcall__ beep (void); // Beep sound +void __fastcall__ set_D0 (unsigned char); // Set display digit 0 +int __fastcall__ get_D0 (void); // Get value of display digit 0 +void __fastcall__ set_D1 (unsigned char); // Set display digit 1 +int __fastcall__ get_D1 (void); // Get value of display digit 1 +void __fastcall__ set_D2 (unsigned char); // Set display digit 2 +int __fastcall__ get_D2 (void); // Get value of display digit 2 +void __fastcall__ set_D3 (unsigned char); // Set display digit 3 +int __fastcall__ get_D3 (void); // Get value of display digit 3 +void __fastcall__ set_D4 (unsigned char); // Set display digit 4 +int __fastcall__ get_D4 (void); // Get value of display digit 4 +void __fastcall__ set_D5 (unsigned char); // Set display digit 5 +int __fastcall__ get_D5 (void); // Get value of display digit 5 +void __fastcall__ set_D6 (unsigned char); // Set byte to the right of display (leading buffer) +int __fastcall__ get_D6 (void); // Get value of memory byte to the right of display +void __fastcall__ fdisp (void); // Flash display + +int __fastcall__ loadt (int); // Read from tape (id) +int __fastcall__ dumpt (int, int, int); // Write to tape (id, start_addr, end_addr) + +void __fastcall__ set_DDR1A (unsigned char); // Set data direction register 1A (U25) +int __fastcall__ get_DDR1A (void); // Get value of data direction register 1A +void __fastcall__ set_IOR1A (unsigned char); // Set I/O register 1A +int __fastcall__ get_IOR1A (void); // Get value of I/O register 1A + +void __fastcall__ set_DDR1B (unsigned char); // Set data direction register 1B (U25) +int __fastcall__ get_DDR1B (void); // Get value of data direction register 1B +void __fastcall__ set_IOR1B (unsigned char); // Set I/O register 1B +int __fastcall__ get_IOR1B (void); // Get value of I/O register 1B + +void __fastcall__ set_DDR2A (unsigned char); // Set data direction register 2A (U28) +int __fastcall__ get_DDR2A (void); // Get value of data direction register 2A +void __fastcall__ set_IOR2A (unsigned char); // Set I/O register 2A +int __fastcall__ get_IOR2A (void); // Get value of I/O register 2A + +void __fastcall__ set_DDR2B (unsigned char); // Set data direction register 2B (U28) +int __fastcall__ get_DDR2B (void); // Get value of data direction register 2B +void __fastcall__ set_IOR2B (unsigned char); // Set I/O register 2B +int __fastcall__ get_IOR2B (void); // Get value of I/O register 2B + +void __fastcall__ set_DDR3A (unsigned char); // Set data direction register 3A (U29) +int __fastcall__ get_DDR3A (void); // Get value of data direction register 3A +void __fastcall__ set_IOR3A (unsigned char); // Set I/O register 3A +int __fastcall__ get_IOR3A (void); // Get value of I/O register 3A + +void __fastcall__ set_DDR3B (unsigned char); // Set data direction register 3B (U29) +int __fastcall__ get_DDR3B (void); // Get value of data direction register 3B +void __fastcall__ set_IOR3B (unsigned char); // Set I/O register 3B +int __fastcall__ get_IOR3B (void); // Get value of I/O register 3B + + + +/* End of sym1.h */ +#endif diff --git a/include/symio.h b/include/symio.h deleted file mode 100644 index 73b3ce18e..000000000 --- a/include/symio.h +++ /dev/null @@ -1,148 +0,0 @@ -// symio.h -// -// I/O primitives for Sym-1 -// -// Wayne Parham - -#ifndef _SYMIO_H -#define _SYMIO_H - -#include <stddef.h> -#include <stdarg.h> - -int __fastcall__ beep (void); // Beep sound -int __fastcall__ set_D0 (char); // Set display digit 0 -int __fastcall__ get_D0 (void); // Get value of display digit 0 -int __fastcall__ set_D1 (char); // Set display digit 1 -int __fastcall__ get_D1 (void); // Get value of display digit 1 -int __fastcall__ set_D2 (char); // Set display digit 2 -int __fastcall__ get_D2 (void); // Get value of display digit 2 -int __fastcall__ set_D3 (char); // Set display digit 3 -int __fastcall__ get_D3 (void); // Get value of display digit 3 -int __fastcall__ set_D4 (char); // Set display digit 4 -int __fastcall__ get_D4 (void); // Get value of display digit 4 -int __fastcall__ set_D5 (char); // Set display digit 5 -int __fastcall__ get_D5 (void); // Get value of display digit 5 -int __fastcall__ set_D6 (char); // Set byte to the right of display (leading buffer) -int __fastcall__ get_D6 (void); // Get value of memory byte to the right of display -int __fastcall__ fdisp (void); // Flash display - -int __fastcall__ loadt (int); // Read from tape (id) -int __fastcall__ dumpt (int, int, int); // Write to tape (id, start_addr, end_addr) - -int __fastcall__ set_DDR1A (int); // Set data direction register 1A (U25) -int __fastcall__ get_DDR1A (void); // Get value of data direction register 1A -int __fastcall__ set_IOR1A (int); // Set I/O register 1A -int __fastcall__ get_IOR1A (void); // Get value of I/O register 1A - -int __fastcall__ set_DDR1B (int); // Set data direction register 1B (U25) -int __fastcall__ get_DDR1B (void); // Get value of data direction register 1B -int __fastcall__ set_IOR1B (int); // Set I/O register 1B -int __fastcall__ get_IOR1B (void); // Get value of I/O register 1B - -int __fastcall__ set_DDR2A (int); // Set data direction register 2A (U28) -int __fastcall__ get_DDR2A (void); // Get value of data direction register 2A -int __fastcall__ set_IOR2A (int); // Set I/O register 2A -int __fastcall__ get_IOR2A (void); // Get value of I/O register 2A - -int __fastcall__ set_DDR2B (int); // Set data direction register 2B (U28) -int __fastcall__ get_DDR2B (void); // Get value of data direction register 2B -int __fastcall__ set_IOR2B (int); // Set I/O register 2B -int __fastcall__ get_IOR2B (void); // Get value of I/O register 2B - -int __fastcall__ set_DDR3A (int); // Set data direction register 3A (U29) -int __fastcall__ get_DDR3A (void); // Get value of data direction register 3A -int __fastcall__ set_IOR3A (int); // Set I/O register 3A -int __fastcall__ get_IOR3A (void); // Get value of I/O register 3A - -int __fastcall__ set_DDR3B (int); // Set data direction register 3B (U29) -int __fastcall__ get_DDR3B (void); // Get value of data direction register 3B -int __fastcall__ set_IOR3B (int); // Set I/O register 3B -int __fastcall__ get_IOR3B (void); // Get value of I/O register 3B - -#ifndef _STDIO_H - -int __fastcall__ putchar (char); -int __fastcall__ puts (const char* s); -int printf (const char* format, ...); -int sprintf (char* buf, const char* format, ...); -int __fastcall__ vprintf (const char* format, va_list ap); -int __fastcall__ vsnprintf (char* buf, size_t size, const char* format, va_list ap); -int __fastcall__ vsprintf (char* buf, const char* format, va_list ap); -char __fastcall__ getchar (void); -char* __fastcall__ gets (char* s); -int scanf (const char* format, ...); -int sscanf (const char* s, const char* format, ...); -int __fastcall__ vscanf (const char* format, va_list ap); -int __fastcall__ vsscanf (const char* s, const char* format, va_list ap); - -#endif - -// 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 - -#endif diff --git a/libsrc/sym1/beep.s b/libsrc/sym1/beep.s index a1f978563..40a3d42c6 100644 --- a/libsrc/sym1/beep.s +++ b/libsrc/sym1/beep.s @@ -1,12 +1,8 @@ -; --------------------------------------------------------------------------- -; beep.s ; -; for Sym-1 +; Wayne Parham (wayne@parhamdata.com) ; -; Wayne Parham +; void beep (void); ; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- .include "sym1.inc" @@ -15,10 +11,8 @@ .segment "CODE" .proc _beep: near -; --------------------------------------------------------------------------- + jsr BEEP ; Beep - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc diff --git a/libsrc/sym1/bitio.s b/libsrc/sym1/bitio.s index 5aa0fde8b..94cd9c5ad 100644 --- a/libsrc/sym1/bitio.s +++ b/libsrc/sym1/bitio.s @@ -1,12 +1,31 @@ -; --------------------------------------------------------------------------- -; bitio.s ; -; for Sym-1 +; Wayne Parham (wayne@parhamdata.com) ; -; Wayne Parham +; void set_DDR1A (int value); +; int get_DDR1A (void); +; void set_IOR1A (int value); +; int get_IOR1A (void); +; void set_DDR1B (int value); +; int get_DDR1B (void); +; void set_IOR1B (int value); +; int get_IOR1B (void); +; void set_DDR2A (int value); +; int get_DDR2A (void); +; void set_IOR2A (int value); +; int get_IOR2A (void); +; void set_DDR2B (int value); +; int get_DDR2B (void); +; void set_IOR2B (int value); +; int get_IOR2B (void); +; void set_DDR3A (int value); +; int get_DDR3A (void); +; void set_IOR3A (int value); +; int get_IOR3A (void); +; void set_DDR3B (int value); +; int get_DDR3B (void); +; void set_IOR3B (int value); +; int get_IOR3B (void); ; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- .include "sym1.inc" @@ -20,211 +39,182 @@ .segment "CODE" .proc _set_DDR1A: near -; --------------------------------------------------------------------------- + sta DDR1A ; Write data direction register for port 1A - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_DDR1A: near -; --------------------------------------------------------------------------- + lda DDR1A ; Read data direction register for port 1A ldx #$00 ; rts ; Return DDR1A -; --------------------------------------------------------------------------- + .endproc .proc _set_IOR1A: near -; --------------------------------------------------------------------------- + sta OR1A ; Write I/O register for port 1A - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_IOR1A: near -; --------------------------------------------------------------------------- + lda OR1A ; Read I/O register for port 1A ldx #$00 ; rts ; Return OR1A -; --------------------------------------------------------------------------- + .endproc - .proc _set_DDR1B: near -; --------------------------------------------------------------------------- + sta DDR1B ; Write data direction register for port 1B - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_DDR1B: near -; --------------------------------------------------------------------------- + lda DDR1B ; Read data direction register for port 1B ldx #$00 ; rts ; Return DDR1B -; --------------------------------------------------------------------------- + .endproc .proc _set_IOR1B: near -; --------------------------------------------------------------------------- + sta OR1B ; Write I/O register for port 1B - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_IOR1B: near -; --------------------------------------------------------------------------- + lda OR1B ; Read I/O register for port 1B ldx #$00 ; rts ; Return OR1B -; --------------------------------------------------------------------------- + .endproc - .proc _set_DDR2A: near -; --------------------------------------------------------------------------- + sta DDR2A ; Write data direction register for port 2A - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_DDR2A: near -; --------------------------------------------------------------------------- + lda DDR2A ; Read data direction register for port 2A ldx #$00 ; rts ; Return DDR2A -; --------------------------------------------------------------------------- + .endproc .proc _set_IOR2A: near -; --------------------------------------------------------------------------- + sta OR2A ; Write I/O register for port 2A - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_IOR2A: near -; --------------------------------------------------------------------------- + lda OR2A ; Read I/O register for port 2A ldx #$00 ; rts ; Return OR2A -; --------------------------------------------------------------------------- + .endproc - .proc _set_DDR2B: near -; --------------------------------------------------------------------------- + sta DDR2B ; Write data direction register for port 2B - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_DDR2B: near -; --------------------------------------------------------------------------- + lda DDR2B ; Read data direction register for port 2B ldx #$00 ; rts ; Return DDR2B -; --------------------------------------------------------------------------- + .endproc .proc _set_IOR2B: near -; --------------------------------------------------------------------------- + sta OR2B ; Write I/O register for port 2B - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_IOR2B: near -; --------------------------------------------------------------------------- + lda OR2B ; Read I/O register for port 2B ldx #$00 ; rts ; Return OR2B -; --------------------------------------------------------------------------- + .endproc - .proc _set_DDR3A: near -; --------------------------------------------------------------------------- + sta DDR3A ; Write data direction register for port 3A - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_DDR3A: near -; --------------------------------------------------------------------------- + lda DDR3A ; Read data direction register for port 3A ldx #$00 ; rts ; Return DDR3A -; --------------------------------------------------------------------------- + .endproc .proc _set_IOR3A: near -; --------------------------------------------------------------------------- + sta OR3A ; Write I/O register for port 3A - lda #$00 ; - ldx #$00 ; rts ; Return 0000 -; --------------------------------------------------------------------------- + .endproc .proc _get_IOR3A: near -; --------------------------------------------------------------------------- + lda OR3A ; Read I/O register for port 3A ldx #$00 ; rts ; Return OR3A -; --------------------------------------------------------------------------- + .endproc - .proc _set_DDR3B: near -; --------------------------------------------------------------------------- + sta DDR3B ; Write data direction register for port 3B - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_DDR3B: near -; --------------------------------------------------------------------------- + lda DDR3B ; Read data direction register for port 3B ldx #$00 ; rts ; Return DDR3B -; --------------------------------------------------------------------------- + .endproc .proc _set_IOR3B: near -; --------------------------------------------------------------------------- + sta OR3B ; Write I/O register for port 3B - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_IOR3B: near -; --------------------------------------------------------------------------- + lda OR3B ; Read I/O register for port 3B ldx #$00 ; rts ; Return OR3B -; --------------------------------------------------------------------------- + .endproc diff --git a/libsrc/sym1/crt0.s b/libsrc/sym1/crt0.s index a85887991..47cc67f07 100644 --- a/libsrc/sym1/crt0.s +++ b/libsrc/sym1/crt0.s @@ -1,12 +1,6 @@ -; --------------------------------------------------------------------------- -; crt0.s ; -; for Sym-1 +; Startup code for cc65 (Sym-1 version) ; -; Wayne Parham -; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- .export _init, _exit .export __STARTUP__ : absolute = 1 ; Mark as startup @@ -19,40 +13,40 @@ .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 @@ -61,5 +55,5 @@ _exit: jsr donelib ; Run destructors sta TECHO jsr NACCES ; Lock System RAM rts ; Re-enter Sym-1 monitor -; --------------------------------------------------------------------------- + diff --git a/libsrc/sym1/display.s b/libsrc/sym1/display.s index 530435d87..a8572f1b0 100644 --- a/libsrc/sym1/display.s +++ b/libsrc/sym1/display.s @@ -1,12 +1,22 @@ -; --------------------------------------------------------------------------- -; display.s ; -; for Sym-1 +; Wayne Parham (wayne@parhamdata.com) ; -; Wayne Parham +; int fdisp (void); +; void set_D0 (char segments); +; int get_D0 (void); +; void set_D1 (char segments); +; int get_D1 (void); +; void set_D2 (char segments); +; int get_D2 (void); +; void set_D3 (char segments); +; int get_D3 (void); +; void set_D4 (char segments); +; int get_D4 (void); +; void set_D5 (char segments); +; int get_D5 (void); +; void set_D6 (char segments); +; int get_D6 (void); ; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- .include "sym1.inc" @@ -18,137 +28,114 @@ .segment "CODE" .proc _fdisp: near -; --------------------------------------------------------------------------- + jsr SCAND ; Flash Display - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc - .proc _set_D0: near -; --------------------------------------------------------------------------- + sta DISBUF0 ; Write Digit 0 - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_D0: near -; --------------------------------------------------------------------------- + lda DISBUF0 ; Read Digit 0 ldx #$00 ; rts ; Return DISBUF0 -; --------------------------------------------------------------------------- + .endproc - .proc _set_D1: near -; --------------------------------------------------------------------------- + sta DISBUF1 ; Write Digit 1 - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_D1: near -; --------------------------------------------------------------------------- + lda DISBUF1 ; Read Digit 1 ldx #$00 ; - rts ; Return DISBUF1 -; --------------------------------------------------------------------------- + rts + .endproc - .proc _set_D2: near -; --------------------------------------------------------------------------- + sta DISBUF2 ; Write Digit 2 - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_D2: near -; --------------------------------------------------------------------------- + lda DISBUF2 ; Read Digit 2 ldx #$00 ; rts ; Return DISBUF2 -; --------------------------------------------------------------------------- + .endproc - .proc _set_D3: near -; --------------------------------------------------------------------------- + sta DISBUF3 ; Write Digit 3 - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_D3: near -; --------------------------------------------------------------------------- + lda DISBUF3 ; Read Digit 3 ldx #$00 ; rts ; Return DISBUF3 -; --------------------------------------------------------------------------- + .endproc - .proc _set_D4: near -; --------------------------------------------------------------------------- + sta DISBUF4 ; Write Digit 4 - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_D4: near -; --------------------------------------------------------------------------- + lda DISBUF4 ; Read Digit 4 ldx #$00 ; rts ; Return DISBUF4 -; --------------------------------------------------------------------------- + .endproc - .proc _set_D5: near -; --------------------------------------------------------------------------- + sta DISBUF5 ; Write Digit 5 - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_D5: near -; --------------------------------------------------------------------------- + lda DISBUF5 ; Read Digit 5 ldx #$00 ; rts ; Return DISBUF5 -; --------------------------------------------------------------------------- + .endproc - .proc _set_D6: near -; --------------------------------------------------------------------------- + sta DISBUF6 ; Write byte to the right of display - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- + rts + .endproc .proc _get_D6: near -; --------------------------------------------------------------------------- + lda DISBUF6 ; Read byte to the right of display ldx #$00 ; rts ; Return DISBUF6 -; --------------------------------------------------------------------------- + .endproc diff --git a/libsrc/sym1/getchar.s b/libsrc/sym1/getchar.s deleted file mode 100644 index d82519ce0..000000000 --- a/libsrc/sym1/getchar.s +++ /dev/null @@ -1,21 +0,0 @@ -; --------------------------------------------------------------------------- -; getchar.s -; -; for Sym-1 -; -; Wayne Parham -; --------------------------------------------------------------------------- - -.include "sym1.inc" -.export _getchar - -.segment "CODE" - -.proc _getchar: near -; --------------------------------------------------------------------------- - jsr INTCHR ; Get character using Monitor ROM call - and #$7F ; Strip off top bit - ldx #$00 ; - rts ; Return char -; --------------------------------------------------------------------------- -.endproc diff --git a/libsrc/sym1/putchar.s b/libsrc/sym1/putchar.s deleted file mode 100644 index 1b84416fe..000000000 --- a/libsrc/sym1/putchar.s +++ /dev/null @@ -1,23 +0,0 @@ -; --------------------------------------------------------------------------- -; putchar.s -; -; for Sym-1 -; -; Wayne Parham -; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- - -.include "sym1.inc" -.export _putchar - -.segment "CODE" - -.proc _putchar: near -; --------------------------------------------------------------------------- - jsr OUTCHR ; Send character using Monitor ROM call - lda #$00 ; - ldx #$00 ; - rts ; Return 0000 -; --------------------------------------------------------------------------- -.endproc diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index f0b0194d2..7ab88f1e8 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -1,12 +1,8 @@ -; --------------------------------------------------------------------------- -; read.s ; -; for Sym-1 +; Wayne Parham (wayne@parhamdata.com) ; -; Wayne Parham +; int read (int fd, void* buf, unsigned count); ; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- .include "sym1.inc" @@ -16,7 +12,7 @@ .export _read .proc _read -; --------------------------------------------------------------------------- + sta ptr3 stx ptr3+1 ; Count in ptr3 inx @@ -49,6 +45,6 @@ putch: ldy #$00 ; Put char into return buffer done: lda ptr3 ldx ptr3+1 rts ; Return count -; --------------------------------------------------------------------------- + .endproc diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s index 3a0c1fa5b..85c9c6fcc 100644 --- a/libsrc/sym1/tapeio.s +++ b/libsrc/sym1/tapeio.s @@ -1,12 +1,9 @@ -; --------------------------------------------------------------------------- -; tapeio.s ; -; for Sym-1 +; Wayne Parham (wayne@parhamdata.com) ; -; Wayne Parham +; int loadt (int id); +; int dumpt (int id, int start_addr, int end_addr); ; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- .include "sym1.inc" @@ -17,7 +14,7 @@ .segment "CODE" .proc _loadt: near -; --------------------------------------------------------------------------- + sta P1L ; Tape record ID to P1L ldx #$00 stx P1H @@ -30,11 +27,11 @@ error: ldx #$00 lda #$FF ; or 00FF if not done: rts -; --------------------------------------------------------------------------- + .endproc .proc _dumpt: near -; --------------------------------------------------------------------------- + sta P3L ; End address stx P3H jsr popax @@ -53,6 +50,6 @@ done: rts error: ldx #$00 lda #$FF ; or 00FF if not done: rts -; --------------------------------------------------------------------------- + .endproc diff --git a/libsrc/sym1/write.s b/libsrc/sym1/write.s index 843dddf1f..f7eb4c55e 100644 --- a/libsrc/sym1/write.s +++ b/libsrc/sym1/write.s @@ -1,12 +1,8 @@ -; --------------------------------------------------------------------------- -; write.s ; -; for Sym-1 +; Wayne Parham (wayne@parhamdata.com) ; -; Wayne Parham +; int write (int fd, const void* buf, int count); ; -; wayne@parhamdata.com -; --------------------------------------------------------------------------- .include "sym1.inc" @@ -16,7 +12,7 @@ .export _write .proc _write -; --------------------------------------------------------------------------- + sta ptr3 stx ptr3+1 ; Count in ptr3 inx @@ -48,6 +44,6 @@ next: inc ptr1 done: lda ptr3 ldx ptr3+1 rts ; Return count -; --------------------------------------------------------------------------- + .endproc diff --git a/samples/symDisplay.c b/samples/symDisplay.c index fa94ce598..23df1e805 100644 --- a/samples/symDisplay.c +++ b/samples/symDisplay.c @@ -6,7 +6,8 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <symio.h> +#include <stdio.h> +#include <sym1.h> void main (void) { int delay = 10; diff --git a/samples/symHello.c b/samples/symHello.c index 99b4c57df..99a7745da 100644 --- a/samples/symHello.c +++ b/samples/symHello.c @@ -6,7 +6,8 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <symio.h>; +#include <stdio.h> +#include <sym1.h> void main(void) { char c = 0x00; diff --git a/samples/symIO.c b/samples/symIO.c index d887c18b9..1e93e941a 100644 --- a/samples/symIO.c +++ b/samples/symIO.c @@ -6,10 +6,10 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <stdio.h>; -#include <symio.h>; -#include <stdlib.h>; -#include <string.h>; +#include <sym1.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> void main(void) { int ddr1a = 0x00; diff --git a/samples/symNotepad.c b/samples/symNotepad.c index bc28ef4b5..79d621223 100644 --- a/samples/symNotepad.c +++ b/samples/symNotepad.c @@ -12,9 +12,10 @@ // // -------------------------------------------------------------------------- -#include <symio.h>; -#include <stdlib.h>; -#include <string.h>; +#include <sym1.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #define TAPIO_ADDRESS 0xE000 #define TAPIO_MAX_SIZE 0x0FFF diff --git a/samples/symTiny.c b/samples/symTiny.c index b82e952ac..4d03338e6 100644 --- a/samples/symTiny.c +++ b/samples/symTiny.c @@ -8,7 +8,8 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <symio.h>; +#include <stdio.h> +#include <sym1.h> void main(void) { char c = 0x00; From 64afb50d5a3002497633ec49aa952496da0e9632 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 6 Jun 2021 21:45:58 -0500 Subject: [PATCH 15/47] Makefile changes --- libsrc/Makefile | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index eee18d0da..fc07862e6 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -149,26 +149,18 @@ GEOSDIRS = common \ runtime \ system -# MACHINE set independently of TARGET lets us easily define new targets -# without changing target.h and target.c in cc65/src/common. Useful -# for initial testing of ports to new systems. - ifeq ($(TARGET),apple2enh) SRCDIR = apple2 OBJPFX = a2 DRVPFX = a2e - MACHINE = $(TARGET) else ifeq ($(TARGET),atarixl) SRCDIR = atari OBJPFX = atr DRVPFX = atrx - MACHINE = $(TARGET) else ifeq ($(TARGET),sim65c02) SRCDIR = sim6502 - MACHINE = $(TARGET) else SRCDIR = $(TARGET) - MACHINE = $(TARGET) endif SRCDIRS = $(SRCDIR) @@ -182,26 +174,16 @@ ifeq ($(TARGET),$(filter $(TARGET),$(GEOS))) SRCDIRS += $(addprefix geos-common/,$(GEOSDIRS)) endif -ifeq ($(TARGET),sym1) - SRCDIRS += common \ - conio \ - dbg \ - em \ - runtime \ - serial \ - sym1 -else - SRCDIRS += common \ - conio \ - dbg \ - em \ - joystick \ - mouse \ - runtime \ - serial \ - tgi \ - zlib -endif +SRCDIRS += common \ + conio \ + dbg \ + em \ + joystick \ + mouse \ + runtime \ + serial \ + tgi \ + zlib vpath %.s $(SRCDIRS) vpath %.c $(SRCDIRS) From 9d509735a8fff81c4f94cb343102540293540c23 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 6 Jun 2021 21:56:23 -0500 Subject: [PATCH 16/47] Makefile changes --- libsrc/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index fc07862e6..60946b59f 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -232,7 +232,7 @@ $1_DRVS = $$(patsubst $$($1_DYNPAT),$$($1_DRVPAT),$$($1_DYNS)) $$($1_STCPAT): $$($1_SRCPAT) @echo $$(TARGET) - $$< - static - @$$(CA65) -t $$(MACHINE) -D DYN_DRV=0 $$(CA65FLAGS) --create-dep $$(@:.o=.d) -o $$@ $$< + @$$(CA65) -t $$(TARGET) -D DYN_DRV=0 $$(CA65FLAGS) --create-dep $$(@:.o=.d) -o $$@ $$< OBJS += $$($1_STCS) DEPS += $$($1_STCS:.o=.d) @@ -264,15 +264,15 @@ export CC65_HOME := $(abspath ..) define ASSEMBLE_recipe $(if $(QUIET),,@echo $(TARGET) - $<) -@$(CA65) -t $(MACHINE) $(CA65FLAGS) --create-dep $(@:.o=.d) -o $@ $< +@$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:.o=.d) -o $@ $< endef # ASSEMBLE_recipe define COMPILE_recipe $(if $(QUIET),,@echo $(TARGET) - $<) -@$(CC65) -t $(MACHINE) $(CC65FLAGS) --create-dep $(@:.o=.d) --dep-target $@ -o $(@:.o=.s) $< -@$(CA65) -t $(MACHINE) -o $@ $(@:.o=.s) +@$(CC65) -t $(TARGET) $(CC65FLAGS) --create-dep $(@:.o=.d) --dep-target $@ -o $(@:.o=.s) $< +@$(CA65) -t $(TARGET) -o $@ $(@:.o=.s) endef # COMPILE_recipe @@ -284,7 +284,7 @@ endef # COMPILE_recipe $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib @echo $(TARGET) - $(<F) - @$(CA65) -t $(MACHINE) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $< + @$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $< ../lib/$(TARGET).lib: $(OBJS) | ../lib $(AR65) a $@ $? From 33af3d79975d7b8b2b9bf381ab7193ef1df38561 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 6 Jun 2021 23:53:53 -0500 Subject: [PATCH 17/47] sym1.h updates --- include/sym1.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include/sym1.h b/include/sym1.h index 0a919f84d..4fb66b251 100644 --- a/include/sym1.h +++ b/include/sym1.h @@ -100,53 +100,53 @@ int __fastcall__ beep (void); // Beep sound void __fastcall__ set_D0 (unsigned char); // Set display digit 0 -int __fastcall__ get_D0 (void); // Get value of display digit 0 +unsigned char __fastcall__ get_D0 (void); // Get value of display digit 0 void __fastcall__ set_D1 (unsigned char); // Set display digit 1 -int __fastcall__ get_D1 (void); // Get value of display digit 1 +unsigned char __fastcall__ get_D1 (void); // Get value of display digit 1 void __fastcall__ set_D2 (unsigned char); // Set display digit 2 -int __fastcall__ get_D2 (void); // Get value of display digit 2 +unsigned char __fastcall__ get_D2 (void); // Get value of display digit 2 void __fastcall__ set_D3 (unsigned char); // Set display digit 3 -int __fastcall__ get_D3 (void); // Get value of display digit 3 +unsigned char __fastcall__ get_D3 (void); // Get value of display digit 3 void __fastcall__ set_D4 (unsigned char); // Set display digit 4 -int __fastcall__ get_D4 (void); // Get value of display digit 4 +unsigned char __fastcall__ get_D4 (void); // Get value of display digit 4 void __fastcall__ set_D5 (unsigned char); // Set display digit 5 -int __fastcall__ get_D5 (void); // Get value of display digit 5 +unsigned char __fastcall__ get_D5 (void); // Get value of display digit 5 void __fastcall__ set_D6 (unsigned char); // Set byte to the right of display (leading buffer) -int __fastcall__ get_D6 (void); // Get value of memory byte to the right of display +unsigned char __fastcall__ get_D6 (void); // Get value of memory byte to the right of display void __fastcall__ fdisp (void); // Flash display int __fastcall__ loadt (int); // Read from tape (id) int __fastcall__ dumpt (int, int, int); // Write to tape (id, start_addr, end_addr) void __fastcall__ set_DDR1A (unsigned char); // Set data direction register 1A (U25) -int __fastcall__ get_DDR1A (void); // Get value of data direction register 1A +unsigned char __fastcall__ get_DDR1A (void); // Get value of data direction register 1A void __fastcall__ set_IOR1A (unsigned char); // Set I/O register 1A -int __fastcall__ get_IOR1A (void); // Get value of I/O register 1A +unsigned char __fastcall__ get_IOR1A (void); // Get value of I/O register 1A void __fastcall__ set_DDR1B (unsigned char); // Set data direction register 1B (U25) -int __fastcall__ get_DDR1B (void); // Get value of data direction register 1B +unsigned char __fastcall__ get_DDR1B (void); // Get value of data direction register 1B void __fastcall__ set_IOR1B (unsigned char); // Set I/O register 1B -int __fastcall__ get_IOR1B (void); // Get value of I/O register 1B +unsigned char __fastcall__ get_IOR1B (void); // Get value of I/O register 1B void __fastcall__ set_DDR2A (unsigned char); // Set data direction register 2A (U28) -int __fastcall__ get_DDR2A (void); // Get value of data direction register 2A +unsigned char __fastcall__ get_DDR2A (void); // Get value of data direction register 2A void __fastcall__ set_IOR2A (unsigned char); // Set I/O register 2A -int __fastcall__ get_IOR2A (void); // Get value of I/O register 2A +unsigned char __fastcall__ get_IOR2A (void); // Get value of I/O register 2A void __fastcall__ set_DDR2B (unsigned char); // Set data direction register 2B (U28) -int __fastcall__ get_DDR2B (void); // Get value of data direction register 2B +unsigned char __fastcall__ get_DDR2B (void); // Get value of data direction register 2B void __fastcall__ set_IOR2B (unsigned char); // Set I/O register 2B -int __fastcall__ get_IOR2B (void); // Get value of I/O register 2B +unsigned char __fastcall__ get_IOR2B (void); // Get value of I/O register 2B void __fastcall__ set_DDR3A (unsigned char); // Set data direction register 3A (U29) -int __fastcall__ get_DDR3A (void); // Get value of data direction register 3A +unsigned char __fastcall__ get_DDR3A (void); // Get value of data direction register 3A void __fastcall__ set_IOR3A (unsigned char); // Set I/O register 3A -int __fastcall__ get_IOR3A (void); // Get value of I/O register 3A +unsigned char __fastcall__ get_IOR3A (void); // Get value of I/O register 3A void __fastcall__ set_DDR3B (unsigned char); // Set data direction register 3B (U29) -int __fastcall__ get_DDR3B (void); // Get value of data direction register 3B +unsigned char __fastcall__ get_DDR3B (void); // Get value of data direction register 3B void __fastcall__ set_IOR3B (unsigned char); // Set I/O register 3B -int __fastcall__ get_IOR3B (void); // Get value of I/O register 3B +unsigned char __fastcall__ get_IOR3B (void); // Get value of I/O register 3B From 0bbff54378bec65843214a786a60684fc6af67bd Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:03:44 -0500 Subject: [PATCH 18/47] return val updates --- libsrc/sym1/bitio.s | 24 ++++++++++++------------ libsrc/sym1/display.s | 14 +++++++------- libsrc/sym1/tapeio.s | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libsrc/sym1/bitio.s b/libsrc/sym1/bitio.s index 94cd9c5ad..a61dd4800 100644 --- a/libsrc/sym1/bitio.s +++ b/libsrc/sym1/bitio.s @@ -48,7 +48,7 @@ .proc _get_DDR1A: near lda DDR1A ; Read data direction register for port 1A - ldx #$00 ; + ldx #>$0000 ; rts ; Return DDR1A .endproc @@ -63,7 +63,7 @@ .proc _get_IOR1A: near lda OR1A ; Read I/O register for port 1A - ldx #$00 ; + ldx #>$0000 ; rts ; Return OR1A .endproc @@ -78,7 +78,7 @@ .proc _get_DDR1B: near lda DDR1B ; Read data direction register for port 1B - ldx #$00 ; + ldx #>$0000 ; rts ; Return DDR1B .endproc @@ -93,7 +93,7 @@ .proc _get_IOR1B: near lda OR1B ; Read I/O register for port 1B - ldx #$00 ; + ldx #>$0000 ; rts ; Return OR1B .endproc @@ -108,7 +108,7 @@ .proc _get_DDR2A: near lda DDR2A ; Read data direction register for port 2A - ldx #$00 ; + ldx #>$0000 ; rts ; Return DDR2A .endproc @@ -123,7 +123,7 @@ .proc _get_IOR2A: near lda OR2A ; Read I/O register for port 2A - ldx #$00 ; + ldx #>$0000 ; rts ; Return OR2A .endproc @@ -138,7 +138,7 @@ .proc _get_DDR2B: near lda DDR2B ; Read data direction register for port 2B - ldx #$00 ; + ldx #>$0000 ; rts ; Return DDR2B .endproc @@ -153,7 +153,7 @@ .proc _get_IOR2B: near lda OR2B ; Read I/O register for port 2B - ldx #$00 ; + ldx #>$0000 ; rts ; Return OR2B .endproc @@ -168,7 +168,7 @@ .proc _get_DDR3A: near lda DDR3A ; Read data direction register for port 3A - ldx #$00 ; + ldx #>$0000 ; rts ; Return DDR3A .endproc @@ -183,7 +183,7 @@ .proc _get_IOR3A: near lda OR3A ; Read I/O register for port 3A - ldx #$00 ; + ldx #>$0000 ; rts ; Return OR3A .endproc @@ -198,7 +198,7 @@ .proc _get_DDR3B: near lda DDR3B ; Read data direction register for port 3B - ldx #$00 ; + ldx #>$0000 ; rts ; Return DDR3B .endproc @@ -213,7 +213,7 @@ .proc _get_IOR3B: near lda OR3B ; Read I/O register for port 3B - ldx #$00 ; + ldx #>$0000 ; rts ; Return OR3B .endproc diff --git a/libsrc/sym1/display.s b/libsrc/sym1/display.s index a8572f1b0..9bef30c01 100644 --- a/libsrc/sym1/display.s +++ b/libsrc/sym1/display.s @@ -44,7 +44,7 @@ .proc _get_D0: near lda DISBUF0 ; Read Digit 0 - ldx #$00 ; + ldx #>$0000 ; rts ; Return DISBUF0 .endproc @@ -59,7 +59,7 @@ .proc _get_D1: near lda DISBUF1 ; Read Digit 1 - ldx #$00 ; + ldx #>$0000 ; rts .endproc @@ -74,7 +74,7 @@ .proc _get_D2: near lda DISBUF2 ; Read Digit 2 - ldx #$00 ; + ldx #>$0000 ; rts ; Return DISBUF2 .endproc @@ -89,7 +89,7 @@ .proc _get_D3: near lda DISBUF3 ; Read Digit 3 - ldx #$00 ; + ldx #>$0000 ; rts ; Return DISBUF3 .endproc @@ -104,7 +104,7 @@ .proc _get_D4: near lda DISBUF4 ; Read Digit 4 - ldx #$00 ; + ldx #>$0000 ; rts ; Return DISBUF4 .endproc @@ -119,7 +119,7 @@ .proc _get_D5: near lda DISBUF5 ; Read Digit 5 - ldx #$00 ; + ldx #>$0000 ; rts ; Return DISBUF5 .endproc @@ -134,7 +134,7 @@ .proc _get_D6: near lda DISBUF6 ; Read byte to the right of display - ldx #$00 ; + ldx #>$0000 ; rts ; Return DISBUF6 .endproc diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s index 85c9c6fcc..e956b6eee 100644 --- a/libsrc/sym1/tapeio.s +++ b/libsrc/sym1/tapeio.s @@ -24,7 +24,7 @@ lda #$00 ldx #$00 ; Return 0000 if successful jmp done -error: ldx #$00 +error: ldx #>$0000 lda #$FF ; or 00FF if not done: rts @@ -47,7 +47,7 @@ done: rts lda #$00 ldx #$00 ; Return 0000 if successful jmp done -error: ldx #$00 +error: ldx #>$0000 lda #$FF ; or 00FF if not done: rts From c961782192f15c4f2099e526d8babcffcabd07fd Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:07:09 -0500 Subject: [PATCH 19/47] Removed libref.s --- libsrc/sym1/libref.s | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 libsrc/sym1/libref.s diff --git a/libsrc/sym1/libref.s b/libsrc/sym1/libref.s deleted file mode 100644 index 9356d18dc..000000000 --- a/libsrc/sym1/libref.s +++ /dev/null @@ -1,3 +0,0 @@ - - .import _exit - From dc9333a3bbeef7d07535a505120af0205824d0c0 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:18:26 -0500 Subject: [PATCH 20/47] tapeio.s updates --- libsrc/sym1/tapeio.s | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s index e956b6eee..dbb6963ca 100644 --- a/libsrc/sym1/tapeio.s +++ b/libsrc/sym1/tapeio.s @@ -7,7 +7,7 @@ .include "sym1.inc" -.import popax +.import popax, return0, return1 .export _loadt, _dumpt @@ -21,12 +21,8 @@ ldy #$80 jsr LOADT ; Read data from tape bcs error - lda #$00 - ldx #$00 ; Return 0000 if successful - jmp done -error: ldx #>$0000 - lda #$FF ; or 00FF if not -done: rts + jmp return 0 ; Return 0 if sucessful +error: jmp return 1 ; or 1 if not .endproc @@ -44,12 +40,8 @@ done: rts ldy #$80 jsr DUMPT ; Write data to tape bcs error - lda #$00 - ldx #$00 ; Return 0000 if successful - jmp done -error: ldx #>$0000 - lda #$FF ; or 00FF if not -done: rts + jmp return 0 ; Return 0 if sucessful +error: jmp return 1 ; or 1 if not .endproc From 88ee45e9ef33d88cd95ec0cb03bc22a29c53ba26 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:35:20 -0500 Subject: [PATCH 21/47] tapeio.s updates --- libsrc/sym1/tapeio.s | 8 ++++---- samples/helloworld.c | 9 --------- 2 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 samples/helloworld.c diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s index dbb6963ca..19eeb2444 100644 --- a/libsrc/sym1/tapeio.s +++ b/libsrc/sym1/tapeio.s @@ -21,8 +21,8 @@ ldy #$80 jsr LOADT ; Read data from tape bcs error - jmp return 0 ; Return 0 if sucessful -error: jmp return 1 ; or 1 if not + jmp return0 ; Return 0 if sucessful +error: jmp return1 ; or 1 if not .endproc @@ -40,8 +40,8 @@ error: jmp return 1 ; or 1 if not ldy #$80 jsr DUMPT ; Write data to tape bcs error - jmp return 0 ; Return 0 if sucessful -error: jmp return 1 ; or 1 if not + jmp return0 ; Return 0 if sucessful +error: jmp return1 ; or 1 if not .endproc diff --git a/samples/helloworld.c b/samples/helloworld.c deleted file mode 100644 index 057a153e8..000000000 --- a/samples/helloworld.c +++ /dev/null @@ -1,9 +0,0 @@ -// Traditional "Hello World" program - -#include <stdio.h> - -void main (void) -{ - printf( "Hello World!\n" ); - return; -} From a3fce656b7c8761346a2b565046f9a371413ca3f Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:42:13 -0500 Subject: [PATCH 22/47] Samples updates --- samples/Makefile | 23 +++++------------------ samples/helloworld.c | 8 ++++++++ 2 files changed, 13 insertions(+), 18 deletions(-) create mode 100644 samples/helloworld.c diff --git a/samples/Makefile b/samples/Makefile index 0cd867054..c8c02dbe3 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -8,10 +8,6 @@ # var. to build for another target system. SYS ?= c64 -# New targets can define MACHINE separately -# from target if needed. -MACHINE=$(SYS) - # Just the usual way to define a variable # containing a single space character. SPACE := @@ -139,21 +135,19 @@ LDFLAGS_tgidemo_atarixl = --start-addr 0x4000 %: %.s .c.o: - $(CC) $(CFLAGS) -Ors --codesize 500 -T -g -t $(MACHINE) $< + $(CC) $(CFLAGS) -Ors --codesize 500 -T -g -t $(SYS) $< $(AS) $(<:.c=.s) .s.o: - $(AS) $(ASFLAGS) -t $(MACHINE) $< + $(AS) $(ASFLAGS) -t $(SYS) $< .PRECIOUS: %.o .o: ifeq ($(SYS),vic20) $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib -else ifeq ($(SYS),sym1) - $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@.bin -C sym1.cfg -m $@.map $^ $(SYS).lib else - $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(MACHINE) -m $@.map $^ $(SYS).lib + $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib endif # -------------------------------------------------------------------------- @@ -161,9 +155,7 @@ endif # disasm depends on cpp -ifneq ($(SYS),sym1) - DIRLIST = tutorial geos -endif +DIRLIST = tutorial geos # -------------------------------------------------------------------------- # Lists of executables @@ -276,12 +268,10 @@ EXELIST_gamate = \ hello EXELIST_geos-cbm = \ - helloworld \ ascii \ diodemo EXELIST_geos-apple = \ - helloworld \ ascii EXELIST_lunix = \ @@ -322,10 +312,7 @@ EXELIST_supervision = \ supervisionhello EXELIST_sym1 = \ - helloworld \ - symHello \ - symTiny \ - symDisplay + helloworld EXELIST_telestrat = \ ascii \ diff --git a/samples/helloworld.c b/samples/helloworld.c new file mode 100644 index 000000000..9aa4197d8 --- /dev/null +++ b/samples/helloworld.c @@ -0,0 +1,8 @@ +// Traditional "Hello World" program + +#include <stdio.h> + +int main() { + printf("Hello, World!"); + return 0; +} From 975e43892ff05462eeb23be37165c77247aba871 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:48:02 -0500 Subject: [PATCH 23/47] Samples cleanup --- samples/symDisplay.c | 361 ------------------------------------- samples/symHello.c | 40 ---- samples/symIO.c | 170 ----------------- samples/symNotepad.c | 200 -------------------- samples/symTiny.c | 43 ----- targettest/sym1/build | 36 ---- targettest/sym1/build_32k | 36 ---- targettest/sym1/build_4k | 36 ---- targettest/sym1/clean | 14 -- targettest/sym1/readme.txt | 11 -- 10 files changed, 947 deletions(-) delete mode 100644 samples/symDisplay.c delete mode 100644 samples/symHello.c delete mode 100644 samples/symIO.c delete mode 100644 samples/symNotepad.c delete mode 100644 samples/symTiny.c delete mode 100644 targettest/sym1/build delete mode 100644 targettest/sym1/build_32k delete mode 100644 targettest/sym1/build_4k delete mode 100644 targettest/sym1/clean delete mode 100644 targettest/sym1/readme.txt diff --git a/samples/symDisplay.c b/samples/symDisplay.c deleted file mode 100644 index 23df1e805..000000000 --- a/samples/symDisplay.c +++ /dev/null @@ -1,361 +0,0 @@ -// -------------------------------------------------------------------------- -// Sym-1 front panel display example -// -// Wayne Parham -// -// wayne@parhamdata.com -// -------------------------------------------------------------------------- - -#include <stdio.h> -#include <sym1.h> - -void 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 != '\r') && (i < 41) ) { - c = getchar(); - putchar( c ); - 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(); - putchar( c ); - 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 - - - set_D0( DISP_SPACE ); // Clear the display - set_D1( DISP_SPACE ); - set_D2( DISP_SPACE ); - set_D3( DISP_SPACE ); - set_D4( DISP_SPACE ); - set_D5( DISP_SPACE ); - set_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 - set_D6( DISP_1 ); // one at a time - break; - case '2': - set_D6( DISP_2 ); - break; - case '3': - set_D6( DISP_3 ); - break; - case '4': - set_D6( DISP_4 ); - break; - case '5': - set_D6( DISP_5 ); - break; - case '6': - set_D6( DISP_6 ); - break; - case '7': - set_D6( DISP_7 ); - break; - case '8': - set_D6( DISP_8 ); - break; - case '9': - set_D6( DISP_9 ); - break; - case '0': - set_D6( DISP_0 ); - break; - case 'A': - set_D6( DISP_A ); - break; - case 'a': - set_D6( DISP_A ); - break; - case 'B': - set_D6( DISP_b ); - break; - case 'b': - set_D6( DISP_b ); - break; - case 'C': - set_D6( DISP_C ); - break; - case 'c': - set_D6( DISP_c ); - break; - case 'D': - set_D6( DISP_d ); - break; - case 'd': - set_D6( DISP_d ); - break; - case 'E': - set_D6( DISP_E ); - break; - case 'e': - set_D6( DISP_e ); - break; - case 'F': - set_D6( DISP_F ); - break; - case 'f': - set_D6( DISP_F ); - break; - case 'G': - set_D6( DISP_G ); - break; - case 'g': - set_D6( DISP_g ); - break; - case 'H': - set_D6( DISP_H ); - break; - case 'h': - set_D6( DISP_h ); - break; - case 'I': - set_D6( DISP_I ); - break; - case 'i': - set_D6( DISP_i ); - break; - case 'J': - set_D6( DISP_J ); - break; - case 'j': - set_D6( DISP_J ); - break; - case 'K': - set_D6( DISP_K ); - break; - case 'k': - set_D6( DISP_K ); - break; - case 'L': - set_D6( DISP_L ); - break; - case 'l': - set_D6( DISP_L ); - break; - case 'M': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_M_1 ); - set_D6( DISP_M_2 ); - break; - case 'm': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_M_1 ); - set_D6( DISP_M_2 ); - break; - case 'N': - set_D6( DISP_n ); - break; - case 'n': - set_D6( DISP_n ); - break; - case 'O': - set_D6( DISP_O ); - break; - case 'o': - set_D6( DISP_o ); - break; - case 'P': - set_D6( DISP_P ); - break; - case 'p': - set_D6( DISP_P ); - break; - case 'Q': - set_D6( DISP_q ); - break; - case 'q': - set_D6( DISP_q ); - break; - case 'R': - set_D6( DISP_r ); - break; - case 'r': - set_D6( DISP_r ); - break; - case 'S': - set_D6( DISP_S ); - break; - case 's': - set_D6( DISP_S ); - break; - case 'T': - set_D6( DISP_t ); - break; - case 't': - set_D6( DISP_t ); - break; - case 'U': - set_D6( DISP_U ); - break; - case 'u': - set_D6( DISP_u ); - break; - case 'V': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_V_1 ); - set_D6( DISP_V_2 ); - break; - case 'v': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_V_1 ); - set_D6( DISP_V_2 ); - break; - case 'W': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_W_1 ); - set_D6( DISP_W_2 ); - break; - case 'w': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_W_1 ); - set_D6( DISP_W_2 ); - break; - case 'Y': - set_D6( DISP_Y ); - break; - case 'y': - set_D6( DISP_Y ); - break; - case 'Z': - set_D6( DISP_Z ); - break; - case 'z': - set_D6( DISP_Z ); - break; - case ' ': - set_D6( DISP_SPACE ); - break; - case '.': - set_D6( DISP_PERIOD ); - break; - case '-': - set_D6( DISP_HYPHEN ); - break; - case '\'': - set_D6( DISP_APOSTR ); - break; - case '"': - set_D6( DISP_APOSTR ); - break; - case '=': - set_D6( DISP_EQUAL ); - break; - case '_': - set_D6( DISP_BOTTOM ); - break; - case '/': - set_D6( DISP_SLASH ); - break; - case '\\': - set_D6( DISP_BACKSLASH ); - break; - default: - displayable = 0; // Character not mapped - } - - if( displayable ) { - - putchar( buffer[l] ); // Send it to the console - - set_D0( get_D1() ); // Scroll to the left - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( get_D6() ); - - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } - } - } - - for( e = 0; e < 6; e++ ) { // Gradually fill the - set_D0( get_D1() ); // display with spaces - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_SPACE ); - set_D6( DISP_SPACE ); - for( d = 0; d < flashes ; d++ ) { - fdisp(); // Display - } - } - } - - puts( "\n\nEnjoy your day!\n\n" ); - - return; -} diff --git a/samples/symHello.c b/samples/symHello.c deleted file mode 100644 index 99a7745da..000000000 --- a/samples/symHello.c +++ /dev/null @@ -1,40 +0,0 @@ -// -------------------------------------------------------------------------- -// Hello World for Sym-1 -// -// Wayne Parham -// -// wayne@parhamdata.com -// -------------------------------------------------------------------------- - -#include <stdio.h> -#include <sym1.h> - -void 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 != '\r' ) { - c = getchar(); - putchar( c ); - } - - printf( "\n\nThanks!\n\n" ); - - for( l = 0; l < 5; l++ ) { - beep(); - for( d = 0; d < 10 ; d++ ) { - } - } - - return; -} diff --git a/samples/symIO.c b/samples/symIO.c deleted file mode 100644 index 1e93e941a..000000000 --- a/samples/symIO.c +++ /dev/null @@ -1,170 +0,0 @@ -// -------------------------------------------------------------------------- -// Sym-1 digital I/O interface example -// -// Wayne Parham -// -// wayne@parhamdata.com -// -------------------------------------------------------------------------- - -#include <sym1.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -void main(void) { - int ddr1a = 0x00; - int ior1a = 0x00; - int ddr1b = 0x00; - int ior1b = 0x00; - int ddr2a = 0x00; - int ior2a = 0x00; - int ddr2b = 0x00; - int ior2b = 0x00; - int ddr3a = 0x00; - int ior3a = 0x00; - int ddr3b = 0x00; - int ior3b = 0x00; - int l = 0x00; - int val = 0x00; - int going = 0x01; - int instr = 0x01; - char* vp = 0x00; - char cmd[20] = { 0x00 }; - - while( going ) { - - putchar( '\r' ); - for( l = 0; l < 25; l++ ) { - putchar( '\n' ); - } - - ddr1a = get_DDR1A(); - ior1a = get_IOR1A(); - ddr1b = get_DDR1B(); - ior1b = get_IOR1B(); - ddr2a = get_DDR2A(); - ior2a = get_IOR2A(); - ddr2b = get_DDR2B(); - ior2b = get_IOR2B(); - ddr3a = get_DDR3A(); - ior3a = get_IOR3A(); - ddr3b = get_DDR3B(); - ior3b = get_IOR3B(); - - 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 'stop' 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, "stop", 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 = atoi( vp ); - set_DDR1A( val ); - } - } - else if( strncasecmp(cmd, "ior1a", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_IOR1A( val ); - } - } - else if( strncasecmp(cmd, "ddr1b", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_DDR1B( val ); - } - } - else if( strncasecmp(cmd, "ior1b", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_IOR1B( val ); - } - } - else if( strncasecmp(cmd, "ddr2a", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_DDR2A( val ); - } - } - else if( strncasecmp(cmd, "ior2a", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_IOR2A( val ); - } - } - else if( strncasecmp(cmd, "ddr2b", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_DDR2B( val ); - } - } - else if( strncasecmp(cmd, "ior2b", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_IOR2B( val ); - } - } - else if( strncasecmp(cmd, "ddr3a", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_DDR3A( val ); - } - } - else if( strncasecmp(cmd, "ior3a", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_IOR3A( val ); - } - } - else if( strncasecmp(cmd, "ddr3b", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_DDR3B( val ); - } - } - else if( strncasecmp(cmd, "ior3b", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { - val = atoi( vp ); - set_IOR3B( val ); - } - } - } - - return; -} diff --git a/samples/symNotepad.c b/samples/symNotepad.c deleted file mode 100644 index 79d621223..000000000 --- a/samples/symNotepad.c +++ /dev/null @@ -1,200 +0,0 @@ -// -------------------------------------------------------------------------- -// 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 - -void 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', (int) tapio, (int) 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] ); - if( buffer[l] == '\r' ) { - putchar( '\n' ); - } - } - } - 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] ); - if( buffer[l] == '\r' ) { - putchar( '\n' ); - } - } - } - } - 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 == '\r' ) { - putchar( '\n' ); - } - buffer[p] = c; - putchar( c ); - } - p++; - } - } - } - - free( buffer ); - - puts( "\nEnjoy your day!\n" ); - - return; -} - diff --git a/samples/symTiny.c b/samples/symTiny.c deleted file mode 100644 index 4d03338e6..000000000 --- a/samples/symTiny.c +++ /dev/null @@ -1,43 +0,0 @@ -// -------------------------------------------------------------------------- -// 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> - -void 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 != '\r' ) { - c = getchar(); - putchar( c ); - } - - puts( "\n\nThanks!\n" ); - - for( l = 0; l < 5; l++ ) { - beep(); - for( d = 0; d < 10 ; d++ ) { - } - } - - return; -} diff --git a/targettest/sym1/build b/targettest/sym1/build deleted file mode 100644 index 6688da0a3..000000000 --- a/targettest/sym1/build +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# build.sh - -if [ -f $1.c ]; then - echo - echo "--- Building $1 ---" - - if [ -f $1.s ]; then - rm $1.s - fi - if [ -f $1.o ]; then - rm $1.o - fi - if [ -f $1.bin ]; then - rm $1.bin - fi - if [ -f $1.hex ]; then - rm $1.hex - fi - - cc65 -t sym1 -O $1.c - ca65 $1.s - ld65 -C sym1.cfg -m $1.map -o $1.bin $1.o sym1.lib - if [ -f $1.bin ]; then - bin2hex $1.bin $1.hex > /dev/null 2>&1 - fi - if [ -f $1.hex ]; then - echo "--- $1.hex made ---" - else - echo "--- $1.hex FAIL ---" - fi - - -fi - diff --git a/targettest/sym1/build_32k b/targettest/sym1/build_32k deleted file mode 100644 index 555bda0b4..000000000 --- a/targettest/sym1/build_32k +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# build.sh - -if [ -f $1.c ]; then - echo - echo "--- Building $1 ---" - - if [ -f $1.s ]; then - rm $1.s - fi - if [ -f $1.o ]; then - rm $1.o - fi - if [ -f $1.bin ]; then - rm $1.bin - fi - if [ -f $1.hex ]; then - rm $1.hex - fi - - cc65 -t sym1 -O $1.c - ca65 $1.s - ld65 -C sym1-32k.cfg -m $1.map -o $1.bin $1.o sym1.lib - if [ -f $1.bin ]; then - bin2hex $1.bin $1.hex > /dev/null 2>&1 - fi - if [ -f $1.hex ]; then - echo "--- $1.hex made ---" - else - echo "--- $1.hex FAIL ---" - fi - - -fi - diff --git a/targettest/sym1/build_4k b/targettest/sym1/build_4k deleted file mode 100644 index 502bb6aa9..000000000 --- a/targettest/sym1/build_4k +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# build.sh - -if [ -f $1.c ]; then - echo - echo "--- Building $1 ---" - - if [ -f $1.s ]; then - rm $1.s - fi - if [ -f $1.o ]; then - rm $1.o - fi - if [ -f $1.bin ]; then - rm $1.bin - fi - if [ -f $1.hex ]; then - rm $1.hex - fi - - cc65 -t sym1 -O $1.c - ca65 $1.s - ld65 -C sym1-4k.cfg -m $1.map -o $1.bin $1.o sym1.lib - if [ -f $1.bin ]; then - bin2hex $1.bin $1.hex > /dev/null 2>&1 - fi - if [ -f $1.hex ]; then - echo "--- $1.hex made ---" - else - echo "--- $1.hex FAIL ---" - fi - - -fi - diff --git a/targettest/sym1/clean b/targettest/sym1/clean deleted file mode 100644 index c0d77390e..000000000 --- a/targettest/sym1/clean +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# -# clean.sh - -if [ -f $1.c ]; then - echo - echo "--- Cleaning $1 ---" - - rm $1.s $1.o $1.map $1.bin $1.hex > /dev/null 2>&1 - - echo "--- Cleaned $1 ---" - -fi - diff --git a/targettest/sym1/readme.txt b/targettest/sym1/readme.txt deleted file mode 100644 index 74bcb5527..000000000 --- a/targettest/sym1/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ -These simple build scripts can be used to build any single-file C program -you might write. Notice the diference in the linker line for the 4k build -compared with the 32k build. Small programs can be compiled with either -build script, but they won't run on a 4k machine if compiled for a 32k -system. So if you have a program that's small enough to fit in 4k, it is -probably better to build with the 4k script so it will run on Sym-1 machines -that do not have an expansion memory board. - -Usage: build <program> (don't include the .c extension) - clean <program> (removes intermediate and output files) - From 5eafd8115f2077f668616c1534c21c0fd14ad9c4 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:53:15 -0500 Subject: [PATCH 24/47] Cleanup whitespace in Makefile --- samples/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index c8c02dbe3..e455852c6 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -334,13 +334,12 @@ ifndef EXELIST_$(SYS) EXELIST_$(SYS) := ${patsubst %.c,%,$(wildcard *.c)} endif -define SUBDIR_recipe +define SUBDIR_recipe @$(MAKE) -C $(dir) --no-print-directory $@ endef # SUBDIR_recipe - # -------------------------------------------------------------------------- # Rules to make the binaries and the disk @@ -481,5 +480,4 @@ mostlyclean: clean: mostlyclean @$(DEL) $(EXELIST_$(SYS)) $(DISK_$(SYS)) 2>$(NULLDEV) @$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV) - @$(foreach dir,$(DIRLIST),$(SUBDIR_recipe)) - + $(foreach dir,$(DIRLIST),$(SUBDIR_recipe)) From 732a5fb9a7409eca69faae7e7ce7423b77e493e1 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 00:56:50 -0500 Subject: [PATCH 25/47] Remove bin and hex references from samples/Makefile --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index e455852c6..32a0086d8 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -475,7 +475,7 @@ zip: # Clean-up rules mostlyclean: - @$(DEL) *.lbl *.map *.bin *.hex *.o *.s 2>$(NULLDEV) + @$(DEL) *.lbl *.map *.o *.s 2>$(NULLDEV) clean: mostlyclean @$(DEL) $(EXELIST_$(SYS)) $(DISK_$(SYS)) 2>$(NULLDEV) From 79757ee28093884e1b845a885a2a1e6e9b97c140 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 01:04:55 -0500 Subject: [PATCH 26/47] Removed 'return' from samples (with void main) --- targettest/sym1/symDisplay.c | 2 -- targettest/sym1/symHello.c | 2 -- targettest/sym1/symIO.c | 2 -- targettest/sym1/symNotepad.c | 2 -- targettest/sym1/symTiny.c | 2 -- 5 files changed, 10 deletions(-) diff --git a/targettest/sym1/symDisplay.c b/targettest/sym1/symDisplay.c index fa94ce598..18ae54797 100644 --- a/targettest/sym1/symDisplay.c +++ b/targettest/sym1/symDisplay.c @@ -355,6 +355,4 @@ void main (void) { } puts( "\n\nEnjoy your day!\n\n" ); - - return; } diff --git a/targettest/sym1/symHello.c b/targettest/sym1/symHello.c index 99b4c57df..2cab3cbde 100644 --- a/targettest/sym1/symHello.c +++ b/targettest/sym1/symHello.c @@ -34,6 +34,4 @@ void main(void) { for( d = 0; d < 10 ; d++ ) { } } - - return; } diff --git a/targettest/sym1/symIO.c b/targettest/sym1/symIO.c index d887c18b9..d1cbe8137 100644 --- a/targettest/sym1/symIO.c +++ b/targettest/sym1/symIO.c @@ -165,6 +165,4 @@ void main(void) { } } } - - return; } diff --git a/targettest/sym1/symNotepad.c b/targettest/sym1/symNotepad.c index bc28ef4b5..f59eebda8 100644 --- a/targettest/sym1/symNotepad.c +++ b/targettest/sym1/symNotepad.c @@ -193,7 +193,5 @@ void main(void) { free( buffer ); puts( "\nEnjoy your day!\n" ); - - return; } diff --git a/targettest/sym1/symTiny.c b/targettest/sym1/symTiny.c index b82e952ac..7806d5629 100644 --- a/targettest/sym1/symTiny.c +++ b/targettest/sym1/symTiny.c @@ -37,6 +37,4 @@ void main(void) { for( d = 0; d < 10 ; d++ ) { } } - - return; } From 6cf4bd99bbb96e895ee93d255c555966672aa412 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 11:50:47 -0500 Subject: [PATCH 27/47] Added Makefile for targettest/sym1 --- targettest/sym1/Makefile | 55 ++++++++++++++++++++++++++++++++++++ targettest/sym1/symDisplay.c | 3 +- targettest/sym1/symHello.c | 3 +- targettest/sym1/symIO.c | 8 +++--- targettest/sym1/symNotepad.c | 7 +++-- targettest/sym1/symTiny.c | 3 +- 6 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 targettest/sym1/Makefile diff --git a/targettest/sym1/Makefile b/targettest/sym1/Makefile new file mode 100644 index 000000000..c8508f1e0 --- /dev/null +++ b/targettest/sym1/Makefile @@ -0,0 +1,55 @@ +# Run 'make SYS=<target>'; or, set a SYS env. +# var. to build for another target system. +SYS ?= sym1 + +# 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 $(SYS) -C sym1-4k.cfg -O -o symHello.bin symHello.c + +symTiny.bin: symTiny.c + $(CL) -t $(SYS) -C sym1-4k.cfg -O -o symTiny.bin symTiny.c + +symDisplay.bin: symDisplay.c + $(CL) -t $(SYS) -C sym1-4k.cfg -O -o symDisplay.bin symDisplay.c + +symIO.bin: symIO.c + $(CL) -t $(SYS) -C sym1-32k.cfg -O -o symIO.bin symIO.c + +symNotepad.bin: symNotepad.c + $(CL) -t $(SYS) -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) diff --git a/targettest/sym1/symDisplay.c b/targettest/sym1/symDisplay.c index 18ae54797..7b056c3ab 100644 --- a/targettest/sym1/symDisplay.c +++ b/targettest/sym1/symDisplay.c @@ -6,7 +6,8 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <symio.h> +#include <stdio.h> +#include <sym1.h> void main (void) { int delay = 10; diff --git a/targettest/sym1/symHello.c b/targettest/sym1/symHello.c index 2cab3cbde..7fb86f04e 100644 --- a/targettest/sym1/symHello.c +++ b/targettest/sym1/symHello.c @@ -6,7 +6,8 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <symio.h>; +#include <stdio.h> +#include <sym1.h> void main(void) { char c = 0x00; diff --git a/targettest/sym1/symIO.c b/targettest/sym1/symIO.c index d1cbe8137..67e898801 100644 --- a/targettest/sym1/symIO.c +++ b/targettest/sym1/symIO.c @@ -6,10 +6,10 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <stdio.h>; -#include <symio.h>; -#include <stdlib.h>; -#include <string.h>; +#include <sym1.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> void main(void) { int ddr1a = 0x00; diff --git a/targettest/sym1/symNotepad.c b/targettest/sym1/symNotepad.c index f59eebda8..683cea63f 100644 --- a/targettest/sym1/symNotepad.c +++ b/targettest/sym1/symNotepad.c @@ -12,9 +12,10 @@ // // -------------------------------------------------------------------------- -#include <symio.h>; -#include <stdlib.h>; -#include <string.h>; +#include <sym1.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #define TAPIO_ADDRESS 0xE000 #define TAPIO_MAX_SIZE 0x0FFF diff --git a/targettest/sym1/symTiny.c b/targettest/sym1/symTiny.c index 7806d5629..1e9f86516 100644 --- a/targettest/sym1/symTiny.c +++ b/targettest/sym1/symTiny.c @@ -8,7 +8,8 @@ // wayne@parhamdata.com // -------------------------------------------------------------------------- -#include <symio.h>; +#include <stdio.h> +#include <sym1.h> void main(void) { char c = 0x00; From 886e9e83b2f26c4f6c0ceb5407dcd31646c9d039 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 12:33:29 -0500 Subject: [PATCH 28/47] Removed stdin->stdout echo from read.s --- libsrc/sym1/read.s | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index 7ab88f1e8..b876a5915 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -29,11 +29,7 @@ begin: dec ptr2 beq done ; If buffer full, return getch: jsr INTCHR ; Get character using Monitor ROM call - jsr OUTCHR ; Echo it - and #$7F ; Clear hi bit and check for '\r' - cmp #$0D - bne putch - lda #$0A ; Replace with '\n' and set count to zero + and #$7F ; Clear hi bit putch: ldy #$00 ; Put char into return buffer sta (ptr1),y From 89fb731e2e293d16686fe027a86e8eb12c213891 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 19:01:06 -0500 Subject: [PATCH 29/47] samples/helloworld.c --- samples/helloworld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/helloworld.c b/samples/helloworld.c index 9aa4197d8..b4e1ee6a3 100644 --- a/samples/helloworld.c +++ b/samples/helloworld.c @@ -2,7 +2,7 @@ #include <stdio.h> -int main() { - printf("Hello, World!"); +int main(void) { + printf("Hello, World!\n"); return 0; } From 2635655e8c1b7d7fdcacca619f412fcd93208528 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 19:07:36 -0500 Subject: [PATCH 30/47] sym1.cfg cosmetic changes --- cfg/sym1-32k.cfg | 12 ++++++------ cfg/sym1-4k.cfg | 12 ++++++------ cfg/sym1.cfg | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cfg/sym1-32k.cfg b/cfg/sym1-32k.cfg index 9af125eaa..ee3bc9d63 100644 --- a/cfg/sym1-32k.cfg +++ b/cfg/sym1-32k.cfg @@ -35,12 +35,12 @@ MEMORY { } 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; BSS: load = RAM, type = bss, define = yes; } diff --git a/cfg/sym1-4k.cfg b/cfg/sym1-4k.cfg index eefb48a49..8570b6077 100644 --- a/cfg/sym1-4k.cfg +++ b/cfg/sym1-4k.cfg @@ -35,12 +35,12 @@ MEMORY { } 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; BSS: load = RAM, type = bss, define = yes; } diff --git a/cfg/sym1.cfg b/cfg/sym1.cfg index eefb48a49..8570b6077 100644 --- a/cfg/sym1.cfg +++ b/cfg/sym1.cfg @@ -35,12 +35,12 @@ MEMORY { } 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; + 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; } From 2a25921515a5736b40b2bb7096339a0e912328e6 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Mon, 7 Jun 2021 20:00:18 -0500 Subject: [PATCH 31/47] Sym-1 documentation updates --- doc/sym1.sgml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/sym1.sgml b/doc/sym1.sgml index 59d1db3b7..d2e5f09fd 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -21,11 +21,11 @@ Please note that Sym-1 specific functions are just mentioned here, they are desc <sect>Binary format<p> -The standard binary output format generated by the linker for the Sym-1 target is a 4 kbyte machine language program. It is, of course, possible to change this behavior by using one of the different linker configs. +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. <p> -Included with this distribution is a 4k configuration file and a 32k config file. The Sym-1 on-board memory is limited to 4k 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. +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> @@ -41,8 +41,7 @@ Special locations: The C runtime stack is located at $0FFF on 4KB Syms, or at $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. + The C heap is located at the end of the program and grows towards the C runtime stack. </descrip><p> @@ -52,7 +51,7 @@ Programs containing Sym-1 code may use the <tt/sym1.h/ header file. See the hea <sect1>Hardware access<p> -The following 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. +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> @@ -103,7 +102,7 @@ As stated earlier, there are config files for 4KB and 32KB systems. If you have <sect3>Sample programs<p> -All the samples will run on the "stock" 4k Sym-1, except for symio.c, which requires 8k. Information on building and running it is in the samples/tutorial/sym1 directory. +All the samples will run on the "stock" 4KB Sym-1, except for symIO and symNotepad, which require 32KB. Information on building and running the sample programs are in the targettest/sym1 directory. <itemize> <item>helloworld is the traditional "Hello World!" program, using printf().</item> From 7d6541274d58a9bff7bdf1092b48b3644d960bad Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 9 Jun 2021 10:23:42 -0500 Subject: [PATCH 32/47] Changes to I/O access --- include/sym1.h | 77 ++++------- libsrc/sym1/bitio.s | 220 ------------------------------ libsrc/sym1/display.s | 126 +---------------- libsrc/sym1/read.s | 6 +- targettest/sym1/symDisplay.c | 255 +++++++++++++++++------------------ targettest/sym1/symHello.c | 3 +- targettest/sym1/symIO.c | 112 +++++++-------- targettest/sym1/symTiny.c | 3 +- 8 files changed, 219 insertions(+), 583 deletions(-) delete mode 100644 libsrc/sym1/bitio.s diff --git a/include/sym1.h b/include/sym1.h index 4fb66b251..bedaa7913 100644 --- a/include/sym1.h +++ b/include/sym1.h @@ -91,6 +91,30 @@ #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 */ @@ -98,55 +122,10 @@ -int __fastcall__ beep (void); // Beep sound -void __fastcall__ set_D0 (unsigned char); // Set display digit 0 -unsigned char __fastcall__ get_D0 (void); // Get value of display digit 0 -void __fastcall__ set_D1 (unsigned char); // Set display digit 1 -unsigned char __fastcall__ get_D1 (void); // Get value of display digit 1 -void __fastcall__ set_D2 (unsigned char); // Set display digit 2 -unsigned char __fastcall__ get_D2 (void); // Get value of display digit 2 -void __fastcall__ set_D3 (unsigned char); // Set display digit 3 -unsigned char __fastcall__ get_D3 (void); // Get value of display digit 3 -void __fastcall__ set_D4 (unsigned char); // Set display digit 4 -unsigned char __fastcall__ get_D4 (void); // Get value of display digit 4 -void __fastcall__ set_D5 (unsigned char); // Set display digit 5 -unsigned char __fastcall__ get_D5 (void); // Get value of display digit 5 -void __fastcall__ set_D6 (unsigned char); // Set byte to the right of display (leading buffer) -unsigned char __fastcall__ get_D6 (void); // Get value of memory byte to the right of display -void __fastcall__ fdisp (void); // Flash display - -int __fastcall__ loadt (int); // Read from tape (id) -int __fastcall__ dumpt (int, int, int); // Write to tape (id, start_addr, end_addr) - -void __fastcall__ set_DDR1A (unsigned char); // Set data direction register 1A (U25) -unsigned char __fastcall__ get_DDR1A (void); // Get value of data direction register 1A -void __fastcall__ set_IOR1A (unsigned char); // Set I/O register 1A -unsigned char __fastcall__ get_IOR1A (void); // Get value of I/O register 1A - -void __fastcall__ set_DDR1B (unsigned char); // Set data direction register 1B (U25) -unsigned char __fastcall__ get_DDR1B (void); // Get value of data direction register 1B -void __fastcall__ set_IOR1B (unsigned char); // Set I/O register 1B -unsigned char __fastcall__ get_IOR1B (void); // Get value of I/O register 1B - -void __fastcall__ set_DDR2A (unsigned char); // Set data direction register 2A (U28) -unsigned char __fastcall__ get_DDR2A (void); // Get value of data direction register 2A -void __fastcall__ set_IOR2A (unsigned char); // Set I/O register 2A -unsigned char __fastcall__ get_IOR2A (void); // Get value of I/O register 2A - -void __fastcall__ set_DDR2B (unsigned char); // Set data direction register 2B (U28) -unsigned char __fastcall__ get_DDR2B (void); // Get value of data direction register 2B -void __fastcall__ set_IOR2B (unsigned char); // Set I/O register 2B -unsigned char __fastcall__ get_IOR2B (void); // Get value of I/O register 2B - -void __fastcall__ set_DDR3A (unsigned char); // Set data direction register 3A (U29) -unsigned char __fastcall__ get_DDR3A (void); // Get value of data direction register 3A -void __fastcall__ set_IOR3A (unsigned char); // Set I/O register 3A -unsigned char __fastcall__ get_IOR3A (void); // Get value of I/O register 3A - -void __fastcall__ set_DDR3B (unsigned char); // Set data direction register 3B (U29) -unsigned char __fastcall__ get_DDR3B (void); // Get value of data direction register 3B -void __fastcall__ set_IOR3B (unsigned char); // Set I/O register 3B -unsigned char __fastcall__ get_IOR3B (void); // Get value of I/O register 3B +void beep (void); // Beep sound +void fdisp (void); // Flash display +int __fastcall__ loadt (unsigned char); // Read from tape (id) +int __fastcall__ dumpt (unsigned char, const void*, const void*); // Write to tape (id, start_addr, end_addr) diff --git a/libsrc/sym1/bitio.s b/libsrc/sym1/bitio.s deleted file mode 100644 index a61dd4800..000000000 --- a/libsrc/sym1/bitio.s +++ /dev/null @@ -1,220 +0,0 @@ -; -; Wayne Parham (wayne@parhamdata.com) -; -; void set_DDR1A (int value); -; int get_DDR1A (void); -; void set_IOR1A (int value); -; int get_IOR1A (void); -; void set_DDR1B (int value); -; int get_DDR1B (void); -; void set_IOR1B (int value); -; int get_IOR1B (void); -; void set_DDR2A (int value); -; int get_DDR2A (void); -; void set_IOR2A (int value); -; int get_IOR2A (void); -; void set_DDR2B (int value); -; int get_DDR2B (void); -; void set_IOR2B (int value); -; int get_IOR2B (void); -; void set_DDR3A (int value); -; int get_DDR3A (void); -; void set_IOR3A (int value); -; int get_IOR3A (void); -; void set_DDR3B (int value); -; int get_DDR3B (void); -; void set_IOR3B (int value); -; int get_IOR3B (void); -; - -.include "sym1.inc" - -.export _set_DDR1A, _get_DDR1A, _set_IOR1A, _get_IOR1A -.export _set_DDR1B, _get_DDR1B, _set_IOR1B, _get_IOR1B -.export _set_DDR2A, _get_DDR2A, _set_IOR2A, _get_IOR2A -.export _set_DDR2B, _get_DDR2B, _set_IOR2B, _get_IOR2B -.export _set_DDR3A, _get_DDR3A, _set_IOR3A, _get_IOR3A -.export _set_DDR3B, _get_DDR3B, _set_IOR3B, _get_IOR3B - -.segment "CODE" - -.proc _set_DDR1A: near - - sta DDR1A ; Write data direction register for port 1A - rts - -.endproc - -.proc _get_DDR1A: near - - lda DDR1A ; Read data direction register for port 1A - ldx #>$0000 ; - rts ; Return DDR1A - -.endproc - -.proc _set_IOR1A: near - - sta OR1A ; Write I/O register for port 1A - rts - -.endproc - -.proc _get_IOR1A: near - - lda OR1A ; Read I/O register for port 1A - ldx #>$0000 ; - rts ; Return OR1A - -.endproc - -.proc _set_DDR1B: near - - sta DDR1B ; Write data direction register for port 1B - rts - -.endproc - -.proc _get_DDR1B: near - - lda DDR1B ; Read data direction register for port 1B - ldx #>$0000 ; - rts ; Return DDR1B - -.endproc - -.proc _set_IOR1B: near - - sta OR1B ; Write I/O register for port 1B - rts - -.endproc - -.proc _get_IOR1B: near - - lda OR1B ; Read I/O register for port 1B - ldx #>$0000 ; - rts ; Return OR1B - -.endproc - -.proc _set_DDR2A: near - - sta DDR2A ; Write data direction register for port 2A - rts - -.endproc - -.proc _get_DDR2A: near - - lda DDR2A ; Read data direction register for port 2A - ldx #>$0000 ; - rts ; Return DDR2A - -.endproc - -.proc _set_IOR2A: near - - sta OR2A ; Write I/O register for port 2A - rts - -.endproc - -.proc _get_IOR2A: near - - lda OR2A ; Read I/O register for port 2A - ldx #>$0000 ; - rts ; Return OR2A - -.endproc - -.proc _set_DDR2B: near - - sta DDR2B ; Write data direction register for port 2B - rts - -.endproc - -.proc _get_DDR2B: near - - lda DDR2B ; Read data direction register for port 2B - ldx #>$0000 ; - rts ; Return DDR2B - -.endproc - -.proc _set_IOR2B: near - - sta OR2B ; Write I/O register for port 2B - rts - -.endproc - -.proc _get_IOR2B: near - - lda OR2B ; Read I/O register for port 2B - ldx #>$0000 ; - rts ; Return OR2B - -.endproc - -.proc _set_DDR3A: near - - sta DDR3A ; Write data direction register for port 3A - rts - -.endproc - -.proc _get_DDR3A: near - - lda DDR3A ; Read data direction register for port 3A - ldx #>$0000 ; - rts ; Return DDR3A - -.endproc - -.proc _set_IOR3A: near - - sta OR3A ; Write I/O register for port 3A - rts ; Return 0000 - -.endproc - -.proc _get_IOR3A: near - - lda OR3A ; Read I/O register for port 3A - ldx #>$0000 ; - rts ; Return OR3A - -.endproc - -.proc _set_DDR3B: near - - sta DDR3B ; Write data direction register for port 3B - rts - -.endproc - -.proc _get_DDR3B: near - - lda DDR3B ; Read data direction register for port 3B - ldx #>$0000 ; - rts ; Return DDR3B - -.endproc - -.proc _set_IOR3B: near - - sta OR3B ; Write I/O register for port 3B - rts - -.endproc - -.proc _get_IOR3B: near - - lda OR3B ; Read I/O register for port 3B - ldx #>$0000 ; - rts ; Return OR3B - -.endproc - diff --git a/libsrc/sym1/display.s b/libsrc/sym1/display.s index 9bef30c01..1d3b0abfa 100644 --- a/libsrc/sym1/display.s +++ b/libsrc/sym1/display.s @@ -1,29 +1,12 @@ ; ; Wayne Parham (wayne@parhamdata.com) ; -; int fdisp (void); -; void set_D0 (char segments); -; int get_D0 (void); -; void set_D1 (char segments); -; int get_D1 (void); -; void set_D2 (char segments); -; int get_D2 (void); -; void set_D3 (char segments); -; int get_D3 (void); -; void set_D4 (char segments); -; int get_D4 (void); -; void set_D5 (char segments); -; int get_D5 (void); -; void set_D6 (char segments); -; int get_D6 (void); +; void fdisp (void); ; .include "sym1.inc" -.export _fdisp, _set_D0, _get_D0 -.export _set_D1, _get_D1, _set_D2, _get_D2 -.export _set_D3, _get_D3, _set_D4, _get_D4 -.export _set_D5, _get_D5, _set_D6, _get_D6 +.export _fdisp .segment "CODE" @@ -34,108 +17,3 @@ .endproc -.proc _set_D0: near - - sta DISBUF0 ; Write Digit 0 - rts - -.endproc - -.proc _get_D0: near - - lda DISBUF0 ; Read Digit 0 - ldx #>$0000 ; - rts ; Return DISBUF0 - -.endproc - -.proc _set_D1: near - - sta DISBUF1 ; Write Digit 1 - rts - -.endproc - -.proc _get_D1: near - - lda DISBUF1 ; Read Digit 1 - ldx #>$0000 ; - rts - -.endproc - -.proc _set_D2: near - - sta DISBUF2 ; Write Digit 2 - rts - -.endproc - -.proc _get_D2: near - - lda DISBUF2 ; Read Digit 2 - ldx #>$0000 ; - rts ; Return DISBUF2 - -.endproc - -.proc _set_D3: near - - sta DISBUF3 ; Write Digit 3 - rts - -.endproc - -.proc _get_D3: near - - lda DISBUF3 ; Read Digit 3 - ldx #>$0000 ; - rts ; Return DISBUF3 - -.endproc - -.proc _set_D4: near - - sta DISBUF4 ; Write Digit 4 - rts - -.endproc - -.proc _get_D4: near - - lda DISBUF4 ; Read Digit 4 - ldx #>$0000 ; - rts ; Return DISBUF4 - -.endproc - -.proc _set_D5: near - - sta DISBUF5 ; Write Digit 5 - rts - -.endproc - -.proc _get_D5: near - - lda DISBUF5 ; Read Digit 5 - ldx #>$0000 ; - rts ; Return DISBUF5 - -.endproc - -.proc _set_D6: near - - sta DISBUF6 ; Write byte to the right of display - rts - -.endproc - -.proc _get_D6: near - - lda DISBUF6 ; Read byte to the right of display - ldx #>$0000 ; - rts ; Return DISBUF6 - -.endproc - diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index b876a5915..7ab88f1e8 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -29,7 +29,11 @@ begin: dec ptr2 beq done ; If buffer full, return getch: jsr INTCHR ; Get character using Monitor ROM call - and #$7F ; Clear hi bit + jsr OUTCHR ; Echo it + and #$7F ; Clear hi bit and check for '\r' + cmp #$0D + bne putch + lda #$0A ; Replace with '\n' and set count to zero putch: ldy #$00 ; Put char into return buffer sta (ptr1),y diff --git a/targettest/sym1/symDisplay.c b/targettest/sym1/symDisplay.c index 7b056c3ab..e97518c79 100644 --- a/targettest/sym1/symDisplay.c +++ b/targettest/sym1/symDisplay.c @@ -25,9 +25,8 @@ void main (void) { puts( "\nType a message (40 chars max) and press ENTER, please:\n" ); - while( (c != '\r') && (i < 41) ) { + while( (c != '\n') && (i < 40) ) { c = getchar(); - putchar( c ); buffer[i] = c; i++; if( i == 40 ) { @@ -40,7 +39,6 @@ void main (void) { while( z == 0 ) { puts( "\n\nHow many times (0 for forever) to repeat?" ); c = getchar(); - putchar( c ); if( (c >= '0') && (c <= '9') ) { // between 1 and 9 loops allowed z = 1; // a number was pressed t = c - '0'; // convert char to int @@ -59,14 +57,13 @@ void main (void) { putchar( '\r' ); // Send CR to console - - set_D0( DISP_SPACE ); // Clear the display - set_D1( DISP_SPACE ); - set_D2( DISP_SPACE ); - set_D3( DISP_SPACE ); - set_D4( DISP_SPACE ); - set_D5( DISP_SPACE ); - set_D6( DISP_SPACE ); + 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 @@ -78,247 +75,247 @@ void main (void) { switch( buffer[l] ) { // Put the typed charaters case '1': // into the display buffer - set_D6( DISP_1 ); // one at a time + DISPLAY.d6 = DISP_1; // one at a time break; case '2': - set_D6( DISP_2 ); + DISPLAY.d6 = DISP_2; break; case '3': - set_D6( DISP_3 ); + DISPLAY.d6 = DISP_3; break; case '4': - set_D6( DISP_4 ); + DISPLAY.d6 = DISP_4; break; case '5': - set_D6( DISP_5 ); + DISPLAY.d6 = DISP_5; break; case '6': - set_D6( DISP_6 ); + DISPLAY.d6 = DISP_6; break; case '7': - set_D6( DISP_7 ); + DISPLAY.d6 = DISP_7; break; case '8': - set_D6( DISP_8 ); + DISPLAY.d6 = DISP_8; break; case '9': - set_D6( DISP_9 ); + DISPLAY.d6 = DISP_9; break; case '0': - set_D6( DISP_0 ); + DISPLAY.d6 = DISP_0; break; case 'A': - set_D6( DISP_A ); + DISPLAY.d6 = DISP_A; break; case 'a': - set_D6( DISP_A ); + DISPLAY.d6 = DISP_A; break; case 'B': - set_D6( DISP_b ); + DISPLAY.d6 = DISP_b; break; case 'b': - set_D6( DISP_b ); + DISPLAY.d6 = DISP_b; break; case 'C': - set_D6( DISP_C ); + DISPLAY.d6 = DISP_C; break; case 'c': - set_D6( DISP_c ); + DISPLAY.d6 = DISP_c; break; case 'D': - set_D6( DISP_d ); + DISPLAY.d6 = DISP_d; break; case 'd': - set_D6( DISP_d ); + DISPLAY.d6 = DISP_d; break; case 'E': - set_D6( DISP_E ); + DISPLAY.d6 = DISP_E; break; case 'e': - set_D6( DISP_e ); + DISPLAY.d6 = DISP_e; break; case 'F': - set_D6( DISP_F ); + DISPLAY.d6 = DISP_F; break; case 'f': - set_D6( DISP_F ); + DISPLAY.d6 = DISP_F; break; case 'G': - set_D6( DISP_G ); + DISPLAY.d6 = DISP_G; break; case 'g': - set_D6( DISP_g ); + DISPLAY.d6 = DISP_g; break; case 'H': - set_D6( DISP_H ); + DISPLAY.d6 = DISP_H; break; case 'h': - set_D6( DISP_h ); + DISPLAY.d6 = DISP_h; break; case 'I': - set_D6( DISP_I ); + DISPLAY.d6 = DISP_I; break; case 'i': - set_D6( DISP_i ); + DISPLAY.d6 = DISP_i; break; case 'J': - set_D6( DISP_J ); + DISPLAY.d6 = DISP_J; break; case 'j': - set_D6( DISP_J ); + DISPLAY.d6 = DISP_J; break; case 'K': - set_D6( DISP_K ); + DISPLAY.d6 = DISP_K; break; case 'k': - set_D6( DISP_K ); + DISPLAY.d6 = DISP_K; break; case 'L': - set_D6( DISP_L ); + DISPLAY.d6 = DISP_L; break; case 'l': - set_D6( DISP_L ); + DISPLAY.d6 = DISP_L; break; case 'M': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_M_1 ); - set_D6( DISP_M_2 ); + 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': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_M_1 ); - set_D6( DISP_M_2 ); + 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': - set_D6( DISP_n ); + DISPLAY.d6 = DISP_n; break; case 'n': - set_D6( DISP_n ); + DISPLAY.d6 = DISP_n; break; case 'O': - set_D6( DISP_O ); + DISPLAY.d6 = DISP_O; break; case 'o': - set_D6( DISP_o ); + DISPLAY.d6 = DISP_o; break; case 'P': - set_D6( DISP_P ); + DISPLAY.d6 = DISP_P; break; case 'p': - set_D6( DISP_P ); + DISPLAY.d6 = DISP_P; break; case 'Q': - set_D6( DISP_q ); + DISPLAY.d6 = DISP_q; break; case 'q': - set_D6( DISP_q ); + DISPLAY.d6 = DISP_q; break; case 'R': - set_D6( DISP_r ); + DISPLAY.d6 = DISP_r; break; case 'r': - set_D6( DISP_r ); + DISPLAY.d6 = DISP_r; break; case 'S': - set_D6( DISP_S ); + DISPLAY.d6 = DISP_S; break; case 's': - set_D6( DISP_S ); + DISPLAY.d6 = DISP_S; break; case 'T': - set_D6( DISP_t ); + DISPLAY.d6 = DISP_t; break; case 't': - set_D6( DISP_t ); + DISPLAY.d6 = DISP_t; break; case 'U': - set_D6( DISP_U ); + DISPLAY.d6 = DISP_U; break; case 'u': - set_D6( DISP_u ); + DISPLAY.d6 = DISP_u; break; case 'V': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_V_1 ); - set_D6( DISP_V_2 ); + 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': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_V_1 ); - set_D6( DISP_V_2 ); + 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': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_W_1 ); - set_D6( DISP_W_2 ); + 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': - set_D0( get_D1() ); - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_W_1 ); - set_D6( DISP_W_2 ); + 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': - set_D6( DISP_Y ); + DISPLAY.d6 = DISP_Y; break; case 'y': - set_D6( DISP_Y ); + DISPLAY.d6 = DISP_Y; break; case 'Z': - set_D6( DISP_Z ); + DISPLAY.d6 = DISP_Z; break; case 'z': - set_D6( DISP_Z ); + DISPLAY.d6 = DISP_Z; break; case ' ': - set_D6( DISP_SPACE ); + DISPLAY.d6 = DISP_SPACE; break; case '.': - set_D6( DISP_PERIOD ); + DISPLAY.d6 = DISP_PERIOD; break; case '-': - set_D6( DISP_HYPHEN ); + DISPLAY.d6 = DISP_HYPHEN; break; case '\'': - set_D6( DISP_APOSTR ); + DISPLAY.d6 = DISP_APOSTR; break; case '"': - set_D6( DISP_APOSTR ); + DISPLAY.d6 = DISP_APOSTR; break; case '=': - set_D6( DISP_EQUAL ); + DISPLAY.d6 = DISP_EQUAL; break; case '_': - set_D6( DISP_BOTTOM ); + DISPLAY.d6 = DISP_BOTTOM; break; case '/': - set_D6( DISP_SLASH ); + DISPLAY.d6 = DISP_SLASH; break; case '\\': - set_D6( DISP_BACKSLASH ); + DISPLAY.d6 = DISP_BACKSLASH; break; default: displayable = 0; // Character not mapped @@ -328,12 +325,12 @@ void main (void) { putchar( buffer[l] ); // Send it to the console - set_D0( get_D1() ); // Scroll to the left - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( get_D6() ); + 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 @@ -342,13 +339,13 @@ void main (void) { } for( e = 0; e < 6; e++ ) { // Gradually fill the - set_D0( get_D1() ); // display with spaces - set_D1( get_D2() ); - set_D2( get_D3() ); - set_D3( get_D4() ); - set_D4( get_D5() ); - set_D5( DISP_SPACE ); - set_D6( DISP_SPACE ); + 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 } diff --git a/targettest/sym1/symHello.c b/targettest/sym1/symHello.c index 7fb86f04e..543e00cb2 100644 --- a/targettest/sym1/symHello.c +++ b/targettest/sym1/symHello.c @@ -23,9 +23,8 @@ void main(void) { } printf( "Type a line and press ENTER, please.\n\n" ); - while( c != '\r' ) { + while( c != '\n' ) { c = getchar(); - putchar( c ); } printf( "\n\nThanks!\n\n" ); diff --git a/targettest/sym1/symIO.c b/targettest/sym1/symIO.c index 67e898801..99b020be2 100644 --- a/targettest/sym1/symIO.c +++ b/targettest/sym1/symIO.c @@ -12,24 +12,24 @@ #include <string.h> void main(void) { - int ddr1a = 0x00; - int ior1a = 0x00; - int ddr1b = 0x00; - int ior1b = 0x00; - int ddr2a = 0x00; - int ior2a = 0x00; - int ddr2b = 0x00; - int ior2b = 0x00; - int ddr3a = 0x00; - int ior3a = 0x00; - int ddr3b = 0x00; - int ior3b = 0x00; - int l = 0x00; - int val = 0x00; - int going = 0x01; - int instr = 0x01; - char* vp = 0x00; - char cmd[20] = { 0x00 }; + 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 ) { @@ -38,18 +38,18 @@ void main(void) { putchar( '\n' ); } - ddr1a = get_DDR1A(); - ior1a = get_IOR1A(); - ddr1b = get_DDR1B(); - ior1b = get_IOR1B(); - ddr2a = get_DDR2A(); - ior2a = get_IOR2A(); - ddr2b = get_DDR2B(); - ior2b = get_IOR2B(); - ddr3a = get_DDR3A(); - ior3a = get_IOR3A(); - ddr3b = get_DDR3B(); - ior3b = get_IOR3B(); + 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" ); @@ -63,7 +63,7 @@ void main(void) { 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 'stop' to end the program.\n"); + 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; @@ -74,7 +74,7 @@ void main(void) { fgets(cmd, sizeof(cmd)-1, stdin); cmd[strlen(cmd)-1] = '\0'; - if( strncasecmp(cmd, "stop", 4) == 0) { + if( strncasecmp(cmd, "quit", 4) == 0) { going = 0; } else if( strncasecmp(cmd, "help", 4) == 0) { @@ -83,85 +83,85 @@ void main(void) { else if( strncasecmp(cmd, "ddr1a", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_DDR1A( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA1.ddra = val; } } else if( strncasecmp(cmd, "ior1a", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_IOR1A( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA1.pra = val; } } else if( strncasecmp(cmd, "ddr1b", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_DDR1B( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA1.ddrb = val; } } else if( strncasecmp(cmd, "ior1b", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_IOR1B( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA1.prb = val; } } else if( strncasecmp(cmd, "ddr2a", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_DDR2A( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA2.ddra = val; } } else if( strncasecmp(cmd, "ior2a", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_IOR2A( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA2.pra = val; } } else if( strncasecmp(cmd, "ddr2b", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_DDR2B( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA2.ddrb = val; } } else if( strncasecmp(cmd, "ior2b", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_IOR2B( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA2.prb = val; } } else if( strncasecmp(cmd, "ddr3a", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_DDR3A( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA3.ddra = val; } } else if( strncasecmp(cmd, "ior3a", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_IOR3A( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA3.pra = val; } } else if( strncasecmp(cmd, "ddr3b", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_DDR3B( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA3.ddrb = val; } } else if( strncasecmp(cmd, "ior3b", 5) == 0) { vp = strchr(cmd, ' '); if( vp ) { - val = atoi( vp ); - set_IOR3B( val ); + val = (unsigned char) strtol( vp, NULL, 0 ); + VIA3.prb = val; } } } diff --git a/targettest/sym1/symTiny.c b/targettest/sym1/symTiny.c index 1e9f86516..bbca4f9d1 100644 --- a/targettest/sym1/symTiny.c +++ b/targettest/sym1/symTiny.c @@ -26,9 +26,8 @@ void main(void) { } } - while( c != '\r' ) { + while( c != '\n' ) { c = getchar(); - putchar( c ); } puts( "\n\nThanks!\n" ); From 24f5bac8994a1a009ae46f5e4db2cdb927bee001 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Thu, 10 Jun 2021 16:07:39 -0500 Subject: [PATCH 33/47] Added BEL -> beep() functionality --- libsrc/sym1/read.s | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index 7ab88f1e8..fe4990601 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -30,10 +30,13 @@ begin: dec ptr2 getch: jsr INTCHR ; Get character using Monitor ROM call jsr OUTCHR ; Echo it - and #$7F ; Clear hi bit and check for '\r' - cmp #$0D - bne putch - lda #$0A ; Replace with '\n' and set count to zero + and #$7F ; Clear hi 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' putch: ldy #$00 ; Put char into return buffer sta (ptr1),y From 9e6c1d1303b2efae34712f51a1a9a915fb3d6856 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Fri, 11 Jun 2021 19:55:13 -0500 Subject: [PATCH 34/47] tapeio and symNotepad updates --- libsrc/sym1/tapeio.s | 8 ++++---- targettest/sym1/symNotepad.c | 11 ++--------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s index 19eeb2444..13579dca7 100644 --- a/libsrc/sym1/tapeio.s +++ b/libsrc/sym1/tapeio.s @@ -1,13 +1,13 @@ ; ; Wayne Parham (wayne@parhamdata.com) ; -; int loadt (int id); -; int dumpt (int id, int start_addr, int end_addr); +; int __fastcall__ loadt (unsigned char id); +; int __fastcall__ dumpt (unsigned char id, void* start_addr, void* end_addr); ; .include "sym1.inc" -.import popax, return0, return1 +.import popa, popax, return0, return1 .export _loadt, _dumpt @@ -33,7 +33,7 @@ error: jmp return1 ; or 1 if not jsr popax sta P2L ; Start address stx P2H - jsr popax + jsr popa sta P1L ; Tape Record ID ldx #$00 stx P1H diff --git a/targettest/sym1/symNotepad.c b/targettest/sym1/symNotepad.c index 683cea63f..c47d1ac98 100644 --- a/targettest/sym1/symNotepad.c +++ b/targettest/sym1/symNotepad.c @@ -110,7 +110,7 @@ void main(void) { l++; tapio[l] = 0x00; puts( "Saving to tape." ); - error = dumpt( 'N', (int) tapio, (int) tapio+p ); + error = dumpt( 'N', tapio, tapio+p ); if( error ) { puts( "\nTape error." ); } @@ -124,9 +124,6 @@ void main(void) { puts( "===================== Sym-1 Notepad ====================\n" ); for( l = 0; l <= p; l++ ) { putchar( buffer[l] ); - if( buffer[l] == '\r' ) { - putchar( '\n' ); - } } } else if( c == 0x0C ) { // Load @@ -155,9 +152,6 @@ void main(void) { for( l = 0; l <= p; l++ ) { putchar( buffer[l] ); - if( buffer[l] == '\r' ) { - putchar( '\n' ); - } } } } @@ -180,11 +174,10 @@ void main(void) { puts( "Buffer full." ); } else { - if( c == '\r' ) { + if( c == '\n' ) { putchar( '\n' ); } buffer[p] = c; - putchar( c ); } p++; } From c9bb1483ac57030981ee77d2e851c3fabf05697d Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sat, 12 Jun 2021 06:17:03 -0500 Subject: [PATCH 35/47] Add BEL->beep functionality --- libsrc/sym1/write.s | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libsrc/sym1/write.s b/libsrc/sym1/write.s index f7eb4c55e..314a7760b 100644 --- a/libsrc/sym1/write.s +++ b/libsrc/sym1/write.s @@ -7,7 +7,7 @@ .include "sym1.inc" .import popax, popptr1 -.importzp ptr1, ptr2, ptr3, tmp1 +.importzp ptr1, ptr2, ptr3 .export _write @@ -28,12 +28,15 @@ begin: dec ptr2 dec ptr2+1 beq done -outch : ldy #0 +outch: ldy #0 lda (ptr1),y jsr OUTCHR ; Send character using Monitor call - cmp #$0A - bne next - lda #$0D ; If it is LF, add CR + 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 From faf6266cded2d45d6020fd9a27e622fc17b4e47e Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sat, 12 Jun 2021 06:28:53 -0500 Subject: [PATCH 36/47] typo in comment --- libsrc/sym1/read.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index fe4990601..177472270 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -30,7 +30,7 @@ begin: dec ptr2 getch: jsr INTCHR ; Get character using Monitor ROM call jsr OUTCHR ; Echo it - and #$7F ; Clear hi bit + and #$7F ; Clear top bit cmp #$07 ; Check for '\a' bne chkcr ; ...if BEL character jsr BEEP ; Make beep sound From 4db50e8e931e10951436310e7837c2bc5de66b5a Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Sun, 13 Jun 2021 11:29:30 -0500 Subject: [PATCH 37/47] Documentation update: Mention where to find sym1 sample programs --- doc/sym1.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/sym1.sgml b/doc/sym1.sgml index d2e5f09fd..c32fcf2cb 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -94,7 +94,7 @@ To be more specific, this limitation means that you cannot use any of the follow <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 sym1.h include file for a list of the functions available. +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> @@ -102,7 +102,7 @@ As stated earlier, there are config files for 4KB and 32KB systems. If you have <sect3>Sample programs<p> -All the samples will run on the "stock" 4KB Sym-1, except for symIO and symNotepad, which require 32KB. Information on building and running the sample programs are in the targettest/sym1 directory. +All the samples will run on the "stock" 4KB Sym-1, except for symIO and symNotepad, which require 32KB. These sample programs can be found in the samples and targettest/sym1 directories: <itemize> <item>helloworld is the traditional "Hello World!" program, using printf().</item> From 11d81b1f436f4f1fc4e5f6e0b952b2df500e76c4 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Tue, 15 Jun 2021 16:39:28 -0500 Subject: [PATCH 38/47] Stylistic changes --- cfg/sym1-32k.cfg | 54 ++++++++++++++++++------------------ cfg/sym1-4k.cfg | 54 ++++++++++++++++++------------------ cfg/sym1.cfg | 54 ++++++++++++++++++------------------ doc/sym1.sgml | 7 ++--- include/sym1.h | 50 +++++++++++++++++++++++++++------ samples/Makefile | 2 +- samples/helloworld.c | 8 ------ targettest/sym1/Makefile | 14 ++++------ targettest/sym1/symDisplay.c | 23 ++++++++------- targettest/sym1/symIO.c | 36 ++++++++++++------------ targettest/sym1/symNotepad.c | 23 +++++++-------- 11 files changed, 170 insertions(+), 155 deletions(-) delete mode 100644 samples/helloworld.c diff --git a/cfg/sym1-32k.cfg b/cfg/sym1-32k.cfg index ee3bc9d63..ad0d760f3 100644 --- a/cfg/sym1-32k.cfg +++ b/cfg/sym1-32k.cfg @@ -6,41 +6,41 @@ 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__; + 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; + __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; + 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; } diff --git a/cfg/sym1-4k.cfg b/cfg/sym1-4k.cfg index 8570b6077..32d3cbb3a 100644 --- a/cfg/sym1-4k.cfg +++ b/cfg/sym1-4k.cfg @@ -6,41 +6,41 @@ 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__; + 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; + __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; + 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; } diff --git a/cfg/sym1.cfg b/cfg/sym1.cfg index 8570b6077..32d3cbb3a 100644 --- a/cfg/sym1.cfg +++ b/cfg/sym1.cfg @@ -6,41 +6,41 @@ 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__; + 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; + __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; + 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; + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = RAM, type = ro, define = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, define = yes; + ONCE: load = RAM, type = ro, define = yes; + DATA: load = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; } diff --git a/doc/sym1.sgml b/doc/sym1.sgml index c32fcf2cb..75c44b422 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -21,7 +21,7 @@ Please note that Sym-1 specific functions are just mentioned here, they are desc <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. +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> @@ -98,14 +98,13 @@ This header exposes Sym-specific I/O functions that are useful for reading and w <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 printf. Printf requires about 1KB because it needs to know how to process all the format specifiers. +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 "stock" 4KB Sym-1, except for symIO and symNotepad, which require 32KB. These sample programs can be found in the samples and targettest/sym1 directories: +All the samples will run on the "stock" 4KB Sym-1, except for symIO and symNotepad, which require 32KB. These sample programs can be found in the targettest/sym1 directory: <itemize> -<item>helloworld is the traditional "Hello World!" program, using printf().</item> <item>symHello prints "Hello World!" and then inputs characters, which are echoed on the screen. It also makes a "beep" 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> diff --git a/include/sym1.h b/include/sym1.h index bedaa7913..e0eb81ecf 100644 --- a/include/sym1.h +++ b/include/sym1.h @@ -1,8 +1,33 @@ -// sym1.h -// -// I/O primitives for Sym-1 -// -// Wayne Parham +/*****************************************************************************/ +/* */ +/* 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. */ +/* */ +/*****************************************************************************/ @@ -122,10 +147,17 @@ struct _display { -void beep (void); // Beep sound -void fdisp (void); // Flash display -int __fastcall__ loadt (unsigned char); // Read from tape (id) -int __fastcall__ dumpt (unsigned char, const void*, const void*); // Write to tape (id, start_addr, end_addr) +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 */ diff --git a/samples/Makefile b/samples/Makefile index 32a0086d8..1679b7d96 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -312,7 +312,7 @@ EXELIST_supervision = \ supervisionhello EXELIST_sym1 = \ - helloworld + notavailable EXELIST_telestrat = \ ascii \ diff --git a/samples/helloworld.c b/samples/helloworld.c deleted file mode 100644 index b4e1ee6a3..000000000 --- a/samples/helloworld.c +++ /dev/null @@ -1,8 +0,0 @@ -// Traditional "Hello World" program - -#include <stdio.h> - -int main(void) { - printf("Hello, World!\n"); - return 0; -} diff --git a/targettest/sym1/Makefile b/targettest/sym1/Makefile index c8508f1e0..23742f6d1 100644 --- a/targettest/sym1/Makefile +++ b/targettest/sym1/Makefile @@ -1,7 +1,3 @@ -# Run 'make SYS=<target>'; or, set a SYS env. -# var. to build for another target system. -SYS ?= sym1 - # Just the usual way to find out if we're # using cmd.exe to execute make rules. ifneq ($(shell echo),) @@ -33,19 +29,19 @@ endif all: symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin symHello.bin: symHello.c - $(CL) -t $(SYS) -C sym1-4k.cfg -O -o symHello.bin symHello.c + $(CL) -t sym1 -O -o symHello.bin symHello.c symTiny.bin: symTiny.c - $(CL) -t $(SYS) -C sym1-4k.cfg -O -o symTiny.bin symTiny.c + $(CL) -t sym1 -O -o symTiny.bin symTiny.c symDisplay.bin: symDisplay.c - $(CL) -t $(SYS) -C sym1-4k.cfg -O -o symDisplay.bin symDisplay.c + $(CL) -t sym1 -O -o symDisplay.bin symDisplay.c symIO.bin: symIO.c - $(CL) -t $(SYS) -C sym1-32k.cfg -O -o symIO.bin symIO.c + $(CL) -t sym1 -C sym1-32k.cfg -O -o symIO.bin symIO.c symNotepad.bin: symNotepad.c - $(CL) -t $(SYS) -C sym1-32k.cfg -O -o symNotepad.bin symNotepad.c + $(CL) -t sym1 -C sym1-32k.cfg -O -o symNotepad.bin symNotepad.c clean: @$(DEL) symHello.bin 2>$(NULLDEV) diff --git a/targettest/sym1/symDisplay.c b/targettest/sym1/symDisplay.c index e97518c79..ff9ff90b2 100644 --- a/targettest/sym1/symDisplay.c +++ b/targettest/sym1/symDisplay.c @@ -10,18 +10,18 @@ #include <sym1.h> void main (void) { - int delay = 10; - int flashes = 255; + 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 }; + 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" ); @@ -351,6 +351,5 @@ void main (void) { } } } - puts( "\n\nEnjoy your day!\n\n" ); } diff --git a/targettest/sym1/symIO.c b/targettest/sym1/symIO.c index 99b020be2..0b1dee40b 100644 --- a/targettest/sym1/symIO.c +++ b/targettest/sym1/symIO.c @@ -12,24 +12,24 @@ #include <string.h> void 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 }; + 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 ) { diff --git a/targettest/sym1/symNotepad.c b/targettest/sym1/symNotepad.c index c47d1ac98..f2c85756c 100644 --- a/targettest/sym1/symNotepad.c +++ b/targettest/sym1/symNotepad.c @@ -17,18 +17,18 @@ #include <stdlib.h> #include <string.h> -#define TAPIO_ADDRESS 0xE000 -#define TAPIO_MAX_SIZE 0x0FFF +#define TAPIO_ADDRESS 0xE000 +#define TAPIO_MAX_SIZE 0x0FFF void 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; + cha 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; @@ -183,9 +183,6 @@ void main(void) { } } } - free( buffer ); - puts( "\nEnjoy your day!\n" ); } - From f98e5f4feb28f6e786ca48551fdad50d1e1f6a7a Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Tue, 15 Jun 2021 17:14:27 -0500 Subject: [PATCH 39/47] Stylistic changes --- doc/sym1.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sym1.sgml b/doc/sym1.sgml index 75c44b422..60eb1c020 100644 --- a/doc/sym1.sgml +++ b/doc/sym1.sgml @@ -106,7 +106,7 @@ All the samples will run on the "stock" 4KB Sym-1, except for symIO an <itemize> <item>symHello prints "Hello World!" and then inputs characters, which are echoed on the screen. It also makes a "beep" 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>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> From f1f700799b6f175e66f4258c634b205a71519cf7 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 07:35:18 -0500 Subject: [PATCH 40/47] All samples use 'int main' and 'return int' --- targettest/sym1/symDisplay.c | 5 ++++- targettest/sym1/symHello.c | 4 +++- targettest/sym1/symIO.c | 6 +++++- targettest/sym1/symNotepad.c | 8 ++++++-- targettest/sym1/symTiny.c | 4 +++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/targettest/sym1/symDisplay.c b/targettest/sym1/symDisplay.c index ff9ff90b2..9176b5234 100644 --- a/targettest/sym1/symDisplay.c +++ b/targettest/sym1/symDisplay.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <sym1.h> -void main (void) { +int main (void) { int delay = 10; int flashes = 255; int displayable = 1; @@ -351,5 +351,8 @@ void main (void) { } } } + puts( "\n\nEnjoy your day!\n\n" ); + + return 0; } diff --git a/targettest/sym1/symHello.c b/targettest/sym1/symHello.c index 543e00cb2..a37bc1994 100644 --- a/targettest/sym1/symHello.c +++ b/targettest/sym1/symHello.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <sym1.h> -void main(void) { +int main(void) { char c = 0x00; int d = 0x00; int l = 0x00; @@ -34,4 +34,6 @@ void main(void) { for( d = 0; d < 10 ; d++ ) { } } + + return 0; } diff --git a/targettest/sym1/symIO.c b/targettest/sym1/symIO.c index 0b1dee40b..0659b71f3 100644 --- a/targettest/sym1/symIO.c +++ b/targettest/sym1/symIO.c @@ -11,7 +11,7 @@ #include <stdlib.h> #include <string.h> -void main(void) { +int main(void) { unsigned char ddr1a = 0x00; unsigned char ior1a = 0x00; unsigned char ddr1b = 0x00; @@ -165,4 +165,8 @@ void main(void) { } } } + + puts( "\n\nEnjoy your day!\n\n" ); + + return 0; } diff --git a/targettest/sym1/symNotepad.c b/targettest/sym1/symNotepad.c index f2c85756c..f2e923bb5 100644 --- a/targettest/sym1/symNotepad.c +++ b/targettest/sym1/symNotepad.c @@ -20,8 +20,8 @@ #define TAPIO_ADDRESS 0xE000 #define TAPIO_MAX_SIZE 0x0FFF -void main(void) { - cha c = 0x00; +int main(void) { + char c = 0x00; int l = 0x00; int p = 0x00; int error = 0x00; @@ -183,6 +183,10 @@ void main(void) { } } } + free( buffer ); + puts( "\nEnjoy your day!\n" ); + + return 0; } diff --git a/targettest/sym1/symTiny.c b/targettest/sym1/symTiny.c index bbca4f9d1..27b8840d8 100644 --- a/targettest/sym1/symTiny.c +++ b/targettest/sym1/symTiny.c @@ -11,7 +11,7 @@ #include <stdio.h> #include <sym1.h> -void main(void) { +int main(void) { char c = 0x00; int d = 0x00; int l = 0x00; @@ -37,4 +37,6 @@ void main(void) { for( d = 0; d < 10 ; d++ ) { } } + + return 0; } From a93542e80cb0e15d790d4ac1882f1d6d64600736 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 16:24:26 -0500 Subject: [PATCH 41/47] Added __fastcall__ to comments --- libsrc/sym1/read.s | 3 ++- libsrc/sym1/write.s | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index 177472270..a2549fd9c 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -1,7 +1,7 @@ ; ; Wayne Parham (wayne@parhamdata.com) ; -; int read (int fd, void* buf, unsigned count); +; int __fastcall__ read (int fd, void* buf, unsigned count); ; .include "sym1.inc" @@ -37,6 +37,7 @@ getch: jsr INTCHR ; Get character using Monitor ROM call 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 diff --git a/libsrc/sym1/write.s b/libsrc/sym1/write.s index 314a7760b..7b7428b9b 100644 --- a/libsrc/sym1/write.s +++ b/libsrc/sym1/write.s @@ -1,7 +1,7 @@ ; ; Wayne Parham (wayne@parhamdata.com) ; -; int write (int fd, const void* buf, int count); +; int __fastcall__ write (int fd, const void* buf, int count); ; .include "sym1.inc" From bed61df8377c42ad7c1cf4e4e32e61691d84ffd7 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 16:28:17 -0500 Subject: [PATCH 42/47] Removed unnecessary blank line from samples/Makefile --- samples/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index 1679b7d96..502748ea1 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -154,7 +154,6 @@ endif # Lists of subdirectories # disasm depends on cpp - DIRLIST = tutorial geos # -------------------------------------------------------------------------- From 82bdc77e41b4e46471ce26be3580f641afe730ac Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 16:47:38 -0500 Subject: [PATCH 43/47] puts() whitespace style change --- targettest/sym1/symDisplay.c | 10 ++++---- targettest/sym1/symHello.c | 2 +- targettest/sym1/symIO.c | 26 ++++++++++---------- targettest/sym1/symNotepad.c | 46 ++++++++++++++++++------------------ targettest/sym1/symTiny.c | 8 +++---- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/targettest/sym1/symDisplay.c b/targettest/sym1/symDisplay.c index 9176b5234..350d261f9 100644 --- a/targettest/sym1/symDisplay.c +++ b/targettest/sym1/symDisplay.c @@ -30,22 +30,22 @@ int main (void) { buffer[i] = c; i++; if( i == 40 ) { - puts( "\n\n--- Reached 40 character limit. ---" ); + 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?" ); + 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" ); + puts ("\n\nLook at the front panel.\n"); } else { - puts( "\nWhat?" ); + puts ("\nWhat?"); z = 0; // keep asking for a number } } @@ -352,7 +352,7 @@ int main (void) { } } - puts( "\n\nEnjoy your day!\n\n" ); + puts ("\n\nEnjoy your day!\n\n"); return 0; } diff --git a/targettest/sym1/symHello.c b/targettest/sym1/symHello.c index a37bc1994..8ca3ac4aa 100644 --- a/targettest/sym1/symHello.c +++ b/targettest/sym1/symHello.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <sym1.h> -int main(void) { +int main (void) { char c = 0x00; int d = 0x00; int l = 0x00; diff --git a/targettest/sym1/symIO.c b/targettest/sym1/symIO.c index 0659b71f3..65bd6e2e1 100644 --- a/targettest/sym1/symIO.c +++ b/targettest/sym1/symIO.c @@ -11,7 +11,7 @@ #include <stdlib.h> #include <string.h> -int main(void) { +int main (void) { unsigned char ddr1a = 0x00; unsigned char ior1a = 0x00; unsigned char ddr1b = 0x00; @@ -51,21 +51,21 @@ int main(void) { ddr3b = VIA3.ddrb; ior3b = VIA3.prb; - puts( "================== Digital I/O Status ==================" ); - puts( " Port1A Port1B Port2A Port2B Port3A Port3B" ); + 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" ); + 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." ); + 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; } @@ -166,7 +166,7 @@ int main(void) { } } - puts( "\n\nEnjoy your day!\n\n" ); + puts ("\n\nEnjoy your day!\n\n"); return 0; } diff --git a/targettest/sym1/symNotepad.c b/targettest/sym1/symNotepad.c index f2e923bb5..7a603bd93 100644 --- a/targettest/sym1/symNotepad.c +++ b/targettest/sym1/symNotepad.c @@ -20,7 +20,7 @@ #define TAPIO_ADDRESS 0xE000 #define TAPIO_MAX_SIZE 0x0FFF -int main(void) { +int main (void) { char c = 0x00; int l = 0x00; int p = 0x00; @@ -42,7 +42,7 @@ int main(void) { memset( buffer, 0x00, heap_size ); if( buffer == 0x00 ) { - puts( "Memory full." ); + puts ("Memory full."); running = 0; } @@ -78,16 +78,16 @@ int main(void) { putchar( '\n' ); } - puts( "===================== Sym-1 Notepad ====================" ); + 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" ); + 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 ) { @@ -101,18 +101,18 @@ int main(void) { } } else if( c == 0x13 ) { // Save - puts( "\n========================= Save =========================" ); - puts( "\nPress any key to 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." ); + puts ("Saving to tape."); error = dumpt( 'N', tapio, tapio+p ); if( error ) { - puts( "\nTape error." ); + puts ("\nTape error."); } else { @@ -121,20 +121,20 @@ int main(void) { putchar( '\n' ); } } - puts( "===================== Sym-1 Notepad ====================\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." ); + 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" ); + puts ("\nTape error."); + puts ("===================== Sym-1 Notepad ====================\n"); } else { @@ -148,7 +148,7 @@ int main(void) { for( l = 0; l < 25; l++ ) { putchar( '\n' ); } - puts( "===================== Sym-1 Notepad ====================\n" ); + puts ("===================== Sym-1 Notepad ====================\n"); for( l = 0; l <= p; l++ ) { putchar( buffer[l] ); @@ -162,7 +162,7 @@ int main(void) { for( l = 0; l < 25; l++ ) { putchar( '\n' ); } - puts( "===================== Sym-1 Notepad ====================\n" ); + puts ("===================== Sym-1 Notepad ====================\n"); } else if( c == 0x18 ) { // Exit writing = 0; @@ -170,8 +170,8 @@ int main(void) { } else { if( p >= heap_size - 1 ) { - puts( "\n========================= End =========================" ); - puts( "Buffer full." ); + puts ("\n========================= End ========================="); + puts ("Buffer full."); } else { if( c == '\n' ) { @@ -186,7 +186,7 @@ int main(void) { free( buffer ); - puts( "\nEnjoy your day!\n" ); + puts ("\nEnjoy your day!\n"); return 0; } diff --git a/targettest/sym1/symTiny.c b/targettest/sym1/symTiny.c index 27b8840d8..be7d02824 100644 --- a/targettest/sym1/symTiny.c +++ b/targettest/sym1/symTiny.c @@ -11,14 +11,14 @@ #include <stdio.h> #include <sym1.h> -int main(void) { +int main (void) { char c = 0x00; int d = 0x00; int l = 0x00; - puts( "Hello World!\n" ); + puts ("Hello World!\n"); - puts( "Type a line and press ENTER, please:\n" ); + puts ("Type a line and press ENTER, please:\n"); for( l = 0; l < 2; l++ ) { beep(); @@ -30,7 +30,7 @@ int main(void) { c = getchar(); } - puts( "\n\nThanks!\n" ); + puts ("\n\nThanks!\n"); for( l = 0; l < 5; l++ ) { beep(); From 5d90087e664bdd564f09c78b6cbacee2edef5561 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 17:14:44 -0500 Subject: [PATCH 44/47] Add space after every function or statement, before parenthesis --- targettest/sym1/symDisplay.c | 30 +++++------ targettest/sym1/symHello.c | 16 +++--- targettest/sym1/symIO.c | 94 ++++++++++++++++---------------- targettest/sym1/symNotepad.c | 100 +++++++++++++++++------------------ targettest/sym1/symTiny.c | 10 ++-- 5 files changed, 125 insertions(+), 125 deletions(-) diff --git a/targettest/sym1/symDisplay.c b/targettest/sym1/symDisplay.c index 350d261f9..dce39f6b9 100644 --- a/targettest/sym1/symDisplay.c +++ b/targettest/sym1/symDisplay.c @@ -23,23 +23,23 @@ int main (void) { char c = 0x00; char buffer[41] = { 0x00 }; - puts( "\nType a message (40 chars max) and press ENTER, please:\n" ); + puts ("\nType a message (40 chars max) and press ENTER, please:\n"); - while( (c != '\n') && (i < 40) ) { + while ( (c != '\n') && (i < 40) ) { c = getchar(); buffer[i] = c; i++; - if( i == 40 ) { + if ( i == 40 ) { puts ("\n\n--- Reached 40 character limit. ---"); } } i--; // index is one past end - while( z == 0 ) { + 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 + 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"); @@ -51,11 +51,11 @@ int main (void) { } z = 0; - while( (z < t) || (t == 0) ) { + while ( (z < t) || (t == 0) ) { z++; - putchar( '\r' ); // Send CR to console + putchar ( '\r' ); // Send CR to console DISPLAY.d0 = DISP_SPACE; // Clear the display DISPLAY.d1 = DISP_SPACE; @@ -65,15 +65,15 @@ int main (void) { DISPLAY.d5 = DISP_SPACE; DISPLAY.d6 = DISP_SPACE; - for( d = 0; d < flashes ; d++ ) { + for ( d = 0; d < flashes ; d++ ) { fdisp(); // Display } - for( l = 0; l <= i; l++ ) { + for ( l = 0; l <= i; l++ ) { displayable = 1; // Assume character is mapped - switch( buffer[l] ) { // Put the typed charaters + switch ( buffer[l] ) { // Put the typed charaters case '1': // into the display buffer DISPLAY.d6 = DISP_1; // one at a time break; @@ -321,9 +321,9 @@ int main (void) { displayable = 0; // Character not mapped } - if( displayable ) { + if ( displayable ) { - putchar( buffer[l] ); // Send it to the console + putchar ( buffer[l] ); // Send it to the console DISPLAY.d0 = DISPLAY.d1; // Scroll to the left DISPLAY.d1 = DISPLAY.d2; @@ -332,13 +332,13 @@ int main (void) { DISPLAY.d4 = DISPLAY.d5; DISPLAY.d5 = DISPLAY.d6; - for( d = 0; d < flashes ; d++ ) { + for ( d = 0; d < flashes ; d++ ) { fdisp(); // Display } } } - for( e = 0; e < 6; e++ ) { // Gradually fill the + for ( e = 0; e < 6; e++ ) { // Gradually fill the DISPLAY.d0 = DISPLAY.d1; // display with spaces DISPLAY.d1 = DISPLAY.d2; DISPLAY.d2 = DISPLAY.d3; @@ -346,7 +346,7 @@ int main (void) { DISPLAY.d4 = DISPLAY.d5; DISPLAY.d5 = DISP_SPACE; DISPLAY.d6 = DISP_SPACE; - for( d = 0; d < flashes ; d++ ) { + for ( d = 0; d < flashes ; d++ ) { fdisp(); // Display } } diff --git a/targettest/sym1/symHello.c b/targettest/sym1/symHello.c index 8ca3ac4aa..afc1d94c5 100644 --- a/targettest/sym1/symHello.c +++ b/targettest/sym1/symHello.c @@ -14,24 +14,24 @@ int main (void) { int d = 0x00; int l = 0x00; - printf( "\nHello World!\n\n" ); + printf ("\nHello World!\n\n"); - for( l = 0; l < 2; l++ ) { + for ( l = 0; l < 2; l++ ) { beep(); - for( d = 0; d < 10 ; d++ ) { + for ( d = 0; d < 10 ; d++ ) { } } - printf( "Type a line and press ENTER, please.\n\n" ); + printf ("Type a line and press ENTER, please.\n\n"); - while( c != '\n' ) { + while ( c != '\n' ) { c = getchar(); } - printf( "\n\nThanks!\n\n" ); + printf ("\n\nThanks!\n\n"); - for( l = 0; l < 5; l++ ) { + for ( l = 0; l < 5; l++ ) { beep(); - for( d = 0; d < 10 ; d++ ) { + for ( d = 0; d < 10 ; d++ ) { } } diff --git a/targettest/sym1/symIO.c b/targettest/sym1/symIO.c index 65bd6e2e1..50fefc303 100644 --- a/targettest/sym1/symIO.c +++ b/targettest/sym1/symIO.c @@ -31,11 +31,11 @@ int main (void) { char* vp = 0x00; char cmd[20] = { 0x00 }; - while( going ) { + while ( going ) { - putchar( '\r' ); - for( l = 0; l < 25; l++ ) { - putchar( '\n' ); + putchar ( '\r' ); + for ( l = 0; l < 25; l++ ) { + putchar ( '\n' ); } ddr1a = VIA1.ddra; @@ -53,11 +53,11 @@ int main (void) { 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 ); + 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 ) { + 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'."); @@ -69,97 +69,97 @@ int main (void) { instr = 0; } - printf( "\n Command: " ); + printf ("\n Command: "); - fgets(cmd, sizeof(cmd)-1, stdin); + fgets ( cmd, sizeof(cmd)-1, stdin ); cmd[strlen(cmd)-1] = '\0'; - if( strncasecmp(cmd, "quit", 4) == 0) { + if ( strncasecmp(cmd, "quit", 4) == 0 ) { going = 0; } - else if( strncasecmp(cmd, "help", 4) == 0) { + else if ( strncasecmp(cmd, "help", 4) == 0 ) { instr = 1; } - else if( strncasecmp(cmd, "ddr1a", 5) == 0) { - vp = strchr(cmd, ' '); - if( vp ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + 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 ) { + else if ( strncasecmp(cmd, "ior3b", 5) == 0 ) { + vp = strchr (cmd, ' ' ); + if ( vp ) { val = (unsigned char) strtol( vp, NULL, 0 ); VIA3.prb = val; } diff --git a/targettest/sym1/symNotepad.c b/targettest/sym1/symNotepad.c index 7a603bd93..1d0541ab6 100644 --- a/targettest/sym1/symNotepad.c +++ b/targettest/sym1/symNotepad.c @@ -34,53 +34,53 @@ int main (void) { heap_size = _heapmaxavail(); - if( heap_size > TAPIO_MAX_SIZE ) { // No need to malloc more than + 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 ); + buffer = malloc ( heap_size ); + memset ( buffer, 0x00, heap_size ); - if( buffer == 0x00 ) { + if ( buffer == 0x00 ) { puts ("Memory full."); running = 0; } tapio[0] = 0x00; // Check tape interface memory - if( tapio[0] != 0x00 ) + if ( tapio[0] != 0x00 ) error = 1; tapio[0] = 0xFF; - if( tapio[0] != 0xFF ) + if ( tapio[0] != 0xFF ) error = 1; tapio[TAPIO_MAX_SIZE] = 0x00; - if( tapio[TAPIO_MAX_SIZE] != 0x00 ) + if ( tapio[TAPIO_MAX_SIZE] != 0x00 ) error = 1; tapio[TAPIO_MAX_SIZE] = 0xFF; - if( tapio[TAPIO_MAX_SIZE] != 0xFF ) + if ( tapio[TAPIO_MAX_SIZE] != 0xFF ) error = 1; - if( error ) { - printf( "\nNo memory at location %p, aborting.\n", tapio ); + if ( error ) { + printf ("\nNo memory at location %p, aborting.\n", tapio); running = 0; } else { - memset( tapio, 0, TAPIO_MAX_SIZE ); + memset ( tapio, 0, TAPIO_MAX_SIZE ); } - while( running ) { + while ( running ) { - putchar( '\r' ); - for( l = 0; l < 25; l++ ) { - putchar( '\n' ); + putchar ( '\r' ); + for ( l = 0; l < 25; l++ ) { + putchar ( '\n' ); } puts ("===================== Sym-1 Notepad ===================="); - if( instruction_needed ) { + 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"); @@ -90,92 +90,92 @@ int main (void) { puts ("========================================================\n"); } - while( writing ) { + while ( writing ) { c = getchar(); - if( c == 0x08 ) { // Backspace - if( p > 0 ) { + if ( c == 0x08 ) { // Backspace + if ( p > 0 ) { buffer[p] = 0x00; p--; } } - else if( c == 0x13 ) { // Save + else if ( c == 0x13 ) { // Save puts ("\n========================= Save ========================="); puts ("\nPress any key to save."); c = getchar(); - for( l = 0; l <= p; l++ ) { + 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 ) { + error = dumpt ( 'N', tapio, tapio+p ); + if ( error ) { puts ("\nTape error."); } else { - putchar( '\r' ); - for( l = 0; l < 25; l++ ) { - putchar( '\n' ); + putchar ( '\r' ); + for ( l = 0; l < 25; l++ ) { + putchar ( '\n' ); } } puts ("===================== Sym-1 Notepad ====================\n"); - for( l = 0; l <= p; l++ ) { - putchar( buffer[l] ); + for ( l = 0; l <= p; l++ ) { + putchar ( buffer[l] ); } } - else if( c == 0x0C ) { // Load + 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 ) { + 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++ ) { + for ( l = 0; l <= heap_size; l++ ) { buffer[l] = tapio[l]; } - p = strlen( buffer ); + p = strlen ( buffer ); - putchar( '\r' ); - for( l = 0; l < 25; l++ ) { - putchar( '\n' ); + putchar ( '\r' ); + for ( l = 0; l < 25; l++ ) { + putchar ( '\n' ); } puts ("===================== Sym-1 Notepad ====================\n"); - for( l = 0; l <= p; l++ ) { - putchar( buffer[l] ); + for ( l = 0; l <= p; l++ ) { + putchar ( buffer[l] ); } } } - else if( c == 0x03 ) { // Clear + else if ( c == 0x03 ) { // Clear p = 0; - memset( buffer, 0, heap_size ); - putchar( '\r' ); - for( l = 0; l < 25; l++ ) { - putchar( '\n' ); + 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 + else if ( c == 0x18 ) { // Exit writing = 0; running = 0; } else { - if( p >= heap_size - 1 ) { + if ( p >= heap_size - 1 ) { puts ("\n========================= End ========================="); puts ("Buffer full."); } else { - if( c == '\n' ) { - putchar( '\n' ); + if ( c == '\n' ) { + putchar ( '\n' ); } buffer[p] = c; } @@ -184,7 +184,7 @@ int main (void) { } } - free( buffer ); + free ( buffer ); puts ("\nEnjoy your day!\n"); diff --git a/targettest/sym1/symTiny.c b/targettest/sym1/symTiny.c index be7d02824..574ac36bc 100644 --- a/targettest/sym1/symTiny.c +++ b/targettest/sym1/symTiny.c @@ -20,21 +20,21 @@ int main (void) { puts ("Type a line and press ENTER, please:\n"); - for( l = 0; l < 2; l++ ) { + for ( l = 0; l < 2; l++ ) { beep(); - for( d = 0; d < 10 ; d++ ) { + for ( d = 0; d < 10 ; d++ ) { } } - while( c != '\n' ) { + while ( c != '\n' ) { c = getchar(); } puts ("\n\nThanks!\n"); - for( l = 0; l < 5; l++ ) { + for ( l = 0; l < 5; l++ ) { beep(); - for( d = 0; d < 10 ; d++ ) { + for ( d = 0; d < 10 ; d++ ) { } } From 85d345088dd46ed4529c156c671d72e7ec9f94ed Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 17:19:28 -0500 Subject: [PATCH 45/47] Remove trailing two blank lines from libsrc/sym1/crt0.s --- libsrc/sym1/crt0.s | 2 -- 1 file changed, 2 deletions(-) diff --git a/libsrc/sym1/crt0.s b/libsrc/sym1/crt0.s index 47cc67f07..5d398b311 100644 --- a/libsrc/sym1/crt0.s +++ b/libsrc/sym1/crt0.s @@ -55,5 +55,3 @@ _exit: jsr donelib ; Run destructors sta TECHO jsr NACCES ; Lock System RAM rts ; Re-enter Sym-1 monitor - - From d6ef8326f9836a8f417bfc187daf57fab42806eb Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 17:24:18 -0500 Subject: [PATCH 46/47] Remove trailing blank line from libsrc/sym1/display.s --- libsrc/sym1/display.s | 1 - 1 file changed, 1 deletion(-) diff --git a/libsrc/sym1/display.s b/libsrc/sym1/display.s index 1d3b0abfa..f3b2923d6 100644 --- a/libsrc/sym1/display.s +++ b/libsrc/sym1/display.s @@ -16,4 +16,3 @@ rts .endproc - From 5f4605c4fc0dc0f3266edcc811df31a67ef724e6 Mon Sep 17 00:00:00 2001 From: Wayne Parham <wayne@parhamdata.com> Date: Wed, 16 Jun 2021 17:28:19 -0500 Subject: [PATCH 47/47] Remove trailing blank lines from read.s, write.s and tapeio.s --- libsrc/sym1/read.s | 1 - libsrc/sym1/tapeio.s | 1 - libsrc/sym1/write.s | 1 - 3 files changed, 3 deletions(-) diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s index a2549fd9c..c041664da 100644 --- a/libsrc/sym1/read.s +++ b/libsrc/sym1/read.s @@ -51,4 +51,3 @@ done: lda ptr3 rts ; Return count .endproc - diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s index 13579dca7..078ea7abd 100644 --- a/libsrc/sym1/tapeio.s +++ b/libsrc/sym1/tapeio.s @@ -44,4 +44,3 @@ error: jmp return1 ; or 1 if not error: jmp return1 ; or 1 if not .endproc - diff --git a/libsrc/sym1/write.s b/libsrc/sym1/write.s index 7b7428b9b..dbe738468 100644 --- a/libsrc/sym1/write.s +++ b/libsrc/sym1/write.s @@ -49,4 +49,3 @@ done: lda ptr3 rts ; Return count .endproc -