MMIX
Encyclopedia
MMIX is a 64-bit
RISC
instruction set
architecture
(ISA) designed by Donald Knuth
, with significant contributions by John L. Hennessy
(who contributed to the design of the MIPS
ISA) and Richard L. Sites (who was an architect of the Alpha
ISA). In Knuth’s own words:
computer
, with 256 64-bit general-purpose registers and 32 64-bit special-purpose registers. MMIX is a big-endian
machine with 32-bit instructions and a 64-bit virtual address space
. The MMIX instruction set comprises 256 opcodes, one of which is reserved for future expansion.
It uses IEEE 754 floating-point numbers.
Most instructions can take either immediate values or register contents; thus a single instruction mnemonic may correspond to one of two opcodes.
MMIX programs are typically constructed using the MMIXAL assembly language. The below is a simple MMIXAL program, which prints Hello, world:
Two of the special registers, rL and rG, determine which of the general registers are local and which are global. All registers from $0 ... ([rL] - 1) are local registers. Registers from [rL] ... ([rG]-1) are "marginal registers" they always return 0 if they are used as a source in an operation. Using a marginal register as the destination of an operation will cause the machine to automatically increase rL to include that register. All registers [rG] ... $255 are called global registers, and are not saved on the register stack.
However, the fpgammix project implements MMIX in Verilog
, making it possible to implement using a field-programmable gate array
.
includes an MMIX back-end for its C
/C++
compilers, contributed by Hans-Peter Nilsson and part of the main GCC distribution since late 2001. As of January 2011, the MMIX back-end to GCC continues to be actively developed and maintained by volunteers.
The above tools could theoretically be used to compile, build, and bootstrap an entire FreeBSD
, Linux
, or other similar operating system kernel onto MMIX hardware, were such hardware to exist.
64-bit
64-bit is a word size that defines certain classes of computer architecture, buses, memory and CPUs, and by extension the software that runs on them. 64-bit CPUs have existed in supercomputers since the 1970s and in RISC-based workstations and servers since the early 1990s...
RISC
Reduced instruction set computer
Reduced instruction set computing, or RISC , is a CPU design strategy based on the insight that simplified instructions can provide higher performance if this simplicity enables much faster execution of each instruction. A computer based on this strategy is a reduced instruction set computer...
instruction set
Instruction set
An instruction set, or instruction set architecture , is the part of the computer architecture related to programming, including the native data types, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O...
architecture
Computer architecture
In computer science and engineering, computer architecture is the practical art of selecting and interconnecting hardware components to create computers that meet functional, performance and cost goals and the formal modelling of those systems....
(ISA) designed by Donald Knuth
Donald Knuth
Donald Ervin Knuth is a computer scientist and Professor Emeritus at Stanford University.He is the author of the seminal multi-volume work The Art of Computer Programming. Knuth has been called the "father" of the analysis of algorithms...
, with significant contributions by John L. Hennessy
John L. Hennessy
John LeRoy Hennessy is an American computer scientist and academician. Hennessy is one of the founders of MIPS Computer Systems Inc. and is the 10th President of Stanford University.-Background:...
(who contributed to the design of the MIPS
MIPS architecture
MIPS is a reduced instruction set computer instruction set architecture developed by MIPS Technologies . The early MIPS architectures were 32-bit, and later versions were 64-bit...
ISA) and Richard L. Sites (who was an architect of the Alpha
DEC Alpha
Alpha, originally known as Alpha AXP, is a 64-bit reduced instruction set computer instruction set architecture developed by Digital Equipment Corporation , designed to replace the 32-bit VAX complex instruction set computer ISA and its implementations. Alpha was implemented in microprocessors...
ISA). In Knuth’s own words:
Architecture
MMIX is a 64-bit RISCReduced instruction set computer
Reduced instruction set computing, or RISC , is a CPU design strategy based on the insight that simplified instructions can provide higher performance if this simplicity enables much faster execution of each instruction. A computer based on this strategy is a reduced instruction set computer...
computer
Computer
A computer is a programmable machine designed to sequentially and automatically carry out a sequence of arithmetic or logical operations. The particular sequence of operations can be changed readily, allowing the computer to solve more than one kind of problem...
, with 256 64-bit general-purpose registers and 32 64-bit special-purpose registers. MMIX is a big-endian
Endianness
In computing, the term endian or endianness refers to the ordering of individually addressable sub-components within the representation of a larger data item as stored in external memory . Each sub-component in the representation has a unique degree of significance, like the place value of digits...
machine with 32-bit instructions and a 64-bit virtual address space
Virtual address space
Virtual address space is a memory mapping mechanism available in modern operating systems such as OpenVMS, UNIX, Linux, and Windows NT...
. The MMIX instruction set comprises 256 opcodes, one of which is reserved for future expansion.
It uses IEEE 754 floating-point numbers.
Instructions
All instructions have an associated mnemonic. For example instruction 32 is associated to ADD. Most instructions have the symbolic form "OP X,Y,Z", where OP specifies the sort of instruction, X specifies the register used to store the result of the instruction and the rest specify the operands of the instruction. Each of these fields is eight bits wide. For example, the instruction "ADD $0,$1,3", will add the contents of register 1 and the immediate value 3 and store the result in register 0.Most instructions can take either immediate values or register contents; thus a single instruction mnemonic may correspond to one of two opcodes.
MMIX programs are typically constructed using the MMIXAL assembly language. The below is a simple MMIXAL program, which prints Hello, world:
Registers
There are 256 general purpose architectural registers in an MMIX chip, designated by $0 through $255 and 32 special physical architectural registers.Two of the special registers, rL and rG, determine which of the general registers are local and which are global. All registers from $0 ... ([rL] - 1) are local registers. Registers from [rL] ... ([rG]-1) are "marginal registers" they always return 0 if they are used as a source in an operation. Using a marginal register as the destination of an operation will cause the machine to automatically increase rL to include that register. All registers [rG] ... $255 are called global registers, and are not saved on the register stack.
Local register stack
The local register stack provides each subroutine with its own rL local registers, designated by $0 through $(rL−1). Whenever a subroutine is called, a number of local registers is pushed down the stack. The arguments of the called subroutine are left in the remaining local registers. When a subroutine finishes it pops the previously pushed registers. Because there are only 256 local physical registers, it may be necessary to store a part of the stack in memory. This is implemented with the special registers rO and rS which record which part of the local register stack is in memory and which part is still in local physical registers. The register stack provides for fast subroutine linkage.Special registers
The 32 special physical architectural registers are as follows:-
- rB, the bootstrap register (trip)
- When tripping, rB <- $255 and $255 <- rJ. Thus saving rJ in a general register.
- rD, the dividend register
- Unsigned integer divide uses this as the left half of the 128-bit input that is to be divided by the other operand.
- rE, the epsilon register
- Used for floating comparisons with respect to epsilon.
- rH, the himult register
- Used to store the left half of the 128-bit result of unsigned integer multiplication.
- rJ, the return-jump register
- Used to save the address of the next instruction by PUSHes and by POP to return from a PUSH.
- rM, the multiplex mask register
- Used by the multiplex instruction.
- rR, the remainder register
- Is set to the remainder of integer division.
- rBB, the bootstrap register (trap)
- When trapping, rBB <- $255 and $255 <- rJ. Thus saving rJ in a general register
- rC, the cycle counter
- Incremented every cycle.
- rN, the serial number
- A constant identifying this particular MMIX processor.
- rO, the register stack offset
- Used to implement the register stack.
- rS, the register stack pointer
- Used to implement the register stack.
- rI, the interval counter
- Decremented every cycle. Causes an interrupt when zero.
- rT, the trap address register
- Used to store the address of the trip vector.
- rTT, the dynamic trap address register
- Used to store the address of the trap vector.
- rK, the interrupt mask register
- Used to enable and disable specific interrupts.
- rQ, the interrupt request register
- Used to record interrupts as they occur.
- rU, the usage counter
- Used to keep a count of executed instructions.
- rV, the virtual translation register
- Used to translate virtual addresses to physical addresses. Contains the size and number of segments, the root location of the page table and the address space number.
- rG, the global threshold register
- All general registers references with a number greater or equal to rG refer to global registers.
- rL, the local threshold register
- All general registers references with a number smaller than rL refer to local registers.
- rA, the arithmetic status register
- Used to record, enable and disable arithmetic exception like overflow and divide by zero.
- rF, the failure location register
- Used to store the address of the instruction that caused a failure.
- rP, the prediction register
- Used by conditional swap (CSWAP).
- rW, the where-interrupted register (trip)
- Used, when tripping, to store the address of the instruction after the one that was interrupted.
- rX, the execution register (trip)
- Used, when tripping, to store the instruction that was interrupted.
- rY, the Y operand (trip)
- Used, when tripping, to store the Y operand of the interrupted instruction.
- rZ, the Z operand (trip)
- Used, when tripping, to store the Z operand of the interrupted instruction.
- rWW, the where-interrupted register (trap)
- Used, when trapping, to store the address of the instruction after the one that was interrupted.
- rXX, the execution register (trap)
- Used, when trapping, to store the instruction that was interrupted.
- rYY, the Y operand (trap)
- Used, when trapping, to store the Y operand of the interrupted instruction.
- rZZ, the Z operand (trap)
- Used, when trapping, to store the Z operand of the interrupted instruction.
Hardware implementations
As of July 2010, no known hardware implementations of the MMIX instruction set architecture exist.However, the fpgammix project implements MMIX in Verilog
Verilog
In the semiconductor and electronic design industry, Verilog is a hardware description language used to model electronic systems. Verilog HDL, not to be confused with VHDL , is most commonly used in the design, verification, and implementation of digital logic chips at the register-transfer level...
, making it possible to implement using a field-programmable gate array
Field-programmable gate array
A field-programmable gate array is an integrated circuit designed to be configured by the customer or designer after manufacturing—hence "field-programmable"...
.
Software tools
The MMIX instruction set architecture is supported by a number of software tools for computer architecture research and software development.Simulators and assembler
- MMIXware – Donald Knuth’s
MMIX-SIM
simple (behavioral) simulator,MMIXAL
assembler, test suite, sample programs, full documentation, andMMMIX
architectural (pipeline) simulator (gzip
GzipGzip is any of several software applications used for file compression and decompression. The term usually refers to the GNU Project's implementation, "gzip" standing for GNU zip. It is based on the DEFLATE algorithm, which is a combination of Lempel-Ziv and Huffman coding...
pedtar
file).Tar (file format)In computing, tar is both a file format and the name of a program used to handle such files... - MMIXX – An X11X Window SystemThe X window system is a computer software system and network protocol that provides a basis for graphical user interfaces and rich input device capability for networked computers...
-based graphics package contributed by Andrew Pochinsky of MITMassachusetts Institute of TechnologyThe Massachusetts Institute of Technology is a private research university located in Cambridge, Massachusetts. MIT has five schools and one college, containing a total of 32 academic departments, with a strong emphasis on scientific and technological education and research.Founded in 1861 in...
’s Center for Theoretical Physics which, when combined with the MMIXware sources above, augments the MMIX virtual machine with a 640×480 pixelDisplay resolutionThe display resolution of a digital television or display device is the number of distinct pixels in each dimension that can be displayed. It can be an ambiguous term especially as the displayed resolution is controlled by all different factors in cathode ray tube , flat panel or projection...
, true-color ‘virtual display’ (for UNIX/Linux).
Compiler
The GNU Compiler CollectionGNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
includes an MMIX back-end for its C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
/C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
compilers, contributed by Hans-Peter Nilsson and part of the main GCC distribution since late 2001. As of January 2011, the MMIX back-end to GCC continues to be actively developed and maintained by volunteers.
- Installation instructions for GCC + MMIX tools by Hans-Peter Nilsson.
- §3.17.26. MMIX Options for GNUGNUGNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...
GCCGNU Compiler CollectionThe GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
version 4.5.2 (GNU GCC Web site). - §9.25. MMIX-dependent Features for GNUGNUGNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...
asGNU AssemblerThe GNU Assembler, commonly known as GAS , is the assembler used by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software. It is a part of the GNU Binutils package.GAS' executable is named after as, a...
from GNU binutils version 2.21, the assembler back-end for GNU GCC (GNU Binutils Web site).
The above tools could theoretically be used to compile, build, and bootstrap an entire FreeBSD
FreeBSD
FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...
, Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
, or other similar operating system kernel onto MMIX hardware, were such hardware to exist.
See also
- Educational programming languageEducational programming languageAn educational programming language is a programming language that is designed primarily as a learning instrument and not so much as a tool for writing programs for real-world work.-Learning paths:...
- DLXDLXThe DLX is a RISC processor architecture designed by John L. Hennessy and David A. Patterson, the principal designers of the MIPS and the Berkeley RISC designs , the two benchmark examples of RISC design. The DLX is essentially a cleaned up and simplified MIPS, with a simple 32-bit load/store...
- LC-3LC-3Little Computer 3, or LC-3, is a type of computer educational programming language, an assembly language, which is a type of low-level programming language. It features a relatively simple instruction set, but can be used to write moderately complex assembly programs, and is a theoretically viable...
- Little man computerLittle man computerThe Little Man Computer is an instructional model of a computer, created by Dr. Stuart Madnick in 1965. The LMC is generally used to teach students, because it models a simple von Neumann architecture computer - which has all of the basic features of a modern computer...
- MikroSimMikroSimThe program MikroSim is an educational software for hardware-non-specific explanation of the general functioning and behaviour of a virtual processor, running on the operating system Microsoft Windows...
- MIXMIXMIX is a hypothetical computer used in Donald Knuth's monograph, The Art of Computer Programming . MIX's model number is 1009, which was derived by combining the model numbers and names of several contemporaneous, commercial machines deemed significant by the author...
External links
- Donald Knuth's MMIX page — A brief introduction to MMIX, and Knuth's reasons for using a hypothetical assembly languageAssembly languageAn assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...
in TAoCP. - Donald Knuth's MMIX news page — An open-source simulator written in CWEBCWEBCWEB is a computer programming system created by Donald Knuth and Silvio Levy as a follow up to Knuth's WEB literate programming system, using the C programming language instead of Pascal....
, a programmer's manual, and example programs. - MMIXmasters web site A web site for the volunteers (MMIXmasters) who are converting all of the programs in TAOCP, Volumes 1 - 3, from the old language MIX to the new language MMIX.
- VMMMIX VMMMIX is the MMIX virtual machine. It has console, HDD and Ethernet I/Os. Currently, this virtual machine runs on Windows only. And Linux runs on this MMIX virtual machine.
- The MMIX Homepage In September 2011, MMIX has moved its home from Stanford to Munich.
- The VMB Homepage The Virtual Motherboard Project offers a pug and play collection of devices that can be used with an appropriate version of the MMIX cpu.