vak: (бэсм-6)
The CDC 1604, developed by Control Data Corporation, was a significant computer in the early 1960s, widely used for scientific computing. Regarding whether the CDC 1604 was supplied with the source code for its Fortran compiler, the available evidence and historical context suggest the following:

1. Standard Practice for CDC Fortran Compilers:

  • Control Data Corporation typically provided Fortran compilers for its systems, including the CDC 1604, as Fortran was a dominant programming language for scientific applications at the time. The CDC 1604 supported a Fortran compiler, often based on or derived from the original Fortran II or Fortran IV standards, tailored to the CDC 1604’s 48-bit architecture.

2. Source Code Availability:

  • In the early 1960s, it was common for computer manufacturers like CDC to supply source code for system software, including compilers, to customers, especially for scientific institutions like the Joint Institute for Nuclear Research (JINR) in Dubna. This was because:
    • Customers often needed to modify or optimize compilers for specific applications or hardware configurations.
    • Academic and research institutions, such as JINR, frequently had skilled programmers capable of adapting software.
    • The open nature of early computing encouraged sharing of source code to facilitate customization.
  • While direct documentation confirming the inclusion of Fortran source code with the CDC 1604 at JINR is scarce, CDC’s general practice and the needs of research institutions strongly suggest that the Fortran compiler’s source code was likely provided or available upon request. This would have enabled JINR’s programmers, under leaders like Nikolay Govorun, to adapt the compiler for their heterogeneous computing environment.

3. JINR’s Context and Govorun’s Work:

  • At JINR, Nikolay Govorun and his team were actively involved in developing and adapting software for various systems, including the CDC 1604A. Their work included creating Fortran translators (e.g., for the BESM-6) and adopting international standards like CERN’s Fortran software. This implies that JINR had access to or could modify the Fortran compiler for the CDC 1604, which would be feasible if source code was supplied or if they reverse-engineered or reimplemented parts of it.
  • A 1986 JINR document mentions the use of CDC 1604A and CDC 6500 systems for data processing, indicating significant software customization. Access to the Fortran compiler’s source code would have been critical for integrating these systems into JINR’s computing complex.

4. Historical Precedent:

  • Other institutions using CDC systems, such as universities or government labs in the U.S., often received source code for system software. For example, the University of Wisconsin’s CDC 1604 users contributed to software development, suggesting source code availability. Given JINR’s status as a prestigious international research center, it’s plausible that CDC provided similar access to facilitate scientific collaboration, even across Cold War divides.

5. Caveats:

  • Exact contractual details of the CDC 1604’s delivery to JINR (around 1963–1965) are not publicly documented, and export restrictions during the Cold War may have influenced what was supplied. However, scientific exchanges and JINR’s international status likely mitigated such barriers, allowing for the inclusion of necessary software and documentation.
  • If the source code was not provided, JINR’s skilled programmers could have developed their own Fortran compiler or adapted existing ones, as they did for other systems.

Conclusion:

While definitive evidence is lacking, it is highly likely that the CDC 1604 supplied to JINR in Dubna included the source code for its Fortran compiler, consistent with CDC’s practices and the needs of scientific institutions in the 1960s. JINR’s ability to customize software for the CDC 1604A, under Nikolay Govorun’s leadership, further supports this conclusion, as such customization typically required access to source code. If the source code was not provided, JINR’s team was capable of developing or adapting a Fortran compiler to meet their needs.
vak: (бэсм-6)
Недавно в Дубне отмечали юбилей Николая Говоруна, инициатора создания первого компилятора Фортрана для БЭСМ-6.

"Nikolay Govorun is a phenomenon in science"

"In 1965, during a business trip to CERN, Govorun learnt about the computer centre, as well as about libraries and application packages in the Fortran language that were widely used to process experimental data. In the USSR during these years, the ALGOL programming language was widely developed, so Govorun's proposal to develop software in the Fortran language was not supported."

"In 1966 [...] the BESM-6 computer, the most high-performance computer in Europe appeared, yet it was not equipped with advanced programming systems. Afterwards, N.N.Govorun gathered a team of specialists from different institutes to develop the first in the USSR Fortran language translator for BESM-6 computer, adaptation of libraries and application software packages for experimental data processing. The result of this work was the popular and widespread Dubna monitor system. The next step was the development of the Dubna operating system for BESM-6 that made JINR famous."
vak: (бэсм-6)
Если поставить задачу сбацать эмулятор ретро дисплея, какие шрифты можно бы применить? Я навскидку нагуглил три варианта.
Шрифт DEC Terminal смотрится неплохо, но файл TTF кривой. Без починки не заработает.



Flexi IBM VGA тоже симпатичный, однако больше в стиле писишек.

vak: (Default)
Не то чтобы совсем новая: 1980 года издания, но в идеальном состоянии. Книжка рассказывает про все кодировки символов 50-х, 60-х и 70-х годов. Почему делалось так или иначе, какие были варианты, как проблемы изменялись с появление новых компьютерных технологий. Автор был активным участником комитета по стандартизации ANSI/X3L2. Эту книжку можно свободно читать в интернете, но держать в руках совсем другое удовольствие. 😀



Здесь не только кодировки для принтеров, но и для перфокарт и перфолент.

vak: (Default)
Много интересных подробностей про исторический компилятор Би для PDP-7 и про первый юникс.

vak: (Default)
Простая программа: копирует входные байты на выход.
main() {
auto ch;

while (ch = read()) {
write(ch);
}
}
Пропускаем через Би компилятор, получаем ассемблерный код.
$ bbesm < cat.b > cat.madlen
$ cat cat.madlen
main:8,name,
program:,entry,
main:,bss,
b/save0:,subp,
b/ret:,subp,
,its,13
,call,b/save0
15,utm,1
/0:,bss,
7,utc,0
14,vtm,
,ita,14
read:,subp,
14,vtm,read
,its,14
,ati,14
14,utc,
13,vjm,
15,wtc,
,atx,
,uza,/1
write:,subp,
14,vtm,write
,ita,14
7,utc,0
14,vtm,
,its,14
,ati,14
14,xta,
14,vtm,-1
15,wtc,
13,vjm,
,uj,/0
/1:,bss,
,uj, b/ret
,end,
Компилируем в бинарник для БЭСМ-6. Линкуем с рантайм библиотекой Би.
$ besmc cat.madlen libb.obj
Запустим и подадим на вход собственный исходный код:
$ ./cat.exe < cat.b 
MAIN() [
AUTO CH;

WHILE (CH = READ()) [
WRITE(CH);
]
]
Всё перекодировалось в КОИ-7 по ходу. Это специфика мониторной системы Дубна, никуда не денешься. Ведь мы используем её механизм формирования входного потока программы.
vak: (Default)
Компилятор Би для БЭСМ-6 функционально закончен. То есть все фичи, в нём имеющиеся, вроде работают. Некоторые привычные для нас вещи отсутствуют: инкремент-декремент, сдвиги, операторы типа плюс-присвоить. Нет цикла for и оператора switch. Не поместились они у Кена Томпсона в 16 килобайт памяти PDP-7.

Сгенерённый компилятором код получается неэффективный, но для нас сейчас главное, что он функционально правильный. А насколько он неэффективный - давайте померяем. Возьмём для теста известный алгоритм вычисления e-2 по формуле 1/2! + 1/3! и так далее. Вот реализация на Би: e-2.b. Компилируем, запускаем:
$ bbesm < e-2.b > e-2.madlen
$ besmc e-2.madlen libb.obj
$ time ./e-2.exe
71828 18284 59045 23536 02874 71352 66249 77572 47093 69995
...
88683 31483 28027 06553 83300 46932 90115 74414 75631 39997

real 0m18.310s
user 0m18.302s
sys 0m0.008s
Для сравнения я переписал этот код на Паскаль: e-2.dub. Запустим на том же симуляторе:
$ dubna e-2.dub
...

71828 18284 59045 23536 02874 71352 66249 77572 47093 69995
...
88683 31483 28027 06553 83300 46932 90115 74414 75631 39997
------------------------------------------------------------
Elapsed time: 12.3 seconds
Simulated: 626677681 instructions
Simulation rate: 51010913 instructions/sec
Выходит 18.3 секунды против 12.3 секунды на Паскале. Не так ужасно, всего в полтора раза медленнее. С оптимизацией Би может оказаться даже эффективнее Паскаля.
vak: (Default)
Компилятор Би для БЭСМ-6 маленько подрос и уже способен правильно сгенерить функцию printf(). Вот как она выглядела в районе 1969 года.
printf(fmt, args) {
auto ap, a, c, i, n;

i = 0;
ap = &args;
loop:
while ((c = char(fmt, i)) != '%') {
if (c == '*0')
return;
writeb(c);
i = i + 1;
}
i = i + 1;
c = char(fmt, i);
if (c == '%') {
writeb('%');
i = i + 1;
goto loop;
}
a = *ap;
if (c == 'd') {
printd(a);
} else if (c == 'o') {
printo(a);
} else if (c == 'c') {
write(a);
} else if (c == 's') {
n = 0;
while ((c = char(a, n)) != '*0') {
writeb(c);
n = n + 1;
}
} else {
/* bad format specification, ignore */
goto loop;
}
i = i + 1;
ap = ap + 1;
goto loop;
}
Напишем тест, задействуя все форматы.
main() {
printf("Hello, World!*n");
printf("%% %% %%%%*n");
printf("format %%d: %d %d*n", 123, -123);
printf("format %%o: %o %o*n", 234, -234);
printf("format %%c: %c %c*n", 'foo', 'bar');
printf("format %%s: *"%s*" *"%s*"*n", "Hello", "World");
}
Компилируем, запускаем.
$ bbesm < test.b > test.assem 
$ besmc test.assem libb.obj
$ ./test.exe
Hello, World!
% % %%
format %d: 123 -123
format %o: 352 -352
format %c: foo bar
format %s: "Hello" "World"
Фунциклирует в лучшем виде однако.
vak: (Default)
Собрал компилятор GCC для PDP-10 по инструкции: http://pdp10.nocrew.org/netbsd/build-gcc.txt

Исходник скачивается по ссылке: http://pdp10.nocrew.org/gcc/download/gcc-pdp10-20030606.tar.bz2

Пришлось маленько подрихтовать, чтобы собиралось на современном линуксе. Пропущен третий параметр (mode) в вызове open(). Есть пример автономной программы на Си: http://pdp10.nocrew.org/netbsd/boot.c

При её компиляции получается ассемблерный код: Не так интересна сама PDP-10, как факт наличия компилятора Си для словной архитектуры (без байтовой адресации) с размером слова 36 бит. Значит и для БЭСМ-6 можно переделать. Чем слово 48 бит хуже?
vak: (Default)
Одной из целей добыть компьютер с процессором PowerPC было портонуть туда bintrace и глянуть выполнение машинных команд. Это дело успешно получилось. Вот пример трассировки программы типа "Hello World", написанной для простоты на ассемблере:
$ cc -c demo-powerpc32-linux.S
$ ld demo-powerpc32-linux.o -o demo-powerpc32-linux
$ bintrace ./demo-powerpc32-linux
Starting program: ./demo-powerpc32-linux
r0 = 0xb
r1 = 0xaffff4c0
msr = 0xd932
0x10000054: 38000004 li r0, 4
r0 = 0x4
0x10000058: 38600001 li r3, 1
r3 = 0x1
0x1000005c: 3c801000 lis r4, 0x1000
r4 = 0x10000000
0x10000060: 60840078 ori r4, r4, 0x78
r4 = 0x10000078
0x10000064: 38a0000d li r5, 0xd
r5 = 0xd
0x10000068: 44000002 sc
Hello world!
r0 = 0x1
r3 = 0xd
r4 = 0
r5 = 0
r6 = 0x2c
r7 = 0x1000006c
r8 = 0xd432
r9 = 0x403b9a98
r10 = 0x403b9ba9
r11 = 0x403b9cba
r12 = 0x403b9987
ctr = 0xc00cab0c
0x10000070: 38600000 li r3, 0
r3 = 0
0x10000074: 44000002 sc
Process exited normally.
Кто помнит систему команд MIPS - попробуйте найти десять отличий. 😀
vak: (Default)
Подробности конфигурации:Меряем скорость:
$ dhrystone

Dhrystone Benchmark, Version 2.1 (Language: C)
...
Nanoseconds for one run through Dhrystone: 297.8
Million Dhrystones per Second: 3.357
DMIPS: 1910.9
Это 25% от скорости Raspberry Pi 4. Или на 6% медленнее, чем Celeron M 1Ghz. 

Сравнительная таблица: vak.dreamwidth.org/1159708.html
vak: (Default)
Шикарный сайт про Дос и Виндовс, с кучей полезных материалов.

msdos-windows.com
vak: (Знайка)
Много ли у вас в хозяйстве 32-битных компьютеров? Вот у меня одним прибыло. Макбук 20-летней давности на процессоре до-интеловской архитектуры PowerPC. Буду ставить Debian.

vak: (Daemon)
За последние три дня я могучим рывком, броском, пинком и нахрапом закончил таки переделку RetroBSD под компилятор Clang. Теперь не нужно бегать искать GCC для mips32. Ставите стандартный Clang и вперёд. Инструкция по сборке лежит в корневом файле README. Для запуска на симуляторе годится обновлённый QEMU для pic32. Если кому понадобится старая версия с GCC - она лежит в бранче gcc.

Поддержку устаревшего хардвера я убрал. Оставил только две платы, обе имеются в продаже:Из минусов: потеряны две фичи.
  • MIPS16e - компактная система команд - не поддерживается компилятором Clang. Формально она там есть, но код генерится совершенно нерабочий. Так что приходится довольствоваться стандартным набором инструкций. Из-за этого некоторые "толстые" приложения не лезут в память, к примеру компилятор SmallerC.
  • Не удаётся собрать библиотеку libc.а в формате a.out для того же компилятора SmallerC. Потому что имеющийся ассемблер mips32 не понимает некоторые навороченные конструкции, порождаемые компилятором Clang. Надо будет допиливать.
Но в целом система фурычит довольно неплохо. Открывается путь для переноса на другие платформы: esp32, stm32, riscv и другие.
vak: (Daemon)
Хотите взглянуть, как грузится RetroBSD с точки зрения последовательности системных вызовов? Стартует /sbin/iuit, из-под него /bin/sh выполняет скрипт /etc/rc, проверяет файловую систему, запускает cron и в конце концов getty. Я сделал флажок в QEMU для pic32, чтобы трассировать системные вызовы. Вывод слегка обработал вручную, вот результат.

gist.github.com/sergev/c0c21f47220e2d3ec6eee4b5b076ec0f
vak: (Daemon)
Внезапно выяснилось, что в RetroBSD была старая ошибка, из-за которой он не запускался на QEMU. Инструкция ERET попадала в delay-слот условного перехода. Строго говоря, это неопределённое поведение. В железе на PIC32 оно работает, но симулятор такого не прощает. Поправил, теперь всё с порядке.
$ qemu-pic32 -machine pic32mx7-max32 -nographic -monitor none -serial stdio -bios boot-max32.hex -kernel unix.hex -sd retrobsd.img
Board: chipKIT Max32
Processor: M4K
RAM size: 128 kbytes
Load file: 'boot-max32.hex', 6720 bytes
Load file: 'unix.hex', 141140 bytes
Card0 image 'retrobsd.img', 102401 kbytes

2.11 BSD Unix for PIC32, revision G512 build 3:
Compiled 2025-02-07 by vak@bumba:
/home/vak/Project/BSD/retrobsd/sys/pic32/max32
cpu: 795F512L 80 MHz, bus 80 MHz
oscillator: HS crystal, PLL div 1:2 mult x20
spi2: pins sdi=RG7/sdo=RG8/sck=RG6
uart1: pins rx=RF2/tx=RF8, interrupts 26/27/28, console
uart2: pins rx=RF4/tx=RF5, interrupts 40/41/42
uart4: pins rx=RD14/tx=RD15, interrupts 67/68/69
sd0: port SPI2, pin cs=RC14
gpio0: portA, pins ii---ii-iiiioiii
gpio1: portB, pins iiiiiiiiiiiiiiii
gpio2: portC, pins i-ii-------iiii-
gpio3: portD, pins --iiiiiiiiiiiiii
gpio4: portE, pins ------iiiiiiiiii
gpio5: portF, pins --ii--------i-ii
gpio6: portG, pins iiii--i-----iiii
adc: 15 channels
pwm: 5 channels
sd0: type I, size 102400 kbytes, speed 10 Mbit/sec
sd0a: partition type b7, sector 2, size 102400 kbytes
sd0b: partition type b8, sector 204802, size 2048 kbytes
sd0c: partition type b7, sector 208898, size 102400 kbytes
phys mem = 128 kbytes
user mem = 96 kbytes
root dev = (0,1)
swap dev = (0,2)
root size = 102400 kbytes
swap size = 2048 kbytes
/dev/sd0a: 1444 files, 12342 used, 89657 free
Starting daemons: update cron

2.11 BSD UNIX (pic32) (console)

login: root
Password:
Welcome to RetroBSD!
erase ^?, kill ^U, intr ^C

# date
Sun Jan 24 23:08:07 PST 2016

# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/sd0a 101999 12345 89654 12% /

# ps aux
USER PID NICE SZ TTY TIME COMMAND
root 0 0 3 ? 0:00 swapper
root 1 0 35 ? 0:00 init -
root 10 0 7 ? 0:00 update
root 12 0 54 ? 0:00 cron
root 13 0 39 0 0:00 -sh
root 17 0 42 0 0:00 ps aux

# ls /bin
[ crontab hostname pagesize size uucico
adb date id passwd sl uuclean
adc-demo dc iostat pdc sleep uucp
aout dd join picoc smux uudecode
apropos df kill portio sort uuencode
ar diff la pr split uulog
as diskspeed last printenv strip uuname
awk du lcc printf stty uupoll
basename echo lcpp ps su uuq
basic ed ld pwd sum uusend
bc egrep ln pwm sx uusnap
cal emg login ranlib sync uux
calendar env lol rb sysctl uuxqt
cat expr ls re sz vi
cb false mail renice tail vmstat
cc fgrep make renumber tar w
chat-server file man retroforth tee wall
chflags find md5 rev telnet wc
chfn fold med rm test web-client
chgrp forth mesg rmail time web-server
chmod fstat mkdir rmdir tip whatis
chpass glcdtest more rx touch whereis
chsh globdump msec rz tr who
cmp globread mv sb true whoami
col globwrite nice scc tsort write
comm grep nm scm tty xargs
compress groups nohup sed uname zcat
cp head ntpdate setty uncompress
cpp hostid od sh uniq

# cd /share/examples/asm
# make clean
rm -f *.o ashello echo *.dis *~

# cat ashello.S
/*
* This is an example of MIPS assembly program for RetroBSD.
*
* To compile this program, type:
* cc -c ashello.S
* ld ashello.o -o ashello
*/
#include <syscall.h>

.data // begin data segment
hello: .ascii "Hello, assembly world!\n" // a string

.text // begin code segment
.globl start // entry point for ld
start:
li $a0, 0 // arg 1: stdout fd
la $a1, hello // arg 2: string address
li $a2, 23 // arg 3: string length
syscall SYS_write // call the kernel: write()
nop // returns here on error
nop // skips two words on success

li $a0, 0 // arg 1: exit status
syscall SYS_exit // call the kernel: exit()
// no return

# make ashello
cc -c ashello.S
ld ashello.o -o ashello

# ./ashello
Hello, assembly world!

# cd /share/examples/c
# make clean
rm -f *.o *~ hello stdarg skeleton primelist primesum test1 test2 test3 gpio adc rain q8 tetris lcd6

# cat hello.c
#include <stdio.h>

int main()
{
printf ("Hello, C World!\n");
return 0;
}

# make hello
cc -o hello hello.c

# ./hello
Hello, C World!

# halt
killing processes... done
syncing disks... done
halted
Обратите внимание: работают ассемблер и Си компилятор.
vak: (Daemon)
Нашёлся умный человек, подсказал как собрать на нынешнем Debian 12 (bookworm) симулятор pic32, который я сварганил десять лет назад. Приятно вспомнить.

Главная хитрость - установить Python 2.7. Официально делать это крайне не рекомендуется, но оно работает, как ни странно.
wget http://ftp.debian.org/debian/pool/main/libf/libffi/libffi7_3.3-6_amd64.deb
wget http://ftp.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_amd64.deb
wget http://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb
wget http://ftp.debian.org/debian/pool/main/p/python2.7/python2.7-minimal_2.7.18-8+deb11u1_amd64.deb
wget http://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-stdlib_2.7.18-8+deb11u1_amd64.deb
wget http://ftp.debian.org/debian/pool/main/p/python2.7/python2.7_2.7.18-8+deb11u1_amd64.deb
sudo dpkg -i libffi7_3.3-6_amd64.deb \
libssl1.1_1.1.1w-0+deb11u1_amd64.deb \
libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb \
python2.7-minimal_2.7.18-8+deb11u1_amd64.deb \
libpython2.7-stdlib_2.7.18-8+deb11u1_amd64.deb \
python2.7_2.7.18-8+deb11u1_amd64.deb
Теперь соберём и установим QEMU для pic32:
sudo apt install libpixman-1-dev libfdt-dev zlib1g-dev libglib2.0-dev libsdl1.2-dev
git clone https://github.com/sergev/qemu.git
mkdir qemu-build
cd qemu-build
../qemu/configure --prefix=/usr/local/qemu-mips \
--target-list=mipsel-softmmu \
--python=/usr/bin/python2.7 \
--disable-werror
make CFLAGS="-O3 -Wno-error -isystem /usr/include/glib-2.0 -isystem /usr/lib/$(uname -m)-linux-gnu/glib-2.0/include" -j "$(nproc)"
make install
Бинарник QEMU будет установлен как /usr/local/qemu-mips/bin/qemu-system-mipsel. Запустим LiteBSD:
wget https://raw.githubusercontent.com/wiki/sergev/qemu/binaries/boot-wifire.hex
wget https://raw.githubusercontent.com/wiki/sergev/qemu/binaries/vmunix.hex
wget https://raw.githubusercontent.com/wiki/sergev/qemu/binaries/litebsd.zip
unzip litebsd.zip
/usr/local/qemu-mips/bin/qemu-system-mipsel \
-machine pic32mz-wifire \
-nographic \
-monitor none \
-serial vc \
-serial vc \
-serial vc \
-serial stdio \
-bios "boot-wifire.hex" \
-kernel "vmunix.hex" \
-sd "litebsd.img"
Стартует классический юникс 30-летней давности:
Board: chipKIT WiFire
Processor: microAptivP
RAM size: 512 kbytes
Load file: 'boot-wifire.hex', 6916 bytes
Load file: 'vmunix.hex', 522408 bytes
Card0 image 'litebsd.img', 339969 kbytes
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.

4.4BSD-Lite build 13 compiled 2015-01-20
sergev@ubuntu-sergev:LiteBSD/sys/compile/WIFIRE.pic32
cpu: PIC32MZ2048ECG100 rev A4, 200 MHz
oscillator: system PLL div 1:6 mult x50
real mem = 512 kbytes
avail mem = 344 kbytes
using 18 buffers containing 73728 bytes of memory
spi1 at pins sdi=D14/sdo=C1/sck=D1
spi2 at pins sdi=F0/sdo=D11/sck=G6
spi3 at pins sdi=B10/sdo=C4/sck=B14
spi4 at pins sdi=F5/sdo=G0/sck=D10
uart1 at pins rx=F1/tx=D15, interrupts 112/113/114
uart4 at pins rx=F2/tx=F8, interrupts 170/171/172, console
sd0 at port spi3, pin cs=C3
sd0: type I, size 339968 kbytes, speed 12 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 32768 kbytes
sd0c: partition type b7, sector 475138, size 102400 kbytes
bpf: sl0 attached
bpf: lo0 attached
WARNING: preposterous clock chip time -- CHECK AND RESET THE DATE!

starting file system checks.
/dev/rsd0a: file system is clean; not checking
starting network
clearing /tmp
standard daemons: update.
Wed Dec 10 21:07:36 PST 2014

4.4BSD-Lite (bsd.net) (tty4)

login: _
Заходите как root, без пароля. Остановить систему можно командой halt -q.