1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-21 09:17:52 +00:00

Minor updates

This commit is contained in:
Wayne Parham
2022-03-04 06:23:06 -06:00
parent 7664a2f61e
commit 3cb85fd5e8
2 changed files with 108 additions and 66 deletions
+54 -48
View File
@@ -26,12 +26,13 @@
#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
#define STD_MEM 0x7FFF // Last address of standard memory
#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;
@@ -44,49 +45,54 @@ int main (void) {
printf ( "Main memory has %u 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
}
if ( heap_size > STD_MEM ) {
printf ( "Extended memory already installed.\n" );
} else {
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 );
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");