MMIX is a big-endian 64-bit reduced instruction set computer (RISC), with 256 64-bit general-purpose registers, 32 64-bit special-purpose registers, fixed-length 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. MMIX uses IEEE 754 floating-point numbers.
All instructions have an associated mnemonic. For example, instruction #20 (32 decimal) is associated with 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, ADD $0,$1,3 means "Set $0 to the sum of $1 and 3."
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 the string "Hello, world!":
There are 256 directly addressable general-purpose architectural registers in an MMIX chip, designated by $0 through $255, and 32 special-purpose architectural registers. The special-purpose registers can be accessed with the GET and PUT instructions. 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, and represent a window into an internal stack of registers.4 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 part of the 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 are pushed down the stack (by shifting the start of the window). The arguments of the called subroutine are left in the remaining local registers. When a subroutine finishes it pops the previously pushed registers. Because the internal stack can contain only a finite number of registers, it may be necessary to store a part of the stack in memory.5 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.
The 32 special physical architectural registers are as follows:
Like programs running on almost all other CPUs, MMIX programs can be interrupted in several ways. External hardware, such as timers, are a common source of preemption interrupts. Many instructions cause an interrupt in certain exceptional cases; such as the memory protection page fault exceptions used to implement virtual memory, and floating point exception handling. MMIX has 2 kinds of interrupts: "trips" and "traps". The main difference between "trips" and "traps" is that traps send control to a "trap handler" program in the operating system (trapping), but trips send control to a "trip handler" program in the user application (tripping). Users can also force any interrupt handler to run with explicit software interrupt instructions TRIP and TRAP, similar to some kinds of trap in other computer systems. In particular, a system call from a user program to the operating system uses a TRAP instruction.6: 38
As of October 2015[update][needs update], no known hardware implementations of the MMIX instruction set architecture exist. However, the fpgammix7 project implements MMIX in Verilog, making it possible to implement using a field-programmable gate array.
The MMIX instruction set architecture is supported by a number of software tools for computer architecture research and software development.
The GNU Compiler Collection 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 November 2017[update], 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.
Knuth, Donald E. (October 1999), MMIXware: A RISC Computer for the Third Millennium, Lecture Notes in Computer Science Tutorial, vol. 1750, Heidelberg: Springer-Verlag, ISBN 3-540-66938-8 (Errata) 3-540-66938-8 ↩
"MMIX Home: A Message From Don Knuth". mmix.cs.hm.edu. Retrieved 2021-05-23. http://mmix.cs.hm.edu/message.html ↩
Knuth, Donald (1999-02-09). MMIX: A RISC Computer for the New Millennium (offset 7:36). Stanford Lecture. Archived from the original on 2021-12-11. (Cray-1 + IBM 801 + RISC II + Clipper C300 + AMD 29k + Motorola 88k + IBM 601 + Intel i960 + Alpha 21164 + POWER2 + MIPS R4000 + Hitachi Super H4 + StrongARM 110 + SPARC64) / 14 = 28126 / 14 = 2009 https://www.youtube.com/watch?v=r_pPF5npnio&t=7m36s ↩
Knuth, Donald (2005). "Section 1.4.2'". MMIX—A RISC Computer for the New Millennium. The Art of Computer Programming. Vol. 1, Fasc. 1. Addison Wesley. p. 58. /wiki/Donald_Knuth ↩
tommythorn. "fpgammix". GitHub. Retrieved 2024-09-27. https://github.com/tommythorn/fpgammix ↩
"MMIXware". Cs-faculty.stanford.edu. Retrieved 2014-05-25. https://www-cs-faculty.stanford.edu/~knuth/mmix-news.html ↩
"MMIXX". Malgil.com. 2002-03-06. Retrieved 2014-05-25. https://www.malgil.com/mmix/graphics/ ↩
Installation instructions for GCC + MMIX tools http://bitrange.com/mmix/install.html ↩
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/MMIX-Options.html §3.17.26. MMIX https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/MMIX-Options.html ↩
"§9.28 MMIX Dependent Features". Sourceware.org. Retrieved 2017-11-20. https://sourceware.org/binutils/docs-2.29/as/MMIX_002dDependent.html#MMIX_002dDependent ↩