From f73bb4e372604261a24c158d536105968844b78e Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 25 Apr 2016 21:02:18 +0200 Subject: [PATCH] implemented FSC --- apr.c | 38 +++++++++++++++++++++++++++++++++++++- main.c | 29 +++++++++++++++++++++++++++++ mem | 19 +++++++------------ pdp6.h | 5 +++++ 4 files changed, 78 insertions(+), 13 deletions(-) diff --git a/apr.c b/apr.c index 1460c07..15697c6 100644 --- a/apr.c +++ b/apr.c @@ -39,6 +39,7 @@ swap(word *a, word *b) #define AR_OV_SET (apr->ar_cry0 != apr->ar_cry1) #define AR0_XOR_AROV (!!(apr->ar & F0) != apr->ar_cry0_xor_cry1) #define AR0_XOR_AR1 (!!(apr->ar & F0) != !!(apr->ar & F1)) +#define AR0_EQ_SC0 (!!(apr->ar & F0) == !!(apr->sc & 0400)) #define SET_OVERFLOW apr->ar_ov_flag = 1, recalc_cpa_req(apr) // 6-13 @@ -473,6 +474,7 @@ pulse(lct0a); pulse(dct0a); pulse(mst2); pulse(mpt0a); +pulse(fst0a); // TODO: find A LONG, it probably doesn't exist @@ -532,6 +534,7 @@ pulse(ds_clr){ apr->dsf6 = 0; apr->dsf8 = 0; apr->dsf9 = 0; + apr->fsf1 = 0; // 6-19 } pulse(mr_clr){ @@ -884,6 +887,7 @@ pulse(blt_t0){ #define SC_INC apr->sc = apr->sc+1 & 0777 #define SC_DATA (apr->chf1 ? ~apr->mb>>30 & 077 | 0700 : \ apr->chf2 ? apr->mb>>24 & 077 : \ + apr->fsf1 || 0 ? apr->ar>>27 & 0777 : \ 0) // TODO #define SC_PAD apr->sc ^= SC_DATA #define SC_CRY apr->sc += (~apr->sc & SC_DATA) << 1 @@ -1000,6 +1004,7 @@ pulse(sct0){ pulse(sat3){ trace("SAT3\n"); if(apr->chf2) nextpulse(apr, cht3a); // 6-19 + if(apr->fsf1) nextpulse(apr, fst0a); // 6-19 } pulse(sat2_1){ @@ -1534,6 +1539,30 @@ pulse(nrt6){ nextpulse(apr, et10); // 5-5 } +/* + * Floating scale + */ + +pulse(fst1){ + trace("FST1\n"); + SC_INC; // 6-16 +} + +pulse(fst0a){ + trace("FST0A\n"); + apr->fsf1 = 0; // 6-19 + if(!AR0_EQ_SC0) + SET_OVERFLOW; // 6-17 + apr->ar |= apr->ar&0400777777777 | (apr->sc&0377)<<27; // 6-4 + nextpulse(apr, et10); // 5-5 +} + +pulse(fst0){ + trace("FST0\n"); + apr->fsf1 = 1; // 6-19 + nextpulse(apr, sat0); // 6-16 +} + /* * Fixed point multiply */ @@ -1991,13 +2020,20 @@ pulse(et3){ if(AR_P1) nextpulse(apr, ar_pm1_t1); + if(IR_FPCH && !(apr->ir & H3) && + (apr->inst == 0130 || apr->inst == 0131 || !(apr->ir & H4) || !(apr->ir & H5))) + nextpulse(apr, st7); // 5-6 if(apr->inst == BLT) nextpulse(apr, blt_t0); // 6-18 if(apr->shift_op) nextpulse(apr, sht1); // 6-20 + if(apr->inst == FSC){ + if(apr->ar & F0) + nextpulse(apr, fst1); // 6-19 + nextpulse(apr, fst0); // 6-19 + } if(apr->inst == XCT) nextpulse(apr, xct_t0); // 5-10 - // FSC if(AR_SBR) apr->et4_ar_pse = 1; // 5-5 if(!ET4_INH) diff --git a/main.c b/main.c index 0250a76..d21e45d 100644 --- a/main.c +++ b/main.c @@ -3,6 +3,35 @@ #include #include +word dtopdp(double d){ + uint64_t x, s, e, m; + word f; + x = *(uint64_t*)&d; + s = (x >> 63) & 1; + e = (x >> 52) & 0x7FF; + m = x & 0xFFFFFFFFFFFFF; + e -= 1023; + e += 128; + m >>= 25; + f = s << 35; + f |= e << 27; + f |= m; + return f; +} +double pdptod(word f){ + uint64_t x, s, e, m; + s = (f >> 35) & 1; + e = (f >> 27) & 0377; + m = f & 0777777777; + e -= 128; + e += 1023; + m <<= 25; + x = s << 63; + x |= e << 52; + x |= m; + return *(double*)&x; +} + SDL_Surface *screen; SDL_Surface *keysurf[3]; diff --git a/mem b/mem index e206948..ad9f964 100644 --- a/mem +++ b/mem @@ -1,12 +1,7 @@ -1000: 200000001006 -1001: 200040001007 -1002: 234000001010 -1003: 254200000000 -1004: 777777777742 -1005: 777777777766 -1006: 777777777777 -1007: 777777777771 -1010: 777777777775 -1011: 777777777777 -1012: 777777777772 -1013: 777777777775 +1000: 200000001003 +1001: 132000000001 +1002: 254200000000 +1003: 200000000000 +1004: 600000000000 +1005: 200400000000 +1006: 577400000000 diff --git a/pdp6.h b/pdp6.h index e5911d8..9066c91 100644 --- a/pdp6.h +++ b/pdp6.h @@ -15,6 +15,10 @@ typedef uint16_t u16; typedef uint8_t u8; typedef char bool; +/* convert between PDP-6 float and ieee double */ +word dtopdp(double d); +double pdptod(word f); + enum Mask { FW = 0777777777777, RT = 0000000777777, @@ -162,6 +166,7 @@ struct Apr { bool mpf1, mpf2; bool msf1; bool dsf1, dsf2, dsf3, dsf4, dsf5, dsf6, dsf7, dsf8, dsf9; + bool fsf1; bool iot_f0a; bool blt_f0a, blt_f3a, blt_f5a; bool uuo_f1;