Added Sym-1 extended memory sample program and documentation

This commit is contained in:
Wayne Parham 2022-03-03 17:47:31 -06:00
parent 1cb18182ed
commit 81338a61c3
3 changed files with 106 additions and 5 deletions

View File

@ -29,7 +29,7 @@ Included with this distribution is a 4k configuration file and a 32k config file
<sect>Memory layout<p>
The ROMs and I/O areas are defined in the configuration files, as are most of the entry points for useful subroutines in the Sym-1 monitor ROM. cc65 generated programs compiled and linked using 4k config run in the memory range of &dollar;200 - &dollar;0FFF. The 32k config expands this range to &dollar;7FFF. The starting memory location and entry point for running the program is &dollar;200, so when the program is transferred to the Sym-1, it is executed by typing 'g 200'. The system returns control back to the monitor ROM when the program terminates, providing the '.' prompt.
The ROMs and I/O areas are defined in the configuration files, as are most of the entry points for useful subroutines in the Sym-1 monitor ROM. cc65 generated programs compiled and linked using 4k config run in the memory range of &dollar;200 - &dollar;0FFF. The 32k config expands this range to &dollar;7FFF. Memory above 32K can be used to extend the heap, as described below. The starting memory location and entry point for running the program is &dollar;200, so when the program is transferred to the Sym-1, it is executed by typing 'g 200'. The system returns control back to the monitor ROM when the program terminates, providing the '.' prompt.
Special locations:
@ -41,7 +41,7 @@ Special locations:
The C runtime stack is located at &dollar;0FFF on 4KB Syms, or at &dollar;7FFF for 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. Extended memory can be added to the heap, as described below.
</descrip><p>
@ -61,7 +61,7 @@ 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.
See the example program, symExtendedMemory, in the samples directory.
<sect1>Joystick drivers<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 &quot;stock&quot; 4KB Sym-1, except for symIO and symNotepad, which require 32KB. These sample programs can be found in the samples/sym1 directory:
All the samples will run on the &quot;stock&quot; 4KB Sym-1, except for symIO and symNotepad, which require 32KB. Additionally, symExtendedMemory shows how to access memory above 32KB, so it expects more than 32KB. These sample programs can be found in the samples/sym1 directory:
<itemize>
<item>symHello prints &quot;Hello World!&quot; and then inputs characters, which are echoed on the screen. It also makes a &quot;beep&quot; sound.</item>
@ -110,6 +110,7 @@ All the samples will run on the &quot;stock&quot; 4KB Sym-1, except for symIO an
<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>
<item>symExtendedMemory demonstrates how to access upper-memory and add it to the heap.</item>
</itemize>
<sect>License<p>

View File

@ -32,7 +32,7 @@ else
endif
EXELIST_sym1 = \
symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin
symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin symExtendedMemory.bin
ifneq ($(EXELIST_$(SYS)),)
samples: $(EXELIST_$(SYS))
@ -64,9 +64,14 @@ symIO.bin: symIO.c
symNotepad.bin: symNotepad.c
$(CL) -t sym1 -C sym1-32k.cfg -O -o symNotepad.bin symNotepad.c
symExtendedMemory.bin: symExtendedMemory.c
$(CL) -t sym1 -C sym1-32k.cfg -O -o symExtendedMemory.bin symExtendedMemory.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)
@$(DEL) symExtendedMemory.bin 2>$(NULLDEV)

View File

@ -0,0 +1,95 @@
// --------------------------------------------------------------------------
// Sym-1 Extended Memory
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
//
// Note: This program examines memory above the monitor ROM (8000-8FFF) to
// Determine what, if any, memory is available. It then adds whatever
// 4K segments it finds to the heap.
//
// Memory Segment Remark
// 0x9000 Usually available
// 0xA000 System I/O, always unavailable
// 0xB000 Used by RAE, but normally available
// 0xC000 Used by BASIC, normally unavailable
// 0xD000 Used by BASIC, normally unavailable
// 0xE000 Used by RAE, but normally available
// 0xF000 Normally available, but only to FF7F
//
// --------------------------------------------------------------------------
#include <sym1.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SEGMENT 0x9000 // First 4K segment of extended memory
#define SEG_END 0x0FFF // Last location of segment
#define BLOCK_SIZE 0x1000 // Size of segment
#define TOP_END 0x0F7F // Last location of memory
#define TOP_SIZE 0x0F80 // Size of top segment
#define UNAVAILABLE 0xA000 // System I/O area
int main (void) {
int error = 0;
unsigned heap_size = 0x0000;
char* segment = (char*) SEGMENT;
printf ( "Analyzing memory.\n\n" );
heap_size = _heapmemavail();
printf ( "Main memory has %d bytes available.\n", heap_size );
while ( (int) segment < 0xEFFF ) { // Iterate through 4K memory blocks
if( (int) segment != UNAVAILABLE ) {
segment[0] = 0x00; // Check beginning of segment
if ( segment[0] != 0x00 )
error = 1;
segment[0] = 0xFF;
if ( segment[0] != 0xFF )
error = 1;
segment[SEG_END] = 0x00; // Check end of segment
if ( segment[SEG_END] != 0x00 )
error = 1;
segment[SEG_END] = 0xFF;
if ( segment[SEG_END] != 0xFF )
error = 1;
if ( ! error ) { // If memory found, add to the heap
printf ( "Memory found at location %p, ", segment );
_heapadd ( segment, BLOCK_SIZE );
heap_size = _heapmemavail();
printf( "so the system now has %u bytes available.\n", heap_size );
} else {
error = 0;
}
}
segment += 0x1000; // Increment to next segment
}
segment[0] = 0x00; // Check beginning of top memory segment
if ( segment[0] != 0x00 )
error = 1;
segment[0] = 0xFF;
if ( segment[0] != 0xFF )
error = 1;
segment[TOP_END] = 0x00; // Check end of usable memory
if ( segment[TOP_END] != 0x00 )
error = 1;
segment[TOP_END] = 0xFF;
if ( segment[TOP_END] != 0xFF )
error = 1;
if ( ! error ) { // If memory found, add to the heap
printf ( "Memory found at location %p, ", segment );
_heapadd ( segment, TOP_SIZE );
heap_size = _heapmemavail();
printf( "so the system now has %u bytes available.\n", heap_size );
}
puts ("\nEnjoy your day!\n");
return 0;
}