1
0
mirror of https://github.com/aap/pdp6.git synced 2026-01-13 15:27:46 +00:00

better debugging tracing; fixed bug related to keys

This commit is contained in:
aap 2016-10-05 19:06:47 +02:00
parent 01be323fad
commit 2a67b180a8
10 changed files with 748 additions and 191 deletions

View File

@ -3,7 +3,7 @@ SRC=main.c apr.c mem.c tty.c
#CFLAGS= -Wno-shift-op-parentheses -Wno-logical-op-parentheses \
# -Wno-bitwise-op-parentheses
CFLAGS= -fno-diagnostics-show-caret \
-L/usr/local/lib -I/usr/local/include -lSDL -lSDL_image -lpthread
-L/usr/local/lib -I/usr/local/include -lSDL -lSDL_image -g -lpthread
pdp6: $(SRC) pdp6.h

82
apr.c
View File

@ -5,27 +5,15 @@ word iobus0, iobus1;
void (*iobusmap[128])(void);
u8 ioreq[128];
#define DBG_AR print("AR: %012llo\n", apr->ar)
#define DBG_MB print("MB: %012llo\n", apr->mb)
#define DBG_MQ print("MQ: %012llo\n", apr->mq)
#define DBG_MA print("MA: %06o\n", apr->ma)
#define DBG_IR print("IR: %06o\n", apr->ir)
#define DBG_AR debug("AR: %012llo\n", apr->ar)
#define DBG_MB debug("MB: %012llo\n", apr->mb)
#define DBG_MQ debug("MQ: %012llo\n", apr->mq)
#define DBG_MA debug("MA: %06o\n", apr->ma)
#define DBG_IR debug("IR: %06o\n", apr->ir)
int dotrace = 0;
int pulsestepping = 0;
Apr apr;
void
trace(char *fmt, ...)
{
va_list ap;
if(!dotrace)
return;
va_start(ap, fmt);
print(" ");
vfprintf(stdout, fmt, ap);
va_end(ap);
}
int pulsestepping = 0;
#define SWAPLTRT(a) (a = (a)<<18 & LT | (a)>>18 & RT)
#define CONS(a, b) ((a)&LT | (b)&RT)
@ -2486,11 +2474,11 @@ pulse(et0){
pulse(et0a){
static int gen = 0;
trace("ET0A\n");
print("%o: ", apr->pc);
debug("%o: ", apr->pc);
if((apr->inst & 0700) != 0700)
print("%d %s\n", gen++, names[apr->inst]);
debug("%d %s\n", gen++, names[apr->inst]);
else
print("%d %s\n", gen++, ionames[apr->io_inst>>5 & 7]);
debug("%d %s\n", gen++, ionames[apr->io_inst>>5 & 7]);
if(PI_HOLD)
set_pih(apr, apr->pi_req); // 8-3, 8-4
@ -2855,7 +2843,7 @@ pulse(mc_rq_pulse){
ma_ok = relocate(apr);
apr->mc_stop = 0; // 7-9
/* hack to catch non-existent memory */
apr->extpulse |= 4;
apr->extpulse |= EXT_NONEXIT_MEM;
if(ma_ok || apr->ex_inh_rel)
set_mc_rq(apr, 1); // 7-9
else
@ -3063,15 +3051,13 @@ aprmain(void *p)
apr->clist[i](apr);
/* KEY MANUAL */
if(apr->extpulse & 1){
apr->extpulse &= ~1;
// BUG: without a print somewhere the thing doesn't work :(
print("KEY MANUAL\n");
if(apr->extpulse & EXT_KEY_MANUAL){
apr->extpulse &= ~EXT_KEY_MANUAL;
nextpulse(apr, key_manual);
}
/* KEY INST STOP */
if(apr->extpulse & 2){
apr->extpulse &= ~2;
if(apr->extpulse & EXT_KEY_STOP){
apr->extpulse &= ~EXT_KEY_STOP;
apr->run = 0;
// hack: cleared when the pulse list was empty
apr->ia_inh = 1;
@ -3082,7 +3068,7 @@ aprmain(void *p)
* IOT INIT SET UP or IOT FINAL SETUP really */
if(apr->iot_go)
nextpulse(apr, iot_t2);
/* pulse and signals through IO bus */
/* pulses and signals through IO bus */
if(iobus1 & (IOBUS_PULSES | IOBUS_IOB_STATUS | IOBUS_IOB_DATAI)){
int dev = 0;
if(iobus1 & IOBUS_IOS3_1) dev |= 0100;
@ -3092,7 +3078,7 @@ aprmain(void *p)
if(iobus1 & IOBUS_IOS7_1) dev |= 0004;
if(iobus1 & IOBUS_IOS8_1) dev |= 0002;
if(iobus1 & IOBUS_IOS9_1) dev |= 0001;
//print("bus active for %o\n", dev<<2);
//debug("bus active for %o\n", dev<<2);
if(iobusmap[dev])
iobusmap[dev]();
// TODO: clear IOB STATUS and IOB DATAI too?
@ -3118,15 +3104,15 @@ aprmain(void *p)
/* Pulses from memory */
if(membus0 & MEMBUS_MAI_ADDR_ACK){
membus0 &= ~MEMBUS_MAI_ADDR_ACK;
apr->extpulse &= ~4;
apr->extpulse &= ~EXT_NONEXIT_MEM;
nextpulse(apr, mai_addr_ack);
}
if(membus0 & MEMBUS_MAI_RD_RS){
membus0 &= ~MEMBUS_MAI_RD_RS;
nextpulse(apr, mai_rd_rs);
}
if(apr->extpulse & 4){
apr->extpulse &= ~4;
if(apr->extpulse & EXT_NONEXIT_MEM){
apr->extpulse &= ~EXT_NONEXIT_MEM;
if(apr->mc_rq && !apr->mc_stop)
nextpulse(apr, mc_non_exist_mem); // 7-9
}
@ -3139,7 +3125,7 @@ aprmain(void *p)
}
}
print("power off\n");
debug("power off\n");
return NULL;
}
@ -3285,25 +3271,25 @@ testinst(Apr *apr)
// for(inst = 0140; inst < 0141; inst++){
apr->ir = inst << 9 | 1 << 5;
decodeir(apr);
print("%06o %6s ", apr->ir, names[inst]);
debug("%06o %6s ", apr->ir, names[inst]);
/*
print("%s ", FAC_INH ? "FAC_INH" : " ");
print("%s ", FAC2 ? "FAC2" : " ");
print("%s ", FC_C_ACRT ? "FC_C_ACRT" : " ");
print("%s ", FC_C_ACLT ? "FC_C_ACLT" : " ");
print("%s ", FC_E ? "FC_E" : " ");
debug("%s ", FAC_INH ? "FAC_INH" : " ");
debug("%s ", FAC2 ? "FAC2" : " ");
debug("%s ", FC_C_ACRT ? "FC_C_ACRT" : " ");
debug("%s ", FC_C_ACLT ? "FC_C_ACLT" : " ");
debug("%s ", FC_E ? "FC_E" : " ");
*/
print("%s ", FC_E_PSE ? "FC_E_PSE" : " ");
print("%s ", SC_E ? "SC_E" : " ");
print("%s ", SAC_INH ? "SAC_INH" : " ");
print("%s ", SAC2 ? "SAC2" : " ");
print("\n");
debug("%s ", FC_E_PSE ? "FC_E_PSE" : " ");
debug("%s ", SC_E ? "SC_E" : " ");
debug("%s ", SAC_INH ? "SAC_INH" : " ");
debug("%s ", SAC2 ? "SAC2" : " ");
debug("\n");
// FC_E_PSE
//print("FC_E_PSE: %d %d %d %d %d %d %d %d %d %d\n", apr->hwt_10 , apr->hwt_11 , apr->fwt_11 , \
//debug("FC_E_PSE: %d %d %d %d %d %d %d %d %d %d\n", apr->hwt_10 , apr->hwt_11 , apr->fwt_11 , \
// IOT_BLK , apr->inst == EXCH , CH_DEP , CH_INC_OP , \
// MEMAC_MEM , apr->boole_as_10 , apr->boole_as_11);
//print("CH: %d %d %d %d %d\n", CH_INC, CH_INC_OP, CH_N_INC_OP, CH_LOAD, CH_DEP);
//print("FAC_INH: %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
//debug("CH: %d %d %d %d %d\n", CH_INC, CH_INC_OP, CH_N_INC_OP, CH_LOAD, CH_DEP);
//debug("FAC_INH: %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
// apr->hwt_11 , apr->fwt_00 , apr->fwt_01 , apr->fwt_11 ,
// apr->inst == XCT , apr->ex_ir_uuo ,
// apr->inst == JSP , apr->inst == JSR ,

24
args.h Normal file
View File

@ -0,0 +1,24 @@
extern char *argv0;
#define USED(x) ((void)x)
#define SET(x) ((x)=0)
#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
argv[0] && argv[0][0]=='-' && argv[0][1];\
argc--, argv++) {\
char *_args, *_argt;\
char _argc;\
_args = &argv[0][1];\
if(_args[0]=='-' && _args[1]==0){\
argc--; argv++; break;\
}\
_argc = 0;\
while(*_args && (_argc = *_args++))\
switch(_argc)
#define ARGEND SET(_argt);USED(_argt);USED(_argc);USED(_args);}USED(argv);USED(argc);
#define ARGF() (_argt=_args, _args=(char*)"",\
(*_argt? _argt: argv[1]? (argc--, *++argv): 0))
#define EARGF(x) (_argt=_args, _args=(char*)"",\
(*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
#define ARGC() _argc

61
main.c
View File

@ -4,6 +4,33 @@
#include <pthread.h>
#include <time.h>
#include <unistd.h>
#include "args.h"
char *argv0;
FILE *debugfp;
int dotrace;
void
trace(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if(dotrace){
fprintf(debugfp, " ");
vfprintf(debugfp, fmt, ap);
}
va_end(ap);
}
void
debug(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(debugfp, fmt, ap);
va_end(ap);
}
SDL_Surface *screen;
@ -587,6 +614,8 @@ poweron(void)
pthread_create(&apr_thread, NULL, aprmain, &apr);
}
int tmpextpulse;
void
mouse(int button, int state, int x, int y)
{
@ -657,11 +686,11 @@ mouse(int button, int state, int x, int y)
case 4: /* deposit */
case 5: /* examine */
if(keys[i].state && apr.sw_power)
apr.extpulse |= 1;
tmpextpulse |= EXT_KEY_MANUAL;
break;
case 2: /* stop */
if(keys[i].state == 1) // inst
apr.extpulse |= 2;
tmpextpulse |= EXT_KEY_STOP;
break;
case 6: /* on off reader */
case 7: /* punch */
@ -683,8 +712,14 @@ wakepanel(void)
SDL_PushEvent(&user_event);
}
void
usage(void)
{
exit(1);
}
int
main()
main(int argc, char *argv[])
{
SDL_Event ev;
SDL_MouseButtonEvent *mbev;
@ -700,6 +735,23 @@ main()
// void testinst(Apr*);
// testinst(&apr);
debugfp = stdout;
//dotrace = 1;
ARGBEGIN{
case 't':
dotrace++;
break;
case 'd':
if(debugfp = fopen(EARGF(usage()), "w"), debugfp == nil){
fprintf(stderr, "Can't open debug file\n");
exit(1);
}
break;
default:
usage();
}ARGEND;
if(SDL_Init(SDL_INIT_VIDEO) < 0){
error:
fprintf(stderr, "error: %s\n", SDL_GetError());
@ -875,6 +927,7 @@ error:
apr.sw_rim_maint = rim_maint_sw->state;
apr.data = getswitches(data_sw, 36);
apr.mas = getswitches(ma_sw, 18);
apr.key_start = keys[0].state == 1;
apr.key_readin = keys[0].state == 2;
apr.key_inst_cont = keys[1].state == 1;
@ -891,6 +944,8 @@ error:
apr.key_rd_on = keys[6].state == 2;
apr.key_pt_rd = keys[7].state == 1;
apr.key_pt_wr = keys[7].state == 2;
apr.extpulse |= tmpextpulse;
tmpextpulse = 0;
setlights(apr.mb, mb_lght, 36);
setlights(apr.ar, ar_lght, 36);

640
mem
View File

@ -1,28 +1,612 @@
40: 254200000000
41: 254200000000
1000: 254000001102
1101: 777700001000
1102: 200740001101
1103: 260740001112
1104: 260740001120
1105: 201000000012
1106: 260740001120
1107: 201000000141
1110: 260740001120
1111: 254200000000
1112: 712240000000
1113: 606000000040
1114: 254000001112
1115: 712040000000
1116: 620000000200
1117: 263740000000
1120: 712240000001
1121: 602040000020
1122: 254000001120
1123: 435000000200
1124: 712140000000
1125: 302000000212
1126: 263740000000
1127: 201000000015
1130: 254000001120
1131: 000000000141
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
254200000000
254200000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
254000001102
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
777700001000
200740001101
260740001122
260740001130
201000000012
260740001130
201000000141
260740001130
254200000000
200200000000
200004000000
254200000000
350000000004
336000000000
263740000000
260740001130
254000001113
712240000000
606000000040
254000001122
712040000000
620000000200
263740000000
712240000001
602040000020
254000001130
435000000200
712140000000
302000000212
263740000000
201000000015
254000001130
141
142
143

View File

@ -15,14 +15,12 @@ SP: -PDLLEN,,PDL-1
START:
MOVE P,SP
MOVE 0,STR
PUSHJ P,PUTSTR
# PUSHJ P,GETCH
# PUSHJ P,PUTCHR
# MOVEI 0,"\n
# PUSHJ P,PUTCHR
# MOVEI 0,"a
# PUSHJ P,PUTCHR
PUSHJ P,GETCH
PUSHJ P,PUTCHR
MOVEI 0,"\n
PUSHJ P,PUTCHR
MOVEI 0,"a
PUSHJ P,PUTCHR
JRST 4,
PUTSTR:

12
pdp6.h
View File

@ -16,6 +16,11 @@ typedef uint8_t u8;
typedef unsigned char uchar;
typedef uchar bool;
extern FILE *debugfp;
extern int dotrace;
void trace(char *fmt, ...);
void debug(char *fmt, ...);
enum Mask {
FW = 0777777777777,
RT = 0000000777777,
@ -49,6 +54,13 @@ enum FullwordBits {
F33 = 0000000000004, F34 = 0000000000002, F35 = 0000000000001
};
/* external pulses, bits of Apr.extpulse */
enum Extpulse {
EXT_KEY_MANUAL = 1,
EXT_KEY_STOP = 2,
EXT_NONEXIT_MEM = 4
};
enum Opcode {
FSC = 0132,
IBP = 0133,

57
test.s
View File

@ -1,57 +0,0 @@
APR = 0
PI = 4
PI_RESET = 10000
PI_SET_PIR = 4000
PI_SET_PIO = 2000
PI_CLR_PIO = 1000
PI_CLR_ACT = 400
PI_SET_ACT = 200
. = 40
777777777777
JRST 4,
. = 1000
# CONI PI,1
# CONO PI,PI_RESET
# CONO PI,PI_SET_ACT|PI_SET_PIO|177
# DATAO APR,APR_PR_RLR
# DATAI APR,2
# CONI APR,1
# BLKI APR,TEST
# JRST 4,
# JRST .-2
# MOVE 0,BLTTEST
# BLT 0,BLTSPC+17
# XCT XCTTEST
# UUO04 3,BLAH
# LSH 7,9
# LSH 10,-9
# LSHC 11,6
# LSH 3,3
# LSH 4,-3
# ASH 5,3
# ASH 6,-3
# LSHC 7,3
# LSHC 11,-3
# ASHC 13,3
# ASHC 15,-3
ROT 3,3
ROT 4,-3
ROTC 5,3
ROTC 7,-3
JRST 4,
TEST:
-5,,TEST+1
. = . + 10
XCTTEST:
MOVEI 0,4321
BLTSPC:
. = . + 20
APR_PR_RLR:
321321123123
BLTTEST:
1,,BLTSPC
BLAH:
1234,,4321

1
tty.c
View File

@ -65,6 +65,7 @@ ttythread(void *arg)
printf("TTY attached\n");
tty.fd = newsockfd;
while(n = read(tty.fd, &buf, 1), n > 0){
fprintf(stderr, "(got.%c)", buf);
tty.tti = buf|0200;
tty.tti_flag = 1;
recalc_tty_req();

View File

@ -1,46 +0,0 @@
P=17
TTY=120
PDLLEN=100
.=40
JRST 4,
JRST 4,
.=1000
ENTRY: JRST START
PDL: .=.+PDLLEN
SP: -PDLLEN,,PDL-1
START:
MOVE P,SP
PUSHJ P,GETCH
PUSHJ P,PUTCHR
MOVEI 0,"\n
PUSHJ P,PUTCHR
MOVEI 0,"a
PUSHJ P,PUTCHR
JRST 4,
GETCH:
CONI TTY,0
TRNN 0,40
JRST .-2
DATAI TTY,0
TRZ 0,200
POPJ P,
PUTCHR:
CONI TTY,1
TRNE 1,20
JRST .-2
IORI 0,200
DATAO TTY,0
CAIE 0,"\n|200
POPJ P,
MOVEI 0,"\r
JRST PUTCHR
STR:
"a