1
0
mirror of https://github.com/aap/pdp6.git synced 2026-01-13 23:37:09 +00:00

memory files

This commit is contained in:
aap 2016-04-15 01:19:00 +02:00
parent dd450b9298
commit f41c186d88
4 changed files with 36 additions and 523 deletions

1
main.c
View File

@ -775,6 +775,7 @@ error:
mbev->x, mbev->y);
break;
case SDL_QUIT:
dumpmem();
SDL_Quit();
return 0;
}

513
mem
View File

@ -1,515 +1,4 @@
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
:1000
240040000005
240040777773
201040001234

41
mem.c
View File

@ -1,4 +1,5 @@
#include "pdp6.h"
#include <ctype.h>
word memory[256*1024];
//hword maxmem = 256*1024;
@ -8,30 +9,48 @@ word membus0, membus1;
word *hold;
void
initfmem(void)
readmem(char *file, word *mem, word size)
{
FILE *f;
word w;
char buf[100], *s;
hword a;
if(f = fopen("fmem", "r"), f == NULL)
if(f = fopen(file, "r"), f == nil)
return;
for(a = 0; a < 16 && fscanf(f, "%lo", &w) != EOF; a++)
fmem[a] = w;
a = 0;
while(s = fgets(buf, 100, f)){
while(*s){
if(*s == ':')
a = strtol(s+1, &s, 8);
else if('0' <= *s && *s <= '7' &&
a < size)
mem[a++] = strtol(s, &s, 8);
else
s++;
}
}
fclose(f);
}
void
initmem(void)
{
FILE *f;
word w;
readmem("mem", memory, maxmem);
readmem("fmem", fmem, 16);
}
void
dumpmem(void)
{
hword a;
if(f = fopen("mem", "r"), f == NULL)
FILE *f;
if(f = fopen("memdump", "w"), f == nil)
return;
for(a = 0; a < maxmem && fscanf(f, "%lo", &w) != EOF; a++)
memory[a] = w;
for(a = 0; a < 16; a++)
fprint(f, ":%02o %012llo\n", a, fmem[a]);
for(a = 0; a < maxmem; a++)
fprint(f, ":%06o %012llo\n", a, memory[a]);
fclose(f);
initfmem();
}
/* When a cycle is requested we acknowledge the address

4
pdp6.h
View File

@ -4,6 +4,9 @@
#include <stdarg.h>
#define nelem(a) (sizeof(a)/sizeof(a[0]))
#define nil NULL
#define print printf
#define fprint fprintf
typedef uint64_t word;
typedef uint32_t hword;
@ -188,6 +191,7 @@ void nextpulse(Apr *apr, Pulse *p);
void *aprmain(void *p);
void initmem(void);
void dumpmem(void);
void wakemem(void);
// 7-2, 7-10
enum {