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

commiting old changes

This commit is contained in:
aap 2016-04-03 23:07:12 +02:00
parent 475a10d136
commit b0bfdf7400
6 changed files with 639 additions and 43 deletions

View File

@ -6,3 +6,7 @@ CFLAGS= -Wno-shift-op-parentheses -Wno-logical-op-parentheses\
pdp6: $(SRC) pdp6.h
$(CC) $(CFLAGS) $(SRC) -o pdp6
as: test.s
as10 <test.s
rim2mem <a.rim >mem

117
apr.c
View File

@ -78,26 +78,28 @@ decode_2xx(void)
apr.sac2 = 1;
}
if(apr.inst >= 0244 && apr.inst <= 0246)
apr.shift_op = (apr.inst & 0770) == 0240 &&
(apr.inst & 03) != 3;
if(apr.shift_op && apr.inst & 04)
apr.fac2 = apr.sac2 = 1;
if(apr.inst == 0250) /* EXCH */
if(apr.inst == EXCH)
apr.fc_e_pse = 1;
if((apr.inst & 0774) == 0254)
apr.fac_inh = 1;
if(apr.inst == 0256) /* XCT */
if(apr.inst == XCT)
apr.fac_inh = apr.fc_e = 1;
apr.ir_jp = (apr.inst & 0770) == 0260;
if(apr.ir_jp){
apr.e_long = 1;
if(apr.inst == 0260) /* PUSHJ */
if(apr.inst == PUSHJ)
apr.sc_e = apr.mb_pc_sto = 1;
if(apr.inst == 0261) /* PUSH */
if(apr.inst == PUSH)
apr.sc_e = apr.fc_e = 1;
if((apr.inst & 0776) == 0264) /* JSR, JSP */
apr.mb_pc_sto = apr.fac_inh = 1;
if(apr.inst == 0262 || apr.inst == 0264 || apr.inst == 266)
if(apr.inst == POP || apr.inst == JSR || apr.inst == JSA)
apr.sc_e = 1;
}
@ -245,6 +247,7 @@ bool
accp_et_al_test(void)
{
bool lt, cond;
// 5-9
lt = !!(apr.ar & SGN) != apr.ar_cry0_xor_cry1;
cond = (apr.inst & 2) && apr.ar == 0 ||
(apr.ir_accp || apr.ir_memac) && (apr.inst & 1) && lt;
@ -254,6 +257,7 @@ accp_et_al_test(void)
bool
selected_flag(void)
{
// 5-12
return apr.ir & 0400 && apr.ar_ov_flag ||
apr.ir & 0200 && apr.ar_cry0_flag ||
apr.ir & 0100 && apr.ar_cry1_flag ||
@ -263,6 +267,7 @@ selected_flag(void)
void
selected_flags_clr(void)
{
// 6-10
if(apr.ir & 0400) apr.ar_ov_flag = 0;
if(apr.ir & 0200) apr.ar_cry0_flag = 0;
if(apr.ir & 0100) apr.ar_cry1_flag = 0;
@ -282,6 +287,7 @@ pc_set_enable(void)
bool
pc_inc_enable(void)
{
// 5-12
return (apr.ir_accp || apr.ir_acbm || apr.ir_memac_mem) && accp_et_al_test() ||
apr.ir_iot && ((apr.inst & 0340) == 0300 && apr.ar == 0 ||
(apr.inst & 0340) == 0340 && apr.ar != 0);
@ -417,6 +423,7 @@ pulse(it1);
pulse(at1);
pulse(at0);
pulse(iat0);
pulse(et10);
pulse(mc_wr_rs);
pulse(mc_rd_rq_pulse);
pulse(mc_wr_rq_pulse);
@ -437,10 +444,10 @@ pulse(pi_reset){
pulse(ar_flag_clr){
trace("AR FLAG CLR\n");
apr.ar_pc_chg_flag = 0; // 6-10
apr.ar_ov_flag = 0; // 6-10
apr.ar_cry0_flag = 0; // 6-10
apr.ar_cry1_flag = 0; // 6-10
apr.ar_pc_chg_flag = 0; // 6-10
ar_cry();
apr.chf7 = 0; // 6-19
return NULL;
@ -448,18 +455,21 @@ pulse(ar_flag_clr){
pulse(ar_flag_set){
trace("AR FLAG SET\n");
apr.ar_pc_chg_flag = !!(apr.mb & 0040000000000); // 6-10
apr.ar_ov_flag = !!(apr.mb & 0400000000000); // 6-10
apr.ar_cry0_flag = !!(apr.mb & 0200000000000); // 6-10
apr.ar_cry1_flag = !!(apr.mb & 0100000000000); // 6-10
apr.ar_pc_chg_flag = !!(apr.mb & 0040000000000); // 6-10
ar_cry();
// TODO: what else?
apr.chf7 = !!(apr.mb & 0020000000000); // 6-19
if(apr.mb & 0010000000000)
set_ex_mode_sync(1); // 5-13
return NULL;
}
// TODO
pulse(mp_clr){
apr.chf5 = 0; // 6-19
apr.shf1 = 0; // 6-20
return NULL;
}
@ -501,6 +511,7 @@ pulse(mr_clr){
apr.sf7 = 0; // 5-6
apr.mc_rst1_ret = NULL;
apr.art3_ret = NULL;
apr.sct2_ret = NULL;
return NULL;
}
@ -544,6 +555,76 @@ pulse(st7){
return NULL;
}
/*
* Shift subroutines
*/
pulse(ar_sh_lt){
return NULL;
}
pulse(mq_sh_lt){
return NULL;
}
pulse(ar_sh_rt){
return NULL;
}
pulse(mq_sh_rt){
return NULL;
}
pulse(sct2){
trace("SCT2\n");
return apr.sct2_ret;
}
pulse(sct1){
trace("SCT1\n");
apr.sc = apr.sc+1 & 0777; // 6-16
// TODO: implement shifts
if(apr.shift_op && !(apr.mb & RSGN)){
ar_sh_lt();
mq_sh_lt();
}
if(apr.shift_op && (apr.mb & RSGN)){
ar_sh_rt();
mq_sh_rt();
}
if(apr.sc == 0777)
return sct2;
return sct1;
}
pulse(sct0){
trace("SCT0\n");
if(apr.sc == 0777)
return sct2;
return sct1;
}
pulse(sht1a){
trace("SHT1A\n");
apr.shf1 = 0; // 6-20
return et10;
}
pulse(sht1){
trace("SHT1\n");
if(apr.mb & 0400000)
apr.sc = ~apr.sc & 0777;
apr.shf1 = 1; // 6-20
apr.sct2_ret = sht1a;
return sct0;
}
pulse(sht0){
trace("SHT0\n");
apr.sc = apr.sc+1 & 0777; // 6-16
return NULL;
}
/*
* AR subroutines
*/
@ -859,6 +940,8 @@ pulse(et3){
apr.art3_ret = et4;
return ar_pm1_t0;
}
if(apr.shift_op)
return sht1;
return et4;
};
@ -901,6 +984,8 @@ pulse(et1){
apr.ar = 0; // 6-8
if(apr.inst == POPJ)
apr.ma = 0;
if(apr.shift_op && apr.mb & 0400000)
sht0(); // 6-20
if(apr.ir_acbm){
apr.mb &= apr.ar;
@ -915,11 +1000,11 @@ pulse(et1){
pulse(et0){
trace("ET0\n");
if(!(apr.ch_inc_op && apr.inst != IBP ||
apr.ch_n_inc_op && apr.inst != IBP ||
apr.ex_ir_uuo || apr.iot_blk || apr.inst == XCT ||
apr.key_execute && !apr.run || apr.pi_cyc))
apr.pc = apr.pc+1 & RT;
if(!((apr.ch_inc_op || apr.ch_n_inc_op) && apr.inst != IBP ||
apr.ex_ir_uuo || apr.iot_blk || apr.inst == BLT || apr.inst == XCT ||
apr.key_execute && !apr.run ||
apr.pi_cyc))
apr.pc = apr.pc+1 & RT; // 5-12
apr.ar_cry0 = 0; // 6-10
apr.ar_cry1 = 0; // 6-10
ar_cry();
@ -967,7 +1052,9 @@ pulse(et0a){
apr.hwt_10)
swap(&apr.mb, &apr.ar); // 6-3
if(apr.inst == POP || apr.inst == POPJ || apr.inst == JRA)
apr.mb = apr.mq;
apr.mb = apr.mq; // 6-3
if(apr.inst == FSC || apr.shift_op)
apr.sc |= ~apr.mb & 0377 | ~apr.mb>>9 & 0400; // 6-15
if(apr.ir_acbm && apr.inst & 1 ||
apr.inst == JSA)

4
main.c
View File

@ -366,6 +366,8 @@ Light ind_lights[] = {
{ lampsurf, { 143, 59, 14, 22 }, 0 },
{ lampsurf, { 143, 76, 14, 22 }, 0 },
{ lampsurf, { 143, 93, 14, 22 }, 0 },
{ lampsurf, { 319, 144, 14, 22 }, 0 },
{ lampsurf, { 319, 161, 14, 22 }, 0 },
};
Light extra_lights[] = {
@ -862,6 +864,8 @@ error:
ff_lght[49].state = apr.sf5a;
ff_lght[50].state = apr.sf7;
ff_lght[51].state = apr.ar_com_cont;
ff_lght[52].state = apr.shf1;
ff_lght[53].state = apr.sc == 0777;
setlights(membus0, membus_lght, 36);
setlights(apr.pr, pr_lght, 8);

537
mem
View File

@ -1,30 +1,515 @@
201040001134
000000000005
000000000010
000000000033
200600000011
0
0
0
20
0
4444
1234
777
777777377777
600000000000
400000000000
234100000001
200000000014
204000000014
210000000014
214000000015
500000000015
510000000015
520000000015
530000000015
534000000015
525000000015
430600000021
270500000013
270700000017
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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word *hold;
void
initfmem(void)
{
FILE *f;
word w;
hword a;
if(f = fopen("fmem", "r"), f == NULL)
return;
for(a = 0; a < 16 && fscanf(f, "%lo", &w) != EOF; a++)
fmem[a] = w;
fclose(f);
}
void
initmem(void)
{
@ -18,6 +31,7 @@ initmem(void)
for(a = 0; a < maxmem && fscanf(f, "%lo", &w) != EOF; a++)
memory[a] = w;
fclose(f);
initfmem();
}
void

6
pdp6.h
View File

@ -21,6 +21,7 @@ enum {
};
enum {
FSC = 0132,
IBP = 0133,
EXCH = 0250,
BLT = 0251,
@ -100,6 +101,7 @@ struct Apr {
bool et4_ar_pse;
bool chf5, chf7;
bool sf3, sf5a, sf7;
bool shf1;
/* temporaries */
bool ex_inh_rel;
@ -111,7 +113,7 @@ struct Apr {
bool ch_inc, ch_inc_op, ch_n_inc_op, ch_load, ch_dep;
bool ir_fwt, ir_fwt_swap;
bool fwt_00, fwt_01, fwt_10, fwt_11;
bool ir_md, ir_jp, ir_as;
bool shift_op, ir_md, ir_jp, ir_as;
bool ir_accp, ir_memac, ir_memac_mem, ir_memac_ac;
bool ir_boole;
bool boole_as_00, boole_as_01, boole_as_10, boole_as_11;
@ -130,7 +132,7 @@ struct Apr {
/* needed for the emulation */
int extpulse;
Pulse *nextpulse;
Pulse *mc_rst1_ret, *art3_ret;
Pulse *mc_rst1_ret, *art3_ret, *sct2_ret;
};
extern Apr apr;
void *aprmain(void *p);