MMIX drives Apache

In the course of the Info II lecture I did an experiment to get MMIX to work via CGI with Apache.

MMIX assembler source files have the extension .mms by convention, which led me to add a new handler and a corresponding action to httpd.conf:

AddHandler mmix-handler .mms
Action mmix-handler /cgi-bin/

I had not found a way to directly pass a command line parameter to a program (my action statement). That bothered me a bit at first, but the detour via a small script turned out to be more advantageous - because it was more flexible.

$len = length($ENV{"PATH_TRANSLATED"})-4;
$name = substr($ENV{"PATH_TRANSLATED"}, 0, $len);

system("mmixal.exe", $name . ".mms");
system("mmix.exe", $name . ".mmo", $ARGV[0]);

From here it is possible to store MMIX assembler code in a directory and navigate to it with a browser. The script ensures that the code is assembled and executed with the MMIX Simulator.

Here is the example from the picture above:

       LOC Data_Segment
       GREG @

Header BYTE "Content-type: text/html",#a,#a,#0
Footer BYTE "

brought to you by MMIX ^^",#0

argv   IS   $1

       LOC  #100

Main   LDA  $255,Header
       TRAP 0,Fputs,StdOut

       CMPU $2,$0,#1
       BZ   $2,1F

       LDOU $255,argv,#8
       TRAP 0,Fputs,StdOut

1H     LDA  $255,Footer
       TRAP 0,Fputs,StdOut

       TRAP 0,Halt,0

Use case: probably nonexistent :-)


Alexander Gitter
contact at agitter net