1
0
mirror of https://github.com/aap/pdp6.git synced 2026-02-26 08:54:02 +00:00

emu: implemented SBLK load; fixed a couple of bugs

This commit is contained in:
aap
2019-01-20 23:10:48 +01:00
parent 8b0849d160
commit aec208c1a7
6 changed files with 160 additions and 18 deletions

View File

@@ -685,13 +685,13 @@ defpulse(ar_flag_clr)
defpulse(ar_flag_set)
{
apr->ar_ov_flag = !!(apr->mb & F0); // 6-10
apr->ar_cry0_flag = !!(apr->mb & F1); // 6-10
apr->ar_cry1_flag = !!(apr->mb & F2); // 6-10
apr->ar_pc_chg_flag = !!(apr->mb & F3); // 6-10
apr->chf7 = !!(apr->mb & F4); // 6-19
if(apr->mb & F5)
apr->ex_mode_sync = 1; // 5-13
// 6-10
if(apr->mb & F0) apr->ar_ov_flag = 1;
if(apr->mb & F1) apr->ar_cry0_flag = 1;
if(apr->mb & F2) apr->ar_cry1_flag = 1;
if(apr->mb & F3) apr->ar_pc_chg_flag = 1;
if(apr->mb & F4) apr->chf7 = 1; // 6-19
if(apr->mb & F5) apr->ex_mode_sync = 1; // 5-13
recalc_cpa_req(apr);
}
@@ -2411,10 +2411,9 @@ defpulse_(et10)
swap(&apr->mb, &apr->ar); // 6-3
if(MEMAC || apr->ir_as){
// 6-10
apr->ar_cry0_flag = apr->ar_cry0;
apr->ar_cry1_flag = apr->ar_cry1;
if(apr->ar_cry0) apr->ar_cry0_flag = 1;
if(apr->ar_cry1) apr->ar_cry1_flag = 1;
}
if(apr->ir_fwt && !apr->ar_cry0 && apr->ar_cry1 ||
(MEMAC || apr->ir_as) && AR_OV_SET){
apr->ar_ov_flag = 1; // 6-10
@@ -2677,8 +2676,6 @@ defpulse(et0a)
debug("%s\n", mnemonics[apr->inst]);
else
debug("%s\n", iomnemonics[apr->io_inst>>5 & 7]);
if(apr->inst == 0)
exit(0);
if(PI_HOLD)
set_pih(apr, apr->pi_req); // 8-3, 8-4
@@ -3034,6 +3031,7 @@ defpulse(mc_rq_1)
defpulse(mc_stop_1)
{
// TODO: it's important this pulse come *before* MC RS T0
apr->mc_stop = 1; // 7-9
if(apr->key_mem_cont)
pulse(apr, &kt4, 0); // 5-2
@@ -3351,11 +3349,11 @@ aprcycle(void *p)
if(apr->membus.c12 & MEMBUS_MAI_ADDR_ACK){
apr->membus.c12 &= ~MEMBUS_MAI_ADDR_ACK;
apr->extpulse &= ~EXT_NONEXIT_MEM;
pulse(apr, &mai_addr_ack, 1);
pulse(apr, &mai_addr_ack, 200);
}
if(apr->membus.c12 & MEMBUS_MAI_RD_RS){
apr->membus.c12 &= ~MEMBUS_MAI_RD_RS;
pulse(apr, &mai_rd_rs, 1);
pulse(apr, &mai_rd_rs, 200);
}
if(apr->mc_rd && apr->membus.c34){
/* 7-6, 7-9 */

View File

@@ -484,7 +484,9 @@ void updatepanel(Apr *apr);
enum
{
FmtUnk, FmtSav
FmtUnk,
FmtSav,
FmtSblk
};
static void
@@ -502,10 +504,57 @@ loadsav(FILE *fp)
iowd += 01000001;
w = readwbak(fp);
if(w == ~0)
return;
goto format;
dep(right(iowd), 0, w);
}
}
format:
printf("SAV format botch\n");
}
static void
loadsblk(FILE *fp)
{
word iowd, w, chk;
int d;
/* Skip RIM loader */
while(w = readwits(fp), w != ~0)
if(w == 0254000000001)
goto sblk;
goto format;
sblk:
/* Read a simple block */
while(w = readwits(fp), w != ~0){
/* We expect an AOBJN word here */
if((w & F0) == 0)
goto end;
iowd = w;
chk = iowd;
d = right(iowd) != 0; /* 0 is symbol table */
while(left(iowd) != 0){
w = readwits(fp);
if(w == ~0)
goto format;
chk = (chk<<1 | chk>>35) + w & FW;
dep(right(iowd), 0, w);
iowd += 01000001;
}
if(readwits(fp) != chk)
goto format;
}
goto format;
end:
w = readwits(fp);
if(left(w) != 0324000)
goto format;
apr->pc = right(w);
return;
format:
printf("SBLK format botch\n");
}
static void
@@ -520,6 +569,9 @@ c_load(int argc, char *argv[])
case 's':
fmt = FmtSav;
break;
case 'b':
fmt = FmtSblk;
break;
}ARGEND;
if(argc < 1)
return;
@@ -529,8 +581,10 @@ c_load(int argc, char *argv[])
printf("couldn't open file: %s\n", argv[0]);
return;
}
if(fmt == FmtSav)
loadsav(fp);
switch(fmt){
case FmtSav: loadsav(fp); break;
case FmtSblk: loadsblk(fp); break;
}
fclose(fp);
}

View File

@@ -33,3 +33,4 @@ attach ptr ../code/test.rim
attach ptp ../code/ptp.out
#attach dx0 ../test/out.dt6
attach dx0 ../test/test.dt6

View File

@@ -71,6 +71,7 @@ err(char *fmt, ...)
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
printf("ERRRRR\n");
exit(1);
}

View File

@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
@@ -63,6 +64,92 @@ readwbak(FILE *fp)
((word)buf[4]&0200) >> 7;
}
/* read word in ITS evacuate format. */
static int leftover = -1;
word
readwits(FILE *fp)
{
#define PUSH(x) w = (w<<7) | ((x) & 0177); bits += 7
int o;
word w;
int bits;
if(feof(fp))
return ~0;
w = 0;
bits = 0;
if(leftover >= 0){
w = leftover;
bits = 7;
leftover = -1;
}
while(bits < 36){
o = getc(fp);
if(o == EOF)
if(bits == 0)
return ~0;
if(o == 012){
PUSH(015);
PUSH(012);
}else if(o == 015){
PUSH(012);
}else if(o <= 0176){
PUSH(o);
}else if(o == 0177){
PUSH(0177);
PUSH(7);
}else if(o == 0207){
PUSH(0177);
PUSH(0177);
}else if(o == 0212){
PUSH(0177);
PUSH(015);
}else if(o == 0215){
PUSH(0177);
PUSH(012);
}else if(o <= 0355){
PUSH(0177);
PUSH(o - 0200);
}else if(o == 0356){
PUSH(015);
}else if(o == 0357){
PUSH(0177);
}else{
if(bits != 0){
fprintf(stderr, "[error in 36-bit file format]\n");
exit(1);
}
w = o & 017;
w = (w << 8) | getc(fp);
w = (w << 8) | getc(fp);
w = (w << 8) | getc(fp);
w = (w << 8) | getc(fp);
bits = 36;
}
if(bits == 35){
w <<= 1;
bits++;
}else if(bits == 42){
leftover = w & 0177;
w >>= 7;
w <<= 1;
}
}
if(w > 0777777777777){
fprintf(stderr, "[error in 36-bit file format (word too large)]\n");
exit(1);
}
return w;
}
/* decompose a double into sign, exponent and mantissa */
void
decompdbl(double d, int *s, word *e, uint64_t *m)

View File

@@ -12,6 +12,7 @@ void writew(word w, FILE *fp);
word readw(FILE *fp);
void writewbak(word w, FILE *fp);
word readwbak(FILE *fp);
word readwits(FILE *fp);
void decompdbl(double d, int *s, word *e, uint64_t *m);
word dtopdp(double d);