1
0
mirror of https://github.com/prirun/p50em.git synced 2026-01-27 04:02:12 +00:00

condition code macros

mem array is segment addressable
start of boot support
use CC macros and BCxx to emulate Bxyy (eg, BFLT)
use CC macros and LCxx to emulate Lxyy (eg, LFLT)
shift instruction work
This commit is contained in:
Jim
2005-04-28 00:00:00 -04:00
parent 9291d9e864
commit ff3fd68935
4 changed files with 1408 additions and 404 deletions

150
emdev.h
View File

@@ -1,3 +1,62 @@
/* emdev.h, Jim Wilcoxson, April 17, 2005
Device handlers for pio instructions. Use devnull as a template for
new handlers.
NOTES:
OCP instructions never skip
SKS instructions skip on specified conditions
INA/OTA instructions skip if they succeed (data was read/written)
*/
#include <fcntl.h>
void devnull (short class, short func, short device) {
switch (class) {
case 0:
fprintf(stderr," OCP '%2#0o%2#0o\n", func, device);
if (func == 0) {
;
} else {
fprintf(stderr," unimplemented OCP device %2#0o function\n", device);
exit(1);
}
break;
case 1:
fprintf(stderr," SKS '%2#0o%2#0o\n", func, device);
if (func == 0)
mem[P]++; /* assume it's always ready */
else {
fprintf(stderr," unimplemented SKS device %2#0o function\n", device);
exit(1);
}
break;
case 2:
fprintf(stderr," INA '%2#0o%2#0o\n", func, device);
if (func == 0) {
;
} else {
fprintf(stderr," unimplemented INA device %2#0o function\n", device);
exit(1);
}
break;
case 3:
fprintf(stderr," OTA '%2#0o%2#0o\n", func, device);
if (func == 0 | func == 1) {
mem[P]++; /* OTA '0004 always works on Unix */
} else {
fprintf(stderr," unimplemented OTA device %2#0o function\n", device);
exit(1);
}
break;
}
}
/* Device '4: system console
OCP '0004 = initialize for input only, echoplex, 110 baud, 8-bit, no parity
@@ -10,16 +69,15 @@
*/
#include <fcntl.h>
void devasr (unsigned short class, unsigned short func) {
void devasr (short class, short func, short device) {
static int ttydev=-1;
unsigned char ch;
int ttyflags, newflags;
int n;
if (ttydev < 0) {
ttydev = open("/dev/tty", O_RDWR+O_NONBLOCK, 0);
ttydev = open("/dev/tty", O_RDWR, 0);
if (ttydev < 0) {
perror(" error opening /dev/tty");
exit(1);
@@ -29,11 +87,11 @@ void devasr (unsigned short class, unsigned short func) {
switch (class) {
case 0:
fprintf(stderr," OCP '%o04\n", func);
fprintf(stderr," OCP '%2#0o%2#0o\n", func, device);
break;
case 1:
fprintf(stderr," SKS\n");
fprintf(stderr," SKS '%2#0o%2#0o\n", func, device);
if (func <= 7)
mem[P]++; /* assume it's always ready */
else {
@@ -43,9 +101,20 @@ void devasr (unsigned short class, unsigned short func) {
break;
case 2:
fprintf(stderr," INA\n");
fprintf(stderr," INA '%2#0o%2#0o\n", func, device);
if (func == 0 || func == 010) {
usleep(100000);
if (fcntl(ttydev, F_GETFL, ttyflags) == -1) {
perror(" unable to get tty flags");
exit(1);
}
if (mem[mem[P]] == 03776) /* JMP *-1 -> blocking read */
newflags = ttyflags & ~O_NONBLOCK;
else
newflags = ttyflags | O_NONBLOCK;
if (fcntl(ttydev, F_SETFL, newflags) == -1) {
perror(" unable to set tty flags");
exit(1);
}
n = read(ttydev, &ch, 1);
if (n < 0) {
if (errno != EAGAIN) {
@@ -53,13 +122,19 @@ void devasr (unsigned short class, unsigned short func) {
exit(1);
}
} else if (n == 1) {
mem[A] = ch | 0x80;
if (func >= 010)
mem[A] = 0;
mem[A] = mem[A] | ch | 0x80;
mem[P]++;
} else if (n != 0) {
fprintf(stderr," unexpected error reading from tty, n=%d", n);
exit(1);
}
} else if (func == 012) { /* no idea what this does... */
} else if (func == 011) { /* read device id? */
mem[A] = 4;
mem[P]++;
} else if (func == 012) { /* read control word */
mem[A] = 04110;
mem[P]++;
} else {
fprintf(stderr," unimplemented INA '04 function\n");
@@ -68,12 +143,14 @@ void devasr (unsigned short class, unsigned short func) {
break;
case 3:
fprintf(stderr," OTA\n");
if (func == 0 | func == 1) {
fprintf(stderr," OTA '%2#0o%2#0o\n", func, device);
if (func == 0) {
fprintf(stderr," char to write=%o\n", mem[A]);
putchar(mem[A] & 0x7f);
fflush(stdout);
mem[P]++; /* OTA '0004 always works on Unix */
} else if (func == 1) { /* write control word */
mem[P]++;
} else {
fprintf(stderr," unimplemented OTA '04 function\n");
exit(1);
@@ -82,3 +159,52 @@ void devasr (unsigned short class, unsigned short func) {
}
}
/* Device '20: control panel switches and lights
OTA '1720 = write to lights (sets CP fetch address)
INA '1420 = read location from CP ROM (not implemented, used to boot)
INA '1620 = read control panel switches
*/
void devcp (short class, short func, short device) {
switch (class) {
case 0:
fprintf(stderr," OCP '%2#0o%2#0o\n", func, device);
fprintf(stderr," unimplemented OCP device %2#0o function\n", device);
exit(1);
break;
case 1:
fprintf(stderr," SKS '%2#0o%2#0o\n", func, device);
fprintf(stderr," unimplemented SKS device %2#0o function\n", device);
exit(1);
break;
case 2:
fprintf(stderr," INA '%2#0o%2#0o\n", func, device);
if (func == 016) {
mem[A] = 0;
} else {
fprintf(stderr," unimplemented INA device %2#0o function\n", device);
exit(1);
}
break;
case 3:
fprintf(stderr," OTA '%2#0o%2#0o\n", func, device);
if (func == 017) { /* write lights */
mem[P]++;
} else {
fprintf(stderr," unimplemented OTA device %2#0o function\n", device);
exit(1);
}
break;
}
}