Jump to content

MMIX: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Xanjaxn (talk | contribs)
m Add a link to the MIT Center for Theoretical Physics
 
(48 intermediate revisions by 34 users not shown)
Line 1: Line 1:
{{about|the instruction set architecture|the year|2009}}
{{Short description|64 bit RISC architecture by Donald Knuth}}
{{About|the instruction set architecture|the year|2009|the song|Mylo Xyloto}}
{{Infobox CPU architecture
{{Infobox CPU architecture
| name = [[Image:Mmix.png|220px|alt=MMIX]]
| name = [[Image:Mmix.png|220px|alt=MMIX]]
| designer = [[Donald Knuth]]
| designer = [[Donald Knuth]]
| bits = 64-bit
| bits = 64-bit
| introduced =
| introduced = 1999
| version =
| version =
| design = RISC
| design = RISC
Line 12: Line 13:
| endianness = Big
| endianness = Big
| extensions =
| extensions =
| open = Yes
| open = Yes, and royalty free
| registers = 32 special-purpose registers
| registers = 32 special-purpose registers
| gpr = 256
| gpr = 256
}}
}}

'''MMIX''' (pronounced ''em-mix'') is a [[64-bit]] [[reduced instruction set computing]] (RISC) [[Computer architecture|architecture]] designed by [[Donald Knuth]], with significant contributions by [[John L. Hennessy]] (who contributed to the design of the [[MIPS architecture]]) and Richard L. Sites (who was an architect of the [[DEC Alpha|Alpha]] architecture). Knuth has said that "MMIX is a computer intended to illustrate machine-level aspects of programming. In my books ''[[The Art of Computer Programming]]'', it replaces [[MIX]], the 1960s-style machine that formerly played such a role… I strove to design MMIX so that its machine language would be simple, elegant, and easy to learn. At the same time I was careful to include all of the complexities needed to achieve high performance in practice, so that MMIX could in principle be built and even perhaps be competitive with some of the fastest general-purpose computers in the marketplace."<ref name="MMIXware">{{Citation | last=Knuth | first=Donald E. |date = October 1999| title=MMIXware: A RISC Computer for the Third Millennium | volume=1750 | series=''Lecture Notes in Computer Science Tutorial'' | publication-place=Heidelberg | publisher=Springer-Verlag | isbn=3-540-66938-8 | url = https://books.google.com/books?id=bIJlBAAAQBAJ }} [https://www-cs-faculty.stanford.edu/~knuth/mmixware.html (Errata)]</ref>
'''MMIX''' (pronounced ''em-mix'') is a [[64-bit]] [[reduced instruction set computing]] (RISC) [[Computer architecture|architecture]] designed by [[Donald Knuth]], with significant contributions by [[John L. Hennessy]] (who contributed to the design of the [[MIPS architecture]]) and Richard L. Sites (who was an architect of the [[DEC Alpha|Alpha]] architecture). Knuth has said that,

<blockquote>MMIX is a computer intended to illustrate machine-level aspects of programming. In my books ''[[The Art of Computer Programming]]'', it replaces [[MIX (abstract machine)|MIX]], the 1960s-style machine that formerly played such a role… I strove to design MMIX so that its machine language would be simple, elegant, and easy to learn. At the same time I was careful to include all of the complexities needed to achieve high performance in practice, so that MMIX could in principle be built and even perhaps be competitive with some of the fastest general-purpose computers in the marketplace."<ref name="MMIXware">{{Citation | last=Knuth | first=Donald E. |date = October 1999| title=MMIXware: A RISC Computer for the Third Millennium | volume=1750 | series=Lecture Notes in Computer Science Tutorial | publication-place=Heidelberg | publisher=Springer-Verlag | isbn=3-540-66938-8 | url = https://books.google.com/books?id=bIJlBAAAQBAJ }} [https://www-cs-faculty.stanford.edu/~knuth/mmixware.html (Errata)]</ref></blockquote>

Knuth started the design of MMIX in 1999, and released the stable version of the design in 2011.<ref>{{Cite web|title=MMIX Home: A Message From Don Knuth|url=http://mmix.cs.hm.edu/message.html|access-date=2021-05-23|website=mmix.cs.hm.edu}}</ref> The processor is numbered as "2009" with Knuth explaining that this is the [[arithmetic mean]] from the numbers of other computer architectures; as well as being "MMIX" in [[Roman numerals]].<ref>{{cite video|url=https://www.youtube.com/watch?v=r_pPF5npnio&t=7m36s |archive-url=https://ghostarchive.org/varchive/youtube/20211211/r_pPF5npnio| archive-date=2021-12-11 |url-status=live|type=offset 7:36|series=Stanford Lecture|first=Donald|last=Knuth|title=MMIX: A RISC Computer for the New Millennium|date=1999-02-09|quote=([[Cray-1]] + [[IBM 801]] + [[Berkeley RISC#RISC II|RISC II]] + [[Clipper architecture|Clipper]] C300 + [[AMD 29k]] + [[Motorola 88000|Motorola 88k]] + [[IBM 601]] + [[Intel i960]] + [[Alpha 21164]] + [[POWER2]] + [[MIPS R4000]] + [[Hitachi SH-4|Hitachi Super H4]] + [[StrongARM]] 110 + [[SPARC]]64) / 14 = 28126 / 14 = 2009}}{{cbignore}}</ref>


==Architecture==
==Architecture==
MMIX is a [[Endianness|big-endian]] 64-bit [[reduced instruction set computer]] (RISC), with 256 64-bit general-purpose registers, 32 64-bit special-purpose registers, [[instruction set#Instruction length|fixed-length]] 32-bit [[instruction (computer science)|instruction]]s and a 64-bit [[virtual address space]]. The MMIX instruction set comprises 256 opcodes, one of which is reserved for future expansion{{citation needed|date=January 2017}}. MMIX uses [[IEEE 754]] floating-point numbers.
MMIX is a [[Endianness|big-endian]] 64-bit [[reduced instruction set computer]] (RISC), with 256 64-bit general-purpose registers, 32 64-bit special-purpose registers, [[instruction set#Instruction length|fixed-length]] 32-bit [[instruction (computer science)|instruction]]s and a 64-bit [[virtual address space]]. The MMIX instruction set comprises 256 opcodes, one of which is reserved for future expansion.{{citation needed|date=January 2017}} MMIX uses [[IEEE 754]] floating-point numbers.


===Instructions===
===Instructions===
All instructions have an associated mnemonic. For example, instruction #20 (32) 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."
All instructions have an associated mnemonic. For example, instruction #20 (32 decimal) is associated with ADD. Most instructions have the symbolic form {{code|OP X,Y,Z}}, where {{mono|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, {{code|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.
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!]]":
MMIX programs are typically constructed using the MMIXAL assembly language. The below is a simple MMIXAL program, which prints the string "[[Hello, world!]]":
<source lang="text">
<syntaxhighlight lang="text">
LOC #100 % Set the address of the program
LOC #100 % Set the address of the program
% initially to 0x100.
% initially to 0x100.
Line 43: Line 49:
% newline, 0 terminates the
% newline, 0 terminates the
% string.
% string.
</syntaxhighlight>
</source>


===Registers===
===Registers===
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.
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… {{nowrap|([rL] − 1)}} are local registers, and represent a [[Register window|window]] into an internal stack of registers.<ref name="rstack" /> Registers from [rL] {{nowrap|([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.
Two of the special registers, rL and rG, determine which of the general registers are local and which are global. All registers from $0... {{nowrap|([rL] − 1)}} are local registers, and represent a [[Register window|window]] into an internal stack of registers.<ref name="rstack" /> Registers from [rL]... {{nowrap|([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.


====Local register stack====
====Local register stack====
The local register stack provides each subroutine with its own rL local registers, designated by $0 through {{nowrap|$(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.<ref name="rstack">{{cite book|last=Knuth|first=Donald|authorlink=Donald Knuth|title=MMIX—A RISC Computer for the New Millennium|series=The Art of Computer Programming|volume=Vol. 1, Fasc. 1|year=2005|publisher=Addison Wesley|page=58|chapter=Section 1.4.2'}}</ref> 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 local register stack provides each subroutine with its own rL local registers, designated by $0 through {{nowrap|$(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.<ref name="rstack">{{cite book|last=Knuth|first=Donald|author-link=Donald Knuth|title=MMIX—A RISC Computer for the New Millennium|series=The Art of Computer Programming|volume=1, Fasc. 1|year=2005|publisher=Addison Wesley|page=58|chapter=Section 1.4.2'}}</ref> 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====
====Special registers====
Line 121: Line 127:
Like programs running on almost all other CPUs,
Like programs running on almost all other CPUs,
MMIX programs can be [[interrupt]]ed in several ways.
MMIX programs can be [[interrupt]]ed in several ways.
External hardware, such as timers, are a common source of [[preemption (computing)]] interrupts.
External hardware, such as timers, are a common source of [[preemption (computing)|preemption interrupts]].
Many instructions cause an interrupts in certain exceptional cases; such as the [[memory protection]] [[page fault]] exceptions used to implement virtual memory, and floating point [[exception handling]].
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".
MMIX has 2 kinds of interrupts: "trips" and "traps".
The main difference between "trips" and "traps" is that
The main difference between "trips" and "traps" is that
Line 131: Line 137:


==Hardware implementations==
==Hardware implementations==
{{As of|2015|10}}, no known hardware implementations of the MMIX instruction set architecture exist. However, the fpgammix<ref>{{cite web|author=master |url=http://repo.or.cz/w/fpgammix.git |title=fpgammix |publisher=Repo.or.cz |date=2008-08-24 |accessdate=2014-05-25}}</ref> project implements MMIX in [[Verilog]], making it possible to implement using a [[field-programmable gate array]].
{{As of|2015|10}}, no known hardware implementations of the MMIX instruction set architecture exist. However, the fpgammix<ref>{{cite web|author=master |url=http://repo.or.cz/w/fpgammix.git |title=fpgammix |publisher=Repo.or.cz |date=2008-08-24 |access-date=2014-05-25}}</ref> project implements MMIX in [[Verilog]], making it possible to implement using a [[field-programmable gate array]].


==Software tools==
==Software tools==
Line 137: Line 143:


===Simulators and assembler===
===Simulators and assembler===
* MMIXware<ref>{{cite web |url=https://www-cs-faculty.stanford.edu/~knuth/mmix-news.html |title=MMIXware |publisher=Cs-faculty.stanford.edu |date= |accessdate=2014-05-25}}</ref> &ndash; Donald Knuth’s MMIX-SIM simple (behavioral) simulator, MMIXAL assembler, test suite, sample programs, full documentation, and MMIX architectural (pipeline) simulator (<code>[[gzip]]ped</code> <code>[[tar (file format)|tar]]</code> file).
* MMIXware<ref>{{cite web |url=https://www-cs-faculty.stanford.edu/~knuth/mmix-news.html |title=MMIXware |publisher=Cs-faculty.stanford.edu |access-date=2014-05-25}}</ref> &ndash; Donald Knuth's MMIX-SIM simple (behavioral) simulator, MMIXAL assembler, test suite, sample programs, full documentation, and MMIX architectural (pipeline) simulator (<code>[[gzip]]ped</code> <code>[[tar (file format)|tar]]</code> file).
* MMIXX<ref>{{cite web |url=https://www.malgil.com/mmix/graphics/ |title=MMIXX |publisher=Malgil.com |date=2002-03-06 |accessdate=2014-05-25}}</ref> &ndash; An [[X Window System|X11]]-based graphics package contributed by Andrew Pochinsky of [[Massachusetts Institute of Technology|MIT]]’s Center for Theoretical Physics which, when combined with the MMIXware sources above, augments the MMIX virtual machine with a [[Display resolution|640×480 pixel]], [[True Color|true-color]] ‘virtual display’ (for UNIX/Linux).
* MMIXX<ref>{{cite web |url=https://www.malgil.com/mmix/graphics/ |title=MMIXX |publisher=Malgil.com |date=2002-03-06 |access-date=2014-05-25}}</ref> &ndash; An [[X Window System|X11]]-based graphics package contributed by Andrew Pochinsky of [[Massachusetts Institute of Technology|MIT]]’s [[MIT Center for Theoretical Physics|Center for Theoretical Physics]] which, when combined with the MMIXware sources above, augments the MMIX virtual machine with a [[Display resolution|640×480 pixel]], [[24-bit color|true-color]] ‘virtual display’ (for UNIX/Linux).


===Compiler===
===Compiler===
The [[GNU Compiler Collection]] includes an MMIX [[compilers#Back end|back-end]] for its [[C (programming language)|C]]/[[C++]] compilers, contributed by Hans-Peter Nilsson and part of the main GCC distribution since late 2001. {{As of|2017|11}}, the MMIX back-end to GCC continues to be actively developed and maintained by volunteers.
The [[GNU Compiler Collection]] includes an MMIX [[compilers#Back end|back-end]] for its [[C (programming language)|C]]/[[C++]] compilers, contributed by Hans-Peter Nilsson and part of the main GCC distribution since late 2001. {{As of|2017|11}}, 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.<ref>http://bitrange.com/mmix/install.html Installation instructions for GCC + MMIX tools</ref>
* Installation instructions for GCC + MMIX tools by Hans-Peter Nilsson.<ref>[http://bitrange.com/mmix/install.html Installation instructions for GCC + MMIX tools]</ref>
* §3.17.26. MMIX Options for [[GNU]] [[GNU Compiler Collection|GCC]] version 7.2.0<ref>https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/MMIX-Options.html §3.17.26. MMIX</ref> (GNU GCC Web site).
* §3.17.26. MMIX Options for [[GNU]] [[GNU Compiler Collection|GCC]] version 7.2.0<ref>https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/MMIX-Options.html §3.17.26. MMIX</ref> (GNU GCC Web site).
* §9.28.{{nbsp}} MMIX-dependent Features<ref>{{cite web |url=https://sourceware.org/binutils/docs-2.29/as/MMIX_002dDependent.html#MMIX_002dDependent |title=§9.28 MMIX Dependent Features |publisher=Sourceware.org |date= |accessdate=2017-11-20}}</ref> for [[GNU]] [[GNU Assembler|as]] from [[GNU Binutils]] version 2.29, the assembler back-end for GNU GCC (GNU Binutils Web site).
* §9.28.{{nbsp}} MMIX-dependent Features<ref>{{cite web |url=https://sourceware.org/binutils/docs-2.29/as/MMIX_002dDependent.html#MMIX_002dDependent |title=§9.28 MMIX Dependent Features |publisher=Sourceware.org |access-date=2017-11-20}}</ref> for [[GNU]] [[GNU Assembler|as]] from [[GNU Binutils]] version 2.29, 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]], [[Linux]], or other similar operating system kernel onto MMIX hardware, were such hardware to exist.
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.


Line 150: Line 156:
* [[Educational programming language]]
* [[Educational programming language]]
* [[DLX]]
* [[DLX]]
* [[LC-3]]
* [[Little Computer 3|LC-3]]
* [[Little man computer]]
* [[Little man computer]]
* [[MikroSim]]
* [[MikroSim]]
* [[MIX]]
* [[MIX (abstract machine)|MIX]]
* [[NAR 2]], another processor designed by a professor to help students learn.
* [[NAR 2]], another processor designed by a professor to help students learn


==References==
== References ==
{{reflist}}
{{Reflist}}


== Further reading ==
*Donald E. Knuth (2005). ''The Art of Computer Programming Volume 1 Fascicle 1: MMIX A RISC Computer for the New Millennium''. Addison-Wesley. {{ISBN|0-201-85392-2}} [https://www-cs-staff.stanford.edu/~uno/taocp.html#err1f1 (errata)]
* Donald E. Knuth (2005). ''The Art of Computer Programming Volume 1 Fascicle 1: MMIX A RISC Computer for the New Millennium''. Addison-Wesley. {{ISBN|0-201-85392-2}} [https://www-cs-staff.stanford.edu/~uno/taocp.html#err1f1 (errata)]
* Martin Ruckert (2015). ''MMIX Supplement, The: Supplement to The Art of Computer Programming Volumes 1, 2, 3 by Donald E. Knuth''. Addison-Wesley. {{ISBN|0-133-99231-4}}


==External links==
==External links==
{{Commons category}}
*[http://mmix.cs.hm.edu MMIX Home Page]
*[https://www-cs-faculty.stanford.edu/~knuth/mmix.html Donald Knuth's MMIX page] &mdash; A brief introduction to MMIX, and Knuth's reasons for using a hypothetical [[assembly language]] in TAoCP.
*[https://www-cs-faculty.stanford.edu/~knuth/mmix.html Donald Knuth's MMIX page] &mdash; A brief introduction to MMIX, and Knuth's reasons for using a hypothetical [[assembly language]] in TAoCP.
*[https://www-cs-faculty.stanford.edu/~knuth/mmix-news.html Donald Knuth's MMIX news page] &mdash; An [[open-source software|open source]] simulator written in [[CWEB]], a programmer's manual, and example programs.
*[https://www-cs-faculty.stanford.edu/~knuth/mmix-news.html Donald Knuth's MMIX news page] &mdash; An [[open-source software|open source]] simulator written in [[CWEB]], a programmer's manual, and example programs.
*[http://mmix.cs.hm.edu/mmixmasters/ MMIXmasters web site] &mdash; A web site for the volunteers (MMIXmasters) who are converting all of the programs in TAOCP, Volumes 1&ndash;3, from the old MIX to the new MMIX.
*[http://mmix.cs.hm.edu/mmixmasters/ MMIXmasters web site] &mdash; A web site for the volunteers (MMIXmasters) who are converting all of the programs in TAOCP, Volumes 1&ndash;3, from the old MIX to the new MMIX.
*[http://www007.upp.so-net.ne.jp/eiji-y/vmmmix/vmmmix.html VMMMIX] &mdash; 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.
*[http://www007.upp.so-net.ne.jp/eiji-y/vmmmix/vmmmix.html VMMMIX] {{Webarchive|url=https://web.archive.org/web/20090705154912/http://www007.upp.so-net.ne.jp/eiji-y/vmmmix/vmmmix.html |date=2009-07-05 }} &mdash; 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.
*[http://mmix.cs.hm.edu/index.html The MMIX Homepage] &mdash; In September 2011, MMIX has moved its home from Stanford to Munich.
*[http://vmb.sourceforge.net The VMB Homepage] &mdash; The Virtual Motherboard Project offers a plug and play collection of devices that can be used with an appropriate version of the MMIX CPU.
*[http://vmb.sourceforge.net The VMB Homepage] &mdash; The Virtual Motherboard Project offers a plug and play collection of devices that can be used with an appropriate version of the MMIX CPU.


{{Donald Knuth navbox}}
{{Donald Knuth navbox}}
{{Authority control}}


{{DEFAULTSORT:Mmix}}
{{DEFAULTSORT:Mmix}}
Line 175: Line 185:
[[Category:Educational abstract machines]]
[[Category:Educational abstract machines]]
[[Category:Instruction set architectures]]
[[Category:Instruction set architectures]]
[[Category:Computer-related introductions in 2011]]

Latest revision as of 19:20, 18 July 2024

MMIX
DesignerDonald Knuth
Bits64-bit
Introduced1999
DesignRISC
EncodingFixed
BranchingCondition Code
EndiannessBig
OpenYes, and royalty free
Registers
32 special-purpose registers
General-purpose256

MMIX (pronounced em-mix) is a 64-bit reduced instruction set computing (RISC) architecture designed by Donald Knuth, with significant contributions by John L. Hennessy (who contributed to the design of the MIPS architecture) and Richard L. Sites (who was an architect of the Alpha architecture). Knuth has said that,

MMIX is a computer intended to illustrate machine-level aspects of programming. In my books The Art of Computer Programming, it replaces MIX, the 1960s-style machine that formerly played such a role… I strove to design MMIX so that its machine language would be simple, elegant, and easy to learn. At the same time I was careful to include all of the complexities needed to achieve high performance in practice, so that MMIX could in principle be built and even perhaps be competitive with some of the fastest general-purpose computers in the marketplace."[1]

Knuth started the design of MMIX in 1999, and released the stable version of the design in 2011.[2] The processor is numbered as "2009" with Knuth explaining that this is the arithmetic mean from the numbers of other computer architectures; as well as being "MMIX" in Roman numerals.[3]

Architecture

[edit]

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.[citation needed] MMIX uses IEEE 754 floating-point numbers.

Instructions

[edit]

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!":

        LOC   #100                   % Set the address of the program
                                     % initially to 0x100.

Main    GETA  $255,string            % Put the address of the string
                                     % into register 255.

        TRAP  0,Fputs,StdOut         % Write the string pointed to by
                                     % register 255 to the standard
                                     % output file.

        TRAP  0,Halt,0               % End process.

string  BYTE  "Hello, world!",#a,0   % String to be printed.  #a is
                                     % newline, 0 terminates the
                                     % string.

Registers

[edit]

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.

Local register stack

[edit]

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.[4] 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

[edit]

The 32 special physical architectural registers are as follows:

  1. rB, the bootstrap register (trip)
  2. When tripping, rB ← $255 and $255 ← rJ. Thus saving rJ in a general register.
  3. 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.
  4. rE, the epsilon register
    Used for floating comparisons with respect to epsilon.
  5. rH, the himult register
    Used to store the left half of the 128-bit result of unsigned integer multiplication.
  6. rJ, the return-jump register
    Used to save the address of the next instruction by PUSHes and by POP to return from a PUSH.
  7. rM, the multiplex mask register
    Used by the multiplex instruction.
  8. rR, the remainder register
    Is set to the remainder of integer division.
  9. rBB, the bootstrap register (trap)
    When trapping, rBB ← $255 and $255 ← rJ. Thus saving rJ in a general register
  10. rC, the cycle counter
    Incremented every cycle.
  11. rN, the serial number
    A constant identifying this particular MMIX processor.
  12. rO, the register stack offset
    Used to implement the register stack.
  13. rS, the register stack pointer
    Used to implement the register stack.
  14. rI, the interval counter
    Decremented every cycle. Causes an interrupt when zero.
  15. rT, the trap address register
    Used to store the address of the trip vector.
  16. rTT, the dynamic trap address register
    Used to store the address of the trap vector.
  17. rK, the interrupt mask register
    Used to enable and disable specific interrupts.
  18. rQ, the interrupt request register
    Used to record interrupts as they occur.
  19. rU, the usage counter
    Used to keep a count of executed instructions.
  20. 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.
  21. rG, the global threshold register
    All general registers references with a number greater or equal to rG refer to global registers.
  22. rL, the local threshold register
    All general registers references with a number smaller than rL refer to local registers.
  23. rA, the arithmetic status register
    Used to record, enable and disable arithmetic exception like overflow and divide by zero.
  24. rF, the failure location register
    Used to store the address of the instruction that caused a failure.
  25. rP, the prediction register
    Used by conditional swap (CSWAP).
  26. rW, the where-interrupted register (trip)
    Used, when tripping, to store the address of the instruction after the one that was interrupted.
  27. rX, the execution register (trip)
    Used, when tripping, to store the instruction that was interrupted.
  28. rY, the Y operand (trip)
    Used, when tripping, to store the Y operand of the interrupted instruction.
  29. rZ, the Z operand (trip)
    Used, when tripping, to store the Z operand of the interrupted instruction.
  30. rWW, the where-interrupted register (trap)
    Used, when trapping, to store the address of the instruction after the one that was interrupted.
  31. rXX, the execution register (trap)
    Used, when trapping, to store the instruction that was interrupted.
  32. rYY, the Y operand (trap)
    Used, when trapping, to store the Y operand of the interrupted instruction.
  33. rZZ, the Z operand (trap)
    Used, when trapping, to store the Z operand of the interrupted instruction.

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.[1]: 38 

Hardware implementations

[edit]

As of October 2015, no known hardware implementations of the MMIX instruction set architecture exist. However, the fpgammix[5] project implements MMIX in Verilog, making it possible to implement using a field-programmable gate array.

Software tools

[edit]

The MMIX instruction set architecture is supported by a number of software tools for computer architecture research and software development.

Simulators and assembler

[edit]
  • MMIXware[6] – Donald Knuth's MMIX-SIM simple (behavioral) simulator, MMIXAL assembler, test suite, sample programs, full documentation, and MMIX architectural (pipeline) simulator (gzipped tar file).
  • MMIXX[7] – An X11-based graphics package contributed by Andrew Pochinsky of MIT’s Center for Theoretical Physics which, when combined with the MMIXware sources above, augments the MMIX virtual machine with a 640×480 pixel, true-color ‘virtual display’ (for UNIX/Linux).

Compiler

[edit]

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, 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.[8]
  • §3.17.26. MMIX Options for GNU GCC version 7.2.0[9] (GNU GCC Web site).
  • §9.28.  MMIX-dependent Features[10] for GNU as from GNU Binutils version 2.29, 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, Linux, or other similar operating system kernel onto MMIX hardware, were such hardware to exist.

See also

[edit]

References

[edit]
  1. ^ a b 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)
  2. ^ "MMIX Home: A Message From Don Knuth". mmix.cs.hm.edu. Retrieved 2021-05-23.
  3. ^ 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
  4. ^ a b 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.
  5. ^ master (2008-08-24). "fpgammix". Repo.or.cz. Retrieved 2014-05-25.
  6. ^ "MMIXware". Cs-faculty.stanford.edu. Retrieved 2014-05-25.
  7. ^ "MMIXX". Malgil.com. 2002-03-06. Retrieved 2014-05-25.
  8. ^ Installation instructions for GCC + MMIX tools
  9. ^ https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/MMIX-Options.html §3.17.26. MMIX
  10. ^ "§9.28 MMIX Dependent Features". Sourceware.org. Retrieved 2017-11-20.

Further reading

[edit]
  • Donald E. Knuth (2005). The Art of Computer Programming Volume 1 Fascicle 1: MMIX A RISC Computer for the New Millennium. Addison-Wesley. ISBN 0-201-85392-2 (errata)
  • Martin Ruckert (2015). MMIX Supplement, The: Supplement to The Art of Computer Programming Volumes 1, 2, 3 by Donald E. Knuth. Addison-Wesley. ISBN 0-133-99231-4
[edit]
  • MMIX Home Page
  • Donald Knuth's MMIX page — A brief introduction to MMIX, and Knuth's reasons for using a hypothetical assembly language in TAoCP.
  • Donald Knuth's MMIX news page — An open source simulator written in CWEB, 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 MIX to the new MMIX.
  • VMMMIX Archived 2009-07-05 at the Wayback Machine — 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 VMB Homepage — The Virtual Motherboard Project offers a plug and play collection of devices that can be used with an appropriate version of the MMIX CPU.