Mmix machine Overview

Source: Internet
Author: User
I should have heard of Don knuth, the author of his seven-volume draft of the art of computer programming. Knuth is planning to revise the first, second, and third volumes after completing the fifth volume. Program Instead of using mix for assembly, instead of using Mmix for assembly. Although there is only one more m, the difference is big. Mix and Mmix are completely different machines. In the 1960s S, the computer architecture was very different from today's, if you have read taocp Volume 1, you will be able to understand the complexity of mix assembly. Thirty years later, knuth finally had to re-design a machine, and it was a 64-bit server in the Proteus style. The original knuth statement is as follows:

Thirty years have passed since the mix computer was designed. and computer architecture has been converging during those years towards a rather different style of machine. therefore it is time to replace mix with a new computer that contains even less saturated fat than its predecessor.

It can be seen that the new machine must be simple. In fact, knuth is designing Mmix with the help of Hennessy and Patterson. Of course, it is a server of the same stage.

Mmix Introduction

The Mmix machine is in the same type as the Mmix machine. This means that there should be many registers, most of the operations should be completed in the Register; Mmix is a 64-bit machine, it indicates that Mmix registers should all be 64-bit.
Good, Mmix has 256 General registers for the program to perform arithmetic logic operations. For example, add $0, $1, and $2 are used to add the values of register 1 and register 2 to register 0.
There are also 32 dedicated registers for implicit addressing and some privileged command operations.

The Command Format of Mmix is op X, Y, Z.
Each operation code and each operand occupies one byte, which means that the length of the Mmix command is always four bytes. X is generally used as the destination operand.

Mmix Hello World

Here I cannot describe Mmix in detail. I can only provide some information and then write a helloworld program, because what I know is very limited.
The Mmix simulator is called Mmix, And the assembler is called mmixal. Below is a hello. MMS. (MMS is the general Suffix of Mmix Assembly)


The line starting with * is a comment.
Line 3 should be well understood, that is, it occupies some memory areas and stores "Hello, world!" in it! The ASCII value of each character in ", 10 is a line break, and 0 is the same as '\ 0' in C language.
Each line starts from line 1 and is an instruction. commands in the Mmix Assembly format are divided into three parts: labels, operation codes, and operands, which are separated by blank characters. Those who have learned other compilers should easily understand the Mmix Assembly format, but note that there must be only one comma between the operands and no space, this should be a "bug" in the lexical analysis written by knuth ".

Line 2 string first address string loaded into the last register
Then execute the trap command in line 3, which is equivalent to the interrupt command in x86. The interrupt service program is fputs (Basic Input and Output functions provided by the simulator), which outputs the strings indicated in $255 to stdout.
Finally, use trap to execute the halt command and exit the simulator.

After writing it, just like using gcc, compile the source file with mmixal to get the target file.
Mmixal-O hello. MMS
Load the target file hello to the Mmix simulator.
Mmix hello

Compile and install the Mmix simulator, assembler, and related tools

originally, this section should be placed before Hello world, but I think the above compilation process is no different from the normal use of GCC, so I put the most important section at the end.
at the end of this article, I provided the latest Mmix simulator source code (not just a simulator, but also a series of tools, such as assembler). Please download them first.
after decompression, open the README file and read it carefully. Now it's okay for me.
what? Do not want to read English! Ah, how can I learn computer well. In fact, it is the following three steps
$ make doc // you will get all the documents, including Mmix architecture instructions, mmix assembly instructions. Check
$ make Mmix // obtain the executable Mmix file of the Mmix simulator.
$ make mmixal // obtain the executable file mmixal of the Mmix assembler.
the above installation is not a classic trilogy of confgiure, make, and make install. In fact, it is equivalent to writing the source code and compiling the executable file. If you want to execute Mmix and mmixal in any directory, assume that the directory where it is located is the PATH variable.

OK. Now you can compile the hello file and run it in the simulator.

PS: If you are interested, you 'd better take a look at the three documents generated by make Doc. In fact, there are almost no other references.
If you are interested in Mmix or have research, you can use this blog orJohnWaken@163.comContact me

Download Mmix VM source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.