MMIX
MMIX는 도널드 카누스가 만든 64비트 RISC 가상기계이다. MIPS 칩을 만든 존 L. 헤네시와 DEC 알파 칩을 설계한 딕 사이츠도 MMIX의 설계에 많은 기여를 했다. 카누스에 따르면 앞으로 그가 쓰는 The Art of Computer Programming (TAoCP)에서는 MMIX를 이용하여 컴퓨터 프로그래밍의 기계 수준 알고리즘 분석을 할 것이라고 한다. MMIX는 '엠믹스'라고 읽는다.
MMIX의 이전 버전인 MIX는 The Art of Computer Programming의 현재판까지만 사용된다. MMIX는 컴퓨터 설계에 대한 현대적인 접근방법을 모두 채택하여 처음부터 새로 만들어졌으며 기존의 MIX를 완전히 대체할 것이다.
구조
MMIX는 64 비트의 가상주소공간을 가진 빅 엔디안 형태의 이진 컴퓨터이다. 명령어는 32비트이다.
명령어
모든 명령어는 관련된 약어를 가지고 있다. 예를 들어 명령어 32는 'ADD'와 연결된다. 대부분의 명령은 "OP, X, Y, Z"과 같은 형태를 따른다. 여기서 OP는 명령어에 해당하고, X는 결과값을 저장할 레지스터이다. 나머지는 명령어에 인자로 사용할 값들을 저장한다. 여기서 명령어의 각 부분은 모두 8비트이다. 예를 들어 "ADD $0, $1, 3"라는 명령은 1번 레지스터의 값에 3을 더해서 그 결과값을 0번 레지스터에 저장한다." 라는 의미이다. MMIX 프로그램은 보통 MMIXAL 어셈블리 언어로 구성된다.
Hello world 프로그램
MMIXAL로 Hello, world를 출력하는 프로그램이다.
Main GETA $255,string ; Get the address of the string
; in register 255.
TRAP 0,Fputs,StdOut ; Put the string pointed to
; by register 255 to file StdOut.
TRAP 0,Halt,0 ; End process.
string BYTE "Hello, world!",#a,0 ; String to be printed.
; #a is newline,
; 0 terminates the string.
레지스터
MMIX 칩에는 $0부터 $255까지 256개의 범용 레지스터와 32개의 특수 레지스터가 있다.
지역 레지스터 스택
특수 레지스터
이 문단에는 한국어로 번역되지 않은 내용이 담겨 있습니다. |
32개의 특수 레지스터는 다음과 같다.
- rB, 부트스트랩 레지스터 (trip)
- When tripping, rB <- $255 and $255 <- rJ. rJ를 일반 레지스터에 저장한다.
- 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.
참고문헌
- Donald E. Knuth (1999). MMIXware: A RISC Computer for the Third Millennium. Heidelberg: Springer-Verlag. ISBN 3-540-66938-8 (errata)
바깥 고리
- Donald Knuth's MMIX page — MMIX에 대한 간략한 소개와 왜 'The Art of Computer Programming'에 가상의 어셈블리어를 이용할 수밖에 없었는지에 대한 설명.
- Donald Knuth's MMIX news page — CWEB으로 만든 MMIX의 오픈 소스 시뮬레이터와 프로그래머 매뉴얼, 예제 프로그램.
- MMIXmasters web site TAOCP 1권 ~ 3권에서 예전 MIX로 만든 예제 프로그램을 새로운 MMIX로 바꾸려는 사람(MMIXmasters)들의 모임.