準備 MMIX 環境

黃志斌發表於2018-03-19

安裝 MMIX 軟體

Knuth: MMIX News 頁面提到:

Software

People have been accumulating several years of experience with a straightforward MMIX assembler and simulator, and I know that both programs work reasonably well on three platforms. The pipeline meta-simulator is also up and running, but with a user interface that is not for beginners. (This is one of the most difficult programs I've ever written, and surely one of the most interesting, for people who have time to explore low-level details.)

Click here to download MMIXware: the simple simulator, assembler, test programs, and full documentation, plus the meta-simulator: mmix.tar.gz (Version of 17 May 2017)

In general these programs are now entirely stable: I won't be changing them any more, because they've proved their value in extensive use. Further developments, including versions that I myself do not maintain, are however ongoing. All the really current news about MMIX is, in fact, now to be found in the MMIX home pages.

因此,使用以下命令下載並安裝 MMIXware:

$ mkdir MMIX; cd MMIX
$ wget https://www-cs-faculty.stanford.edu/~knuth/programs/mmix.tar.gz
$ tar xf mmix.tar.gz
$ make doc
$ make all
$ make clean
$ sudo mv abstime mmix mmixal mmotype mmmix /usr/local/bin

彙編並執行

$ cat hello.mms

argv   IS    $1
       LOC   #100
Main   LDOU  $255,argv,0
       TRAP  0,Fputs,StdOut
       GETA  $255,String
       TRAP  0,Fputs,StdOut
       TRAP  0,Halt,0
String BYTE  ", world",#a,0

$ mmixal hello.mms
$ mmix hello
hello, world

大功告成。

參考資料

  1. Wikipedia: MMIX
  2. Knuth: MMIX
  3. Knuth: MMIX News
  4. MMIX Home Page
  5. MMIX Quick Reference Card
  6. The Art of Computer Programming, Volume 1, Fascicle 1, MMIX, Donald E. Knuth, 2004.

相關文章