From f3454efe4139015381d6a1a30599cd3cf366ef15 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 27 Dec 2010 19:52:21 +0100 Subject: [PATCH] Implemented web interface --- .htaccess | 2 + index.cgi | 85 +++++++++++++++++++++++++++++++++++++++++ minsk.css | 56 +++++++++++++++++++++++++++ readme.html | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 251 insertions(+) create mode 100644 .htaccess create mode 100755 index.cgi create mode 100644 minsk.css create mode 100644 readme.html diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..c4db64f --- /dev/null +++ b/.htaccess @@ -0,0 +1,2 @@ +AddDefaultCharset utf-8 +DirectoryIndex index.cgi diff --git a/index.cgi b/index.cgi new file mode 100755 index 0000000..394edaf --- /dev/null +++ b/index.cgi @@ -0,0 +1,85 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use lib '../lib'; +use UCW::CGI; +use File::Temp; +use POSIX; + +my $src; +my $example; +my $trace; + +POSIX::nice(10); + +UCW::CGI::parse_args({ + 'src' => { 'var' => \$src, 'multiline' => 1 }, + 'example' => { 'var' => \$example, 'check' => '\w+' }, + 'trace' => { 'var' => \$trace, 'check' => '[0-2]', 'default' => 0 }, +}); + +if ($example ne '' && open EX, "ex-$example") { + local $/; + undef $/; + $src = ; + close EX; +} + +my $src_html = html_escape($src); +my @trsel = map { $trace == $_ ? "selected" : "" } 0..2; + +print < + +Minsk-2 Emulator + + +

Minsk-2 Emulator

+ +

(see instructions) + +EOF + +if ($src ne '') { + print "

Output

\n\n
";
+	my $tmpf = new File::Temp();
+	print $tmpf $src, "\n";
+	$tmpf->flush();
+	my $in = $tmpf->filename;
+	open SIM, "./minsk --trace=$trace --cpu-quota=1000 --print-quota=100 <$in |" or die;
+	while () {
+		print html_escape($_);
+	}
+	close SIM;
+	print "
\n\n"; +} + +print <Input +
+ +

+ +

+EOF + +print < +

Written by Martin Mareš. Version 1.0 (2010-12-27). + +EOF + +# FIXME: +# - password +# - utf-8 warning +# - nice +# - .htaccess diff --git a/minsk.css b/minsk.css new file mode 100644 index 0000000..1334db2 --- /dev/null +++ b/minsk.css @@ -0,0 +1,56 @@ +BODY { + background-color: #ffffff; +} + +TEXTAREA { + border-top: 1px solid #11308a; + border-left: 1px solid #11308a; + border-bottom: 1px dotted #8396cd; + border-right: 1px dotted #8396cd; + padding: 0.5ex; +} + +#output { + border-top: 1px solid #11308a; + border-left: 1px solid #11308a; + border-bottom: 1px dotted #8396cd; + border-right: 1px dotted #8396cd; + padding: 0.5ex; +} + +H1 { + color: #11308a; + font-size: 1.6em; + text-align: center; +} + +H2 { + color: #11308a; + font-size: 1.4em; +} + +A:link { + color: #0000f0; +} + +A:active { + color: #454589; +} + +A:visited { + color: #00005a; +} + +A:hover { + color: #8900b8; +} + +HR { + border: 1px dotted #11308a; + margin-top: 1cm; + height: 1px; +} + +#top { + text-align: center; +} diff --git a/readme.html b/readme.html new file mode 100644 index 0000000..fa6e217 --- /dev/null +++ b/readme.html @@ -0,0 +1,108 @@ + + +Minsk-2 Emulator + + +

Minsk-2 Emulator

+ +

(see it in action) + +

Introduction

+ +

This is an emulator of Минск-2 (Minsk-2) – a mainframe computer from +the Soviet era, produced around 1963 in the Byelorussian SSR. + +

We have written the emulator for a task in the Po drátě +hacking contest (sorry, the page is in Czech only). The participants were to +find a password hidden in the machine's memory, which involved figuring out how +the machine works and reconstructing at least a part of its instruction set. +You can try your luck, the password is still there. + +

Online resources about this machine are rather scarce. English Wikipedia contains +a fairly short article on the Minsk +family of computers, Russian Wikipedia reveals a couple of technical details on +Minsk-22, +which is essentially Minsk-2 with extra memory. The Russian Virtual Computer Museum +tells the history of the +Minsk family in its full glory, but it lacks details. The best resource we could +find is the book Programmirovanije dlja ECBM Minsk-22 by V. M. Salikov, and the emulator +is based solely on that plus a bit of guesswork. + +

We have written a brief description of the instruction set +for our own reference. + +

When using the emulator, please make sure that your browser is able to display +Cyrillic letters, as all error messages are printed in Russian. (This is not historically +accurate, the real machine never printed error messages – it used signal lights on the +control panel instead.) + +

Features

+ +

We have tried to get as close to the behavior of the real machine as we could, +but the description in the Salikov's book is not as detailed as we would wish, +so several things remained to be guessed. Here is a list of likely differences +against the real Minsk-2: + +

    +
  • Rounding of fixed-point and floating-point computations is likely to be different. +
  • Arithmetic overflow is always fatal. +
  • Exact behavior of negative zero is unknown. We always produce positive zero as a result. +
  • Contents of the R1 and R2 registers displayed when the program stops probably + differ from the real front panel. However, the behavior visible to the program + should be correct. +
  • Among the rich set of I/O devices, only the line printer is implemented. +
  • Malformed instructions are probably handled differently. +
+ +

Input format

+ +

The input to the emulator follows a fairly simple format: + +

; An example
+
+@0050
+-62 00 7000 1000
+-62 00 7006 1001
+-62 00 7400 0000
+-00 00 0000 0000
+@1000
++65 45 53 53 56 17
++42 56 60 53 44 16
+
+ +

Empty lines and lines starting with a semicolon are ignored. +@xxxx sets the memory address (in octal), all other +lines specify signed 36-bit octal values to be written to consecutive +memory cells. Spaces inside numbers are purely decorative and the parser +ignores them. + +

Examples

+ +

Here is a couple of easy example programs for you to try: + +

+ +

Author and copyright

+ +

The emulator has been written by Martin Mareš +in 2010 and it is copyrighted by its author. + +

The program is free software. You can freely use it and distribute it under the terms of the +GNU General Public License version 2. + +

Bug reports and suggestions are welcome (especially from people who have encountered +the real Minsk), please contact the author by e-mail at mj@ucw.cz. + +

Download

+ +

You can download the source code of the emulator from our FTP server. + +

It has been developed on Linux with GCC and it should run on all POSIX systems, +possibly requiring trivial modifications. + + -- 2.39.2