http://jeelabs.org/2016/10/stm32f103-emulating-a-pdp-8/
Runs on YellowPill
I would use 110baud instead of less retro 115k2
BTW, if you are a retrocomputing fan and interested in porting RetroBSD or LiteBSD to STM32Fxx platform you may join
http://retrobsd.org/wiki/doku.php
// PDP-8 emulator
// -jcw, 2016-08-29
// Modded for STM32duino by Pito 11/2016
// . you need the Serial.printf() hack, hopefully it printfs Octals :)
// http://www.stm32duino.com/viewtopic.php?f=18&t=1014#p12014
// . place "focal.h" file to this pdp8.ino sketch for compilation (focal.h attached)
// . Serial1 used here
// . set Serial to 9600 (I do here with 115k2 but it is too fast, it seems)
// No warranties of any kind..
#include <stdio.h>
typedef unsigned short Word;
int errno, EIO;
int rxData = -1;
int txReady (void) {
return 1;
}
void txSend (char ch) {
while (!txReady()) // not strictly needed for emulation, only for printf
;
Serial1.print(ch);
}
const unsigned char program[] = {
#include "focal.h"
};
#define MEMSIZE 4096
Word pc, mem[MEMSIZE];
static Word mask(Word w) { return w & 07777; }
static Word lmask(Word w) { return w & 017777; }
static Word opAddr (int ir) {
Word a = ir & 0177;
if (ir & 0200)
a |= (pc - 1) & 07600;
if (ir & 0400) {
if ((a & 07770) == 010)
mem[a] = mask(mem[a] + 1);
a = mem[a];
}
return a;
}
static int loader (const unsigned char* ptr) {
Word addr = 0;
Serial1.printf("LOAD");
Word b;
for (;;) {
// read next word
b = *ptr++;
if (b & 0200) // skip run-in
continue;
b = (b << 6) | *ptr++;
// look for run-out, to ignore word before it as being a checksum
int c = *ptr;
if (c & 0200)
break;
// process one word
if (b & 010000) {
if (addr != 0)
Serial1.printf("-%04o", addr - 1);
addr = mask(b);
Serial1.printf(" %04o", addr);
} else
mem[addr++] = b;
}
Serial1.printf("-%04o CHECK %04o\n", mask(addr - 1), mask(b));
return addr;
}
void run () {
if (loader(program) == 0)
return;
pc = 0200;
Word sr = 0;
Word ac = 0, mq = 0;
int iena = 0;
for (;;) {
iena >>= 1; // delayed interrupt enabling, relies on sign extension
static short counter; // HACK: every 1024 ops, we fake an interrupt
if ((iena & 1) && (++counter & 0x03FF) == 0) {
mem[0] = pc;
pc = 1;
iena = 0;
}
int ir = mem[pc];
//if (argc >= 5)
// Serial1.printf("PC %04o IR %04o\r\n", pc, ir);
pc = mask(pc + 1);
switch ((ir >> 9) & 07) {
case 0: // AND
ac &= mem[opAddr(ir)] | 010000;
break;
case 1: // TAD
ac = lmask(ac + mem[opAddr(ir)]);
break;
case 2: { // ISZ
Word t = opAddr(ir);
mem[t] = mask(mem[t] + 1);
if (mem[t] == 0)
pc = mask(pc + 1);
break;
}
case 3: // DCA
mem[opAddr(ir)] = mask(ac);
ac &= 010000;
break;
case 4: { // JMS
Word t = opAddr(ir);
mem[t] = pc;
pc = mask(t + 1);
break;
}
case 5: // JMP
pc = opAddr(ir);
break;
case 6: // IOT
switch ((ir >> 3) & 077) {
case 00:
switch (ir) {
case 06001: iena = ~1; break; // delays one cycle
case 06002: iena = 0; break;
default: Serial1.printf("IOT %04o AC=%04o\r\n", ir, ac);
}
break;
case 03: // keyboard
if (Serial1.available() > 0)
rxData = Serial1.read();
if ((ir & 01) && rxData >= 0) // skip if ready
pc = mask(pc + 1);
if (ir & 04) { // read byte
int b = rxData & 0xFF;
rxData = -1;
ac = (ac & 010000) | b;
}
break;
case 04: // teleprinter
if ((ir & 01) && txReady()) // skip if ready
pc = mask(pc + 1);
if (ir & 04) // send byte
txSend(ac & 0177); // strip off parity
if (ir & 02) // clear flag
ac &= 010000;
break;
default:
//Serial1.printf("IOT %04o AC=%04o\r\n", ir, ac);
break;
}
break;
case 7: // OPR
if ((ir & 0400) == 0) { // group 1
if (ir & 0200) // CLA
ac &= 010000;
if (ir & 0100) // CLL
ac &= 07777;
if (ir & 040) // CMA
ac ^= 07777;
if (ir & 020) // CML
ac ^= 010000;
if (ir & 01) // IAC
ac = lmask(ac + 1);
switch (ir & 016) {
case 012: // RTR
ac = lmask((ac >> 1) | (ac << 12)); // fall through
case 010: // RAR
ac = lmask((ac >> 1) | (ac << 12));
break;
case 06: // RTL
ac = lmask((ac >> 12) | (ac << 1)); // fall through
case 04: // RAL
ac = lmask((ac >> 12) | (ac << 1));
break;
case 02: // BSW
ac = (ac & 010000) | ((ac >> 6) & 077)
| ((ac << 6) & 07700);
break;
}
} else if ((ir & 01) == 0) { // group 2
// SMA, SPA, SZA, SNA, SNL, SZL
int s = ((ir & 0100) && (ac & 04000)) ||
((ir & 040) && (ac & 07777) == 0) ||
((ir & 020) && (ac & 010000) != 0) ? 0 : 010;
if (s == (ir & 010))
pc = mask(pc + 1);
if (ir & 0200) // CLA
ac &= 010000;
if (ir & 04) // OSR
ac |= sr;
if (ir & 02) { // HLT
Serial1.printf("\r\nHALT %04o", mask(ac));
return;
}
} else { // group 3
Word t = mq;
if (ir & 0200) // CLA
ac &= 010000;
if (ir & 020) { // MQL
mq = ac & 07777;
ac &= 010000;
}
if (ir & 0100)
ac |= t;
}
break;
}
}
}
void setup() {
// put your setup code here, to run once:
Serial1.begin(115200);
run();
}
void loop() {
// put your main code here, to run repeatedly:
}
*ERASE ALL
*
* 1.01 C INTRST FROM FOCAL PROGRAMMING MANUAL PDP-15 SYSTEMS
* 1.02 C COPYRIGHT 1970 BY DIGITAL EQUPMENT CORP.
* 1.03 C REPRINTED BY PERMISSION OF DIGITAL EQUIPMENT CORP.
* 1.04 C LAST CHANGE: 8/9/71
* 1.05
* 1.06 C THIS PROGRAM WILL COMPUTE MONTHLY PAYMENTS AND THE
* 1.07 C CONTRIBUTION OF EACH PAYMENT TO INTEREST AND PRINCIPAL.
* 1.08 C YOU WILL BE ASKED THE AMOUNT OF THE PRINCIPAL, THE RATE
* 1.09 C OF THE INTEREST, AND THE TERM OF THE LOAN, WHICH IS IN
* 1.10 C MONTHS. THE PROGRAM WILL THEN OUTPUT A TABLE SHOWING
* 1.11 C THE PROGRESSION OF THE LOAN.
* 1.12
* 1.33 E
* 1.34 A "PRINCIPAL: ",PR,!"INTEREST RATE: ",IN
* 1.35 A !"TERM (IN MONTHS): ",TE,!!
* 1.40 S D=1+((IN/12)*.01)
* 1.41 F A=1,TE;D 15.99
* 1.42 S C=PR/B
* 1.50 S BA=PR
* 5.02 T "PRINCIPAL:",%7.02,PR,:30"PAYMENTS",C,!!!
* 5.05 T :5,"PAYMENT",:17,"INTEREST",:32,"PRINCIPAL",:50,"BALANCE",!
* 6.01 F M=1,TERM;D 7
* 6.02 T !!!,:20,"TOTAL INTEREST",%6.02,TO,!!!;G 1.33
* 7.01 S CI=BA*(IN/12)*.01
* 7.02 S TO=TO+CI
* 7.03 S CP=C-CI;S BA=BA-CP;T %7,M,%14.02,CI,CP,BA,!
*15.99 S B=B+(1/D^A)
*
*
* GO
PRINCIPAL: :100000
INTEREST RATE: :6.3
TERM (IN MONTHS): :120
100000.0= 0.00= 1125.33
= 0.00PAYMENT= 0.00INTEREST= 0.00PRINCIPAL= 0.00BALANCE
= 1= 525.00= 600.33= 99399.70
= 2= 521.85= 603.48= 98796.20
= 3= 518.68= 606.65= 98189.50
= 4= 515.50= 609.84= 97579.70
= 5= 512.29= 613.04= 96966.60
= 6= 509.08= 616.26= 96350.40
= 7= 505.84= 619.49= 95730.90
= 8= 502.59= 622.74= 95108.10
= 9= 499.32= 626.01= 94482.10
= 10= 496.03= 629.30= 93852.80
= 11= 492.73= 632.60= 93220.20
= 12= 489.41= 635.93= 92584.30
= 13= 486.07= 639.26= 91945.00
= 14= 482.71= 642.62= 91302.30
= 15= 479.34= 645.99= 90656.30
= 16= 475.95= 649.39= 90007.00
= 17= 472.54= 652.80= 89354.20
= 18= 469.11= 656.22= 88697.90
= 19= 465.67= 659.67= 88038.20
= 20= 462.20= 663.13= 87375.10
= 21= 458.72= 666.61= 86708.50
= 22= 455.22= 670.11= 86038.40
= 23= 451.70= 673.63= 85364.70
= 24= 448.17= 677.17= 84687.50
= 25= 444.61= 680.72= 84006.80
= 26= 441.04= 684.30= 83322.50
= 27= 437.44= 687.89= 82634.60
= 28= 433.83= 691.50= 81943.10
= 29= 430.20= 695.13= 81248.00
= 30= 426.55= 698.78= 80549.20
= 31= 422.88= 702.45= 79846.80
= 32= 419.20= 706.14= 79140.60
= 33= 415.49= 709.84= 78430.80
= 34= 411.76= 713.57= 77717.20
= 35= 408.02= 717.32= 76999.90
= 36= 404.25= 721.08= 76278.80
= 37= 400.46= 724.87= 75553.90
= 38= 396.66= 728.67= 74825.20
= 39= 392.83= 732.50= 74092.70
= 40= 388.99= 736.34= 73356.40
= 41= 385.12= 740.21= 72616.10
= 42= 381.24= 744.10= 71872.00
= 43= 377.33= 748.00= 71124.00
= 44= 373.40= 751.93= 70372.10
= 45= 369.45= 755.88= 69616.20
= 46= 365.49= 759.85= 68856.30
= 47= 361.50= 763.84= 68092.50
= 48= 357.49= 767.85= 67324.60
= 49= 353.46= 771.88= 66552.70
= 50= 349.40= 775.93= 65776.80
= 51= 345.33= 780.00= 64996.80
= 52= 341.23= 784.10= 64212.70
= 53= 337.12= 788.22= 63424.50
= 54= 332.98= 792.35= 62632.10
= 55= 328.82= 796.51= 61835.60
= 56= 324.64= 800.69= 61034.90
= 57= 320.43= 804.90= 60230.00
= 58= 316.21= 809.12= 59420.90
= 59= 311.96= 813.37= 58607.50
= 60= 307.69= 817.64= 57789.80
= 61= 303.40= 821.93= 56967.90
= 62= 299.08= 826.25= 56141.70
= 63= 294.74= 830.59= 55311.10
= 64= 290.38= 834.95= 54476.10
= 65= 286.00= 839.33= 53636.80
= 66= 281.59= 843.74= 52793.00
= 67= 277.16= 848.17= 51944.90
= 68= 272.71= 852.62= 51092.20
= 69= 268.24= 857.10= 50235.10
= 70= 263.74= 861.60= 49373.50
= 71= 259.21= 866.12= 48507.40
= 72= 254.66= 870.67= 47636.70
= 73= 250.09= 875.24= 46761.50
= 74= 245.50= 879.83= 45881.70
= 75= 240.88= 884.45= 44997.20
= 76= 236.24= 889.10= 44108.10
= 77= 231.57= 893.76= 43214.30
= 78= 226.88= 898.46= 42315.90
= 79= 222.16= 903.17= 41412.70
= 80= 217.42= 907.91= 40504.80
= 81= 212.65= 912.68= 39592.10
= 82= 207.86= 917.47= 38674.60
= 83= 203.04= 922.29= 37752.30
= 84= 198.20= 927.13= 36825.20
= 85= 193.33= 932.00= 35893.20
= 86= 188.44= 936.89= 34956.30
= 87= 183.52= 941.81= 34014.50
= 88= 178.58= 946.76= 33067.70
= 89= 173.61= 951.73= 32116.00
= 90= 168.61= 956.72= 31159.30
= 91= 163.59= 961.75= 30197.50
= 92= 158.54= 966.79= 29230.70
= 93= 153.46= 971.87= 28258.90
= 94= 148.36= 976.97= 27281.90
= 95= 143.23= 982.10= 26299.80
= 96= 138.07= 987.26= 25312.50
= 97= 132.89= 992.44= 24320.10
= 98= 127.68= 997.65= 23322.40
= 99= 122.44= 1002.89= 22319.60
= 100= 117.18= 1008.15= 21311.40
= 101= 111.89= 1013.45= 20297.90
= 102= 106.57= 1018.77= 19279.20
= 103= 101.22= 1024.12= 18255.10
= 104= 95.84= 1029.49= 17225.60
= 105= 90.44= 1034.90= 16190.70
= 106= 85.00= 1040.33= 15150.30
= 107= 79.54= 1045.79= 14104.50
= 108= 74.05= 1051.28= 13053.30
= 109= 68.53= 1056.80= 11996.50
= 110= 62.98= 1062.35= 10934.10
= 111= 57.41= 1067.93= 9866.18
= 112= 51.80= 1073.53= 8792.64
= 113= 46.16= 1079.17= 7713.47
= 114= 40.50= 1084.84= 6628.64
= 115= 34.80= 1090.53= 5538.11
= 116= 29.08= 1096.26= 4441.85
= 117= 23.32= 1102.01= 3339.84
= 118= 17.54= 1107.80= 2232.04
= 119= 11.72= 1113.61= 1118.43
= 120= 5.87= 1119.46=- 1.03
= 0.00TOTAL INTEREST= 35039.0
PRINCIPAL: :
LOAD 0000-6376 CHECK 7567
CHEKMO-II
W. YOUR MOVE?
HALT 0000

Its interesting to think that I can now get a $2 board to emulate a DEC machine which when introduced on March 22, 1965 was priced at $18,500 (equivalent to about $140,000 in 2015). Furthermore the $2 board consumes about a millionth of the power and occupies about a millionth of the space.
I wonder how easy it would be to emulate a Datageneral Nova.

+1 +0
stephen
+1 +0
stephen
Cheers, Ollie
Board+SdCard+Console and it works, somehow..
As I can read here a lot of people actually worked with the stuff, so if you may advice me what is going wrong with my box I would appreciate..
http://retrobsd.org/viewtopic.php?f=3&t … 038#p44038
At that point I think they were producing the DEC Alpha platform.
Digital Equipment Corporation (Scotland) Ltd., Mosshill Industrial Estate, Ayr, Scotland. KA6 6BE.
The plant now appears to produce cook ware and kitchens.
So much for the high tech boom of the 1980 and 90s.
don’t start me on Coral-66 compiler, finds an error and dumps file source remaining on end of the object file.
took me a while for that one.
stephen

![[Pending Enhancement] RTC values resetting](https://sparklogic.ru/wp-content/uploads/2019/11/nucleo-l476rg-zestaw-startowy-z-mikrokontrolerem-z-rodziny-stm32-stm32l476-90x90.jpg)
