├── MIXWare.pdf ├── Examples ├── perms-input.deck ├── maximum.mixal ├── easter.mixal ├── perms.mixal └── primes.mixal ├── src ├── MIXLib │ ├── InstructionInfo.cs │ ├── MemoryCell.cs │ ├── MIXInstruction.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Devices.cd │ ├── MIXLib.csproj │ ├── CmdLine.cs │ ├── Parser │ │ ├── Set.cs │ │ └── Scanner.cs │ └── Machine.cd ├── MIXAsm │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── MIXAsm.csproj │ ├── Program.cs │ ├── Assembler.cs │ └── PrettyPrinter.cs ├── MIX │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── MIX.csproj │ └── Program.cs └── MIXWare.sln ├── doc ├── MIXWare.tex ├── fig │ ├── program.fig │ ├── ipart.fig │ ├── fpart.fig │ ├── wvalue.fig │ ├── atom.fig │ ├── apart.fig │ ├── expr.fig │ └── instruction.fig ├── appendixb.tex ├── mwmac.tex ├── frontmatter.tex ├── eps │ ├── program.eps │ ├── atom.eps │ ├── ipart.eps │ ├── fpart.eps │ ├── wvalue.eps │ ├── apart.eps │ ├── expr.eps │ └── instruction.eps ├── appendixa.tex ├── chapter2.tex └── chapter3.tex ├── LICENSE ├── README.md └── .gitignore /MIXWare.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtryf/MIXWare/HEAD/MIXWare.pdf -------------------------------------------------------------------------------- /Examples/perms-input.deck: -------------------------------------------------------------------------------- 1 | ( A C F G) ( B C D) (A E D ) 2 | ( F A D E) ( B G F A E) = -------------------------------------------------------------------------------- /Examples/maximum.mixal: -------------------------------------------------------------------------------- 1 | X EQU 1000 2 | ORIG 3000 3 | MAXIMUM STJ EXIT 4 | INIT ENT3 0,1 5 | JMP CHANGEM 6 | LOOP CMPA X,3 7 | JGE *+3 8 | CHANGEM ENT2 0,3 9 | LDA X,3 10 | DEC3 1 11 | J3P LOOP 12 | EXIT JMP * 13 | -------------------------------------------------------------------------------- /src/MIXLib/InstructionInfo.cs: -------------------------------------------------------------------------------- 1 | namespace MIXLib 2 | { 3 | public class InstructionInfo 4 | { 5 | public string Name; 6 | public byte DefaultField; 7 | public byte OpCode; 8 | public byte Time; 9 | } 10 | } -------------------------------------------------------------------------------- /src/MIXLib/MemoryCell.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MIXLib 4 | { 5 | [Serializable] 6 | public struct MemoryCell 7 | { 8 | public int SourceLocation { get; set; } 9 | public int Location { get; set; } 10 | public MIXWord Contents { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /doc/MIXWare.tex: -------------------------------------------------------------------------------- 1 | % MIXWare Report and Manual 2 | % As reverse engineered from PDF file 3 | % since the original TeX sources have gone missing. 4 | % Build with: tex MIXWare && dvipdf MIXWare 5 | 6 | \input epsf 7 | \input manmac 8 | \input mwmac 9 | 10 | \proofmodefalse 11 | \input frontmatter 12 | 13 | \input chapter1 14 | \input chapter2 15 | \input chapter3 16 | \input chapter4 17 | \input appendixa 18 | \input appendixb 19 | \end 20 | -------------------------------------------------------------------------------- /doc/fig/program.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1133.0 900 -1800 Program\001 11 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 12 | 2 1 1.0 144.00 240.00 13 | 3735 -900 13050 -900 14 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 15 | 2 1 1.0 144.00 240.00 16 | 450 -900 2025 -900 17 | 6 3735 -1170 2025 -585 18 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1366.0 2250 -765 instruction\001 19 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 20 | 2025 -1170 3735 -1170 3735 -585 2025 -585 2025 -1170 21 | -6 22 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 5 23 | 2 1 1.0 144.00 240.00 24 | 3735 -900 4140 -900 4140 450 1440 450 25 | 1440 -900 26 | -------------------------------------------------------------------------------- /src/MIXLib/MIXInstruction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace MIXLib 5 | { 6 | public class MIXInstruction 7 | { 8 | private Action executionProc; 9 | public string Name { get; private set; } 10 | 11 | public MIXInstruction(string name, Action executionProc) 12 | { 13 | this.Name = name; 14 | this.executionProc = executionProc; 15 | } 16 | 17 | public void Execute(MIXWord address, byte index, byte field) 18 | => executionProc(address, index, field); 19 | 20 | public void Execute(MIXWord address, byte index, byte left, byte right) 21 | => executionProc(address, index, (byte)(left * 8 + right)); 22 | } 23 | } -------------------------------------------------------------------------------- /doc/appendixb.tex: -------------------------------------------------------------------------------- 1 | \beginchapter Appendix B. MIXAL Syntax Diagrams 2 | 3 | Included here for future reference (no pun intended) are the syntax diagrams for the \MIXAL\ grammar. 4 | By inspection, it can be proven that the grammar we have distilled from the specification 5 | is in fact {\it LL}(1). 6 | 7 | \epsfxsize=.9\hsize 8 | \centerline{\epsfbox{eps/atom.eps}} 9 | \bigskip 10 | \epsfxsize=.9\hsize 11 | \centerline{\epsfbox{eps/expr.eps}} 12 | \bigskip 13 | \epsfxsize=.9\hsize 14 | \centerline{\epsfbox{eps/apart.eps}} 15 | \bigskip 16 | \epsfxsize=.9\hsize 17 | \centerline{\epsfbox{eps/ipart.eps}} 18 | \bigskip 19 | \epsfxsize=.9\hsize 20 | \centerline{\epsfbox{eps/fpart.eps}} 21 | \bigskip 22 | \epsfxsize=.9\hsize 23 | \centerline{\epsfbox{eps/wvalue.eps}} 24 | \bigskip 25 | \epsfxsize=.9\hsize 26 | \centerline{\epsfbox{eps/instruction.eps}} 27 | \bigskip 28 | \epsfxsize=.9\hsize 29 | \centerline{\epsfbox{eps/program.eps}} 30 | \endchapter 31 | \eject -------------------------------------------------------------------------------- /doc/fig/ipart.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 4 0 0 100 1 16 18.0 0.0 4 383.0 716.0 900 -450 I-Part\001 11 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 12 | 2 1 1.0 144.00 240.00 13 | 7515 990 10575 990 10575 0 14 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 15 | 2 1 1.0 144.00 240.00 16 | 2790 990 5625 990 17 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 18 | 2 1 1.0 144.00 240.00 19 | 1575 0 1575 990 2160 990 20 | 6 7515 675 5625 1305 21 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1433.0 5850 1080 expression\001 22 | 2 2 0 1 0 0 100 1 -1 6.40 0 0 0 0 0 5 23 | 5625 675 7515 675 7515 1305 5625 1305 5625 675 24 | -6 25 | 6 2790 673 2160 1305 26 | 4 0 0 100 1 16 18.0 0.0 4 383.0 83.0 2475 990 ,\001 27 | 1 1 0 1 0 0 100 1 -1 6.40 1 0.0 2475 990 315 315 2160 675 2790 1305 28 | -6 29 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 30 | 2 1 1.0 144.00 240.00 31 | 450 0 13050 0 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 George Tryfonas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /doc/fig/fpart.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 4 0 0 100 1 16 18.0 0.0 4 383.0 833.0 1350 -360 F-Part\001 11 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 12 | 2 1 1.0 144.00 240.00 13 | 7740 1170 9900 1170 9900 0 14 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 15 | 2 1 1.0 144.00 240.00 16 | 5940 1170 7110 1170 17 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 18 | 2 1 1.0 144.00 240.00 19 | 2835 1170 4005 1170 20 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 21 | 2 1 1.0 144.00 240.00 22 | 1350 0 1350 1170 2205 1170 23 | 4 0 0 100 1 16 18.0 0.0 4 383.0 100.0 7380 1260 )\001 24 | 1 1 0 1 0 0 100 1 -1 6.40 1 0.0 7425 1170 315 315 7110 855 7740 1485 25 | 6 5940 900 4005 1485 26 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1433.0 4275 1305 expression\001 27 | 2 2 0 1 0 0 100 1 -1 6.40 0 0 0 0 0 5 28 | 4005 900 5940 900 5940 1485 4005 1485 4005 900 29 | -6 30 | 6 2835 855 2205 1485 31 | 4 0 0 100 1 16 18.0 0.0 4 383.0 100.0 2475 1260 (\001 32 | 1 1 0 1 0 0 100 1 -1 6.40 1 0.0 2520 1170 315 315 2205 855 2835 1485 33 | -6 34 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 35 | 2 1 1.0 144.00 240.00 36 | 450 0 13050 0 37 | -------------------------------------------------------------------------------- /doc/fig/wvalue.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1133.0 900 -225 W-Value\001 11 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 12 | 2 1 1.0 144.00 240.00 13 | 6615 3105 3060 3105 3060 1170 14 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 15 | 2 1 1.0 144.00 240.00 16 | 1350 225 1350 855 2025 855 17 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 18 | 2 1 1.0 144.00 240.00 19 | 9045 855 10800 855 10800 225 20 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 21 | 2 1 1.0 144.00 240.00 22 | 450 225 13050 225 23 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 24 | 2 1 1.0 144.00 240.00 25 | 10125 855 10125 3105 7200 3105 26 | 6 7200 2788 6615 3375 27 | 4 0 0 100 1 16 18.0 0.0 4 383.0 83.0 6885 3105 ,\001 28 | 1 1 0 1 0 0 100 1 -1 6.40 1 0.0 6907 3082 292 292 6615 2790 7199 3374 29 | -6 30 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 31 | 2 1 1.0 144.00 240.00 32 | 3915 855 7875 855 33 | 6 9045 495 7875 1170 34 | 2 2 0 1 0 0 100 1 -1 6.40 0 0 0 0 0 5 35 | 7875 495 9045 495 9045 1170 7875 1170 7875 495 36 | 4 0 0 100 1 16 18.0 0.0 4 383.0 700.0 8100 945 f-part\001 37 | -6 38 | 6 3915 495 2025 1170 39 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1433.0 2250 945 expression\001 40 | 2 2 0 1 0 0 100 1 -1 6.40 0 0 0 0 0 5 41 | 2025 495 3915 495 3915 1170 2025 1170 2025 495 42 | -6 43 | -------------------------------------------------------------------------------- /doc/fig/atom.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 6 5175 855 3150 1755 11 | 6 4649 880 3666 1623 12 | 4 0 0 100 1 16 18.0 0.0 4 383.0 933.0 3666 1557 symbol\001 13 | 4 0 0 100 1 16 18.0 0.0 4 383.0 983.0 3666 1197 defined\001 14 | -6 15 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 16 | 3150 855 5175 855 5175 1755 3150 1755 3150 855 17 | -6 18 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 19 | 2 1 1.0 144.00 240.00 20 | 4590 3150 7425 3150 7425 2250 12825 2250 21 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 22 | 2 1 1.0 144.00 240.00 23 | 5175 1350 7425 1350 7425 2250 12825 2250 24 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 25 | 2 1 1.0 144.00 240.00 26 | 450 2250 2250 2250 2250 3150 3870 3150 27 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 28 | 2 1 1.0 144.00 240.00 29 | 450 2250 2250 2250 2250 1350 3150 1350 30 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1000.0 3666 2366 number\001 31 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 32 | 3150 2025 5175 2025 5175 2475 3150 2475 3150 2025 33 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 34 | 2 1 1.0 144.00 240.00 35 | 2025 2250 3150 2250 36 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 0 0 2 37 | 450 2250 2025 2250 38 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 39 | 2 1 1.0 144.00 240.00 40 | 5175 2250 12825 2250 41 | 6 4590 2790 3870 3510 42 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 4230 3150 360 360 3870 2790 4590 3510 43 | 4 0 0 100 1 16 18.0 0.0 4 383.0 116.0 4185 3285 *\001 44 | -6 45 | 4 0 0 100 1 16 18.0 0.0 4 383.0 666.0 855 405 Atom\001 46 | -------------------------------------------------------------------------------- /src/MIXAsm/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MIXAsm")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MIXAsm")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1f54e3f7-4d3d-472f-85a3-c3a7f3e8333d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/MIXLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RMLib")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RMLib")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("fc8cc757-f73e-45d9-88b9-cb3791640090")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/MIX/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RegisterMachine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RegisterMachine")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0df9147f-56c4-43c8-ad16-b60b71e61fa1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Examples/easter.mixal: -------------------------------------------------------------------------------- 1 | OUTDEV EQU 18 2 | EASTER STJ EASTX 3 | STX Y 4 | ENTA 0 5 | DIV =19= 6 | STX GMINUS1(0:2) 7 | LDA Y 8 | MUL =1//100+1= 9 | INCA 61 10 | STA CPLUS60(1:2) 11 | MUL =3//4+1= 12 | STA XPLUS57(1:2) 13 | CPLUS60 ENTA * 14 | MUL =8//25+1= 15 | GMINUS1 ENT2 * 16 | ENT1 1,2 17 | INC2 1,1 18 | INC2 0,2 19 | INC2 0,1 20 | INC2 0,2 21 | INC2 773,1 22 | XPLUS57 INCA -*,2 23 | SRAX 5 24 | DIV =30= 25 | DECX 24 26 | JXN 4F 27 | DECX 1 28 | JXP 2F 29 | JXN 3F 30 | DEC1 11 31 | J1NP 2F 32 | 3H INCX 1 33 | 2H DECX 29 34 | 4H STX 20MINUSN(0:2) 35 | LDA Y 36 | MUL =1//4+1= 37 | ADD Y 38 | SUB XPLUS57(1:2) 39 | 20MINUSN ENN1 * 40 | INCA 67,1 41 | SRAX 5 42 | DIV =7= 43 | SLAX 5 44 | DECA -4,1 45 | JAN 1F 46 | DECA 31 47 | CHAR 48 | LDA MARCH 49 | JMP 2F 50 | 1H CHAR 51 | LDA APRIL 52 | 2H JBUS *(OUTDEV) 53 | STA MONTH 54 | STX DAY(1:2) 55 | LDA Y 56 | CHAR 57 | STX YEAR 58 | OUT ANS(OUTDEV) 59 | EASTX JMP * 60 | MARCH ALF MARCH 61 | APRIL ALF APRIL 62 | ANS ALF 63 | DAY ALF DD 64 | MONTH ALF MMMMM 65 | ALF , 66 | YEAR ALF YYYYY 67 | ORIG *+20 68 | BEGIN ENTX 2000 69 | ENT6 2000-2050 70 | JMP EASTER 71 | INC6 1 72 | ENTX 2050,6 73 | J6NP EASTER+1 74 | HLT 75 | END BEGIN -------------------------------------------------------------------------------- /src/MIXWare.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MIX", "MIX\MIX.csproj", "{8FC52E82-584C-4247-890E-EBEF3C045A74}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MIXLib", "MIXLib\MIXLib.csproj", "{5A13219C-54BF-4368-9379-3FD5BDC65C76}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MIXAsm", "MIXAsm\MIXAsm.csproj", "{EE59ABE9-5D6B-4AF3-B4EE-CBDAC9754D64}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {8FC52E82-584C-4247-890E-EBEF3C045A74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {8FC52E82-584C-4247-890E-EBEF3C045A74}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {8FC52E82-584C-4247-890E-EBEF3C045A74}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {8FC52E82-584C-4247-890E-EBEF3C045A74}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {5A13219C-54BF-4368-9379-3FD5BDC65C76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {5A13219C-54BF-4368-9379-3FD5BDC65C76}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {5A13219C-54BF-4368-9379-3FD5BDC65C76}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {5A13219C-54BF-4368-9379-3FD5BDC65C76}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {EE59ABE9-5D6B-4AF3-B4EE-CBDAC9754D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {EE59ABE9-5D6B-4AF3-B4EE-CBDAC9754D64}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {EE59ABE9-5D6B-4AF3-B4EE-CBDAC9754D64}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {EE59ABE9-5D6B-4AF3-B4EE-CBDAC9754D64}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /Examples/perms.mixal: -------------------------------------------------------------------------------- 1 | MAXWDS EQU 1200 2 | PERM ORIG *+MAXWDS 3 | ANS ORIG *+MAXWDS 4 | OUTBUF ORIG *+24 5 | CARDS EQU 16 6 | PRINTER EQU 18 7 | BEGIN IN PERM(CARDS) 8 | ENT2 0 9 | LDA EQUALS 10 | 1H JBUS *(CARDS) 11 | CMPA PERM+15,2 12 | JE *+2 13 | IN PERM+16,2(CARDS) 14 | ENT1 OUTBUF 15 | JBUS *(PRINTER) 16 | MOVE PERM,2(16) 17 | OUT OUTBUF(PRINTER) 18 | JE 1F 19 | INC2 16 20 | CMP2 =MAXWDS-16= 21 | JLE 1B 22 | HLT 666 23 | 1H INC2 15 24 | ST2 SIZE 25 | ENT3 0 26 | 2H LDAN PERM,3 27 | CMPA LPREN(1:5) 28 | JNE 1F 29 | STA PERM,3 30 | INC3 1 31 | LDXN PERM,3 32 | JXZ *-2 33 | 1H CMPA RPREN(1:5) 34 | JNE *+2 35 | STX PERM,3 36 | INC3 1 37 | CMP3 SIZE 38 | JL 2B 39 | LDA LPREN 40 | ENT1 ANS 41 | OPEN ENT3 0 42 | 1H LDXN PERM,3 43 | JXN GO 44 | INC3 1 45 | CMP3 SIZE 46 | JL 1B 47 | * 48 | DONE CMP1 =ANS= 49 | JNE *+2 50 | MOVE LPREN(2) 51 | MOVE =0= 52 | MOVE -1,1(22) 53 | ENT3 0 54 | OUT ANS,3(PRINTER) 55 | INC3 24 56 | LDX ANS,3 57 | JXNZ *-3 58 | HLT 59 | * 60 | LPREN ALF ( 61 | RPREN ALF ) 62 | EQUALS ALF = 63 | * 64 | GO MOVE LPREN 65 | MOVE PERM,3 66 | STX START 67 | SUCC STX PERM,3 68 | INC3 1 69 | LDXN PERM,3(1:5) 70 | JXN 1F 71 | JMP *-3 72 | 5H STX 0,1 73 | INC1 1 74 | ENT3 0 75 | 4H CMPX PERM,3(1:5) 76 | JE SUCC 77 | 1H INC3 1 78 | CMP3 SIZE 79 | JL 4B 80 | CMPX START(1:5) 81 | JNE 5B 82 | CLOSE MOVE RPREN 83 | CMPA -3,1 84 | JNE OPEN 85 | INC1 -3 86 | JMP OPEN 87 | END BEGIN -------------------------------------------------------------------------------- /doc/fig/apart.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 11 | 2 1 1.0 144.00 240.00 12 | 4770 3195 6975 3195 6975 225 13 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 14 | 2 1 1.0 144.00 240.00 15 | 900 225 900 3195 2970 3195 16 | 6 4770 2700 2970 3690 17 | 6 4506 2833 3240 3486 18 | 4 0 0 100 1 16 18.0 0.0 4 383.0 766.0 3510 3150 future\001 19 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1266.0 3240 3420 reference\001 20 | -6 21 | 2 4 0 1 0 0 100 1 -1 6.40 0 0 12 0 0 5 22 | 2970 2700 4770 2700 4770 3690 2970 3690 2970 2700 23 | -6 24 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 25 | 2 1 1.0 144.00 240.00 26 | 450 225 13050 225 27 | 6 3105 808 1440 1260 28 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 29 | 1440 810 3105 810 3105 1260 1440 1260 1440 810 30 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1433.0 1575 1125 expression\001 31 | -6 32 | 6 2024 1665 1440 2249 33 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 1732 1957 292 292 1440 1665 2024 2249 34 | 4 0 0 100 1 16 18.0 0.0 4 383.0 183.0 1665 2070 =\001 35 | -6 36 | 6 4410 1665 2925 2205 37 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 38 | 2925 1665 4410 1665 4410 2205 2925 2205 2925 1665 39 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1033.0 3150 2025 w-value\001 40 | -6 41 | 6 5984 1665 5400 2249 42 | 4 0 0 100 1 16 18.0 0.0 4 383.0 183.0 5625 2070 =\001 43 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 5692 1957 292 292 5400 1665 5984 2249 44 | -6 45 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 3 46 | 2 1 1.0 144.00 240.00 47 | 900 225 900 1035 1440 1035 48 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 3 49 | 2 1 1.0 144.00 240.00 50 | 900 225 900 1935 1440 1935 51 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 52 | 2 1 1.0 144.00 240.00 53 | 2025 1935 2925 1935 54 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 55 | 2 1 1.0 144.00 240.00 56 | 4410 1935 5400 1935 57 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 3 58 | 2 1 1.0 144.00 240.00 59 | 5985 1935 6975 1935 6975 225 60 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 3 61 | 2 1 1.0 144.00 240.00 62 | 3105 1035 6975 1035 6975 225 63 | 4 0 0 100 1 16 18.0 0.0 4 383.0 833.0 900 -225 A-Part\001 64 | -------------------------------------------------------------------------------- /Examples/primes.mixal: -------------------------------------------------------------------------------- 1 | * Table of primes (TAOCP p. 148, Program P) 2 | * 3 | L EQU 500 # of primes to find 4 | OUTDEV EQU 18 Unit # of printer 5 | PRIME EQU -1 Memory area for table of primes 6 | BUF0 EQU 2000 Memory area for BUFFER[0] 7 | BUF1 EQU BUF0+25 Memory area for BUFFER[1] 8 | ORIG 3000 9 | START IOC 0(OUTDEV) Skip to new page 10 | LD1 =1-L= P1. Start table. J <- 1. 11 | LD2 =3= N <- 3. 12 | 2H INC1 1 P2. N is prime. J <- J + 1. 13 | ST2 PRIME+L,1 PRIME[J] <- N. 14 | J1Z 2F P3. 500 found? 15 | 4H INC2 2 P4. Advance N. 16 | ENT3 2 P5. K <- 2. 17 | 6H ENTA 0 P6. Does PRIME[K] divide N? 18 | ENTX 0,2 19 | DIV PRIME,3 20 | JXZ 4B R = 0? 21 | CMPA PRIME,3 P7. PRIME[K] large? 22 | INC3 1 P8. Advance K. 23 | JG 6B Jump if Q > PRIME[K]. 24 | JMP 2B Otherwise N is prime. 25 | 2H OUT TITLE(OUTDEV) P9. Print title. 26 | ENT4 BUF1+10 B <- 1. 27 | ENT5 -50 M <- 0. 28 | 2H INC5 L+1 Advance M. 29 | 4H LDA PRIME,5 P10. Set up line. (Right to left) 30 | CHAR 31 | STX 0,4(1:4) 32 | DEC4 1 33 | DEC5 50 (rI5 goes down by 50 until nonpositive) 34 | J5P 4B 35 | OUT 0,4(OUTDEV) P11. Print line. 36 | LD4 24,4 Switch buffers. 37 | J5N 2B If rI5 = 0, we're done. 38 | HLT 39 | * Initial contents. 40 | ORIG PRIME+1 41 | CON 2 First prime is 2. 42 | ORIG BUF0-5 43 | TITLE ALF FIRST 44 | ALF FIVE 45 | ALF HUND 46 | ALF RED P 47 | ALF RIMES 48 | ORIG BUF0+24 Each buffer points to the other. 49 | CON BUF1+10 50 | ORIG BUF1+24 51 | CON BUF0+10 52 | END START End of routine. 53 | -------------------------------------------------------------------------------- /src/MIX/MIX.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | {8FC52E82-584C-4247-890E-EBEF3C045A74} 8 | Exe 9 | Properties 10 | MIX 11 | MIX 12 | v4.6.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {5A13219C-54BF-4368-9379-3FD5BDC65C76} 48 | MIXLib 49 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /src/MIX/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using MIXLib; 7 | using MIXLib.Util; 8 | using System.Runtime.Serialization; 9 | using System.Runtime.Serialization.Formatters.Binary; 10 | using System.IO; 11 | 12 | namespace MIX 13 | { 14 | class Program 15 | { 16 | private static string GetInputFile(Dictionary cmdLine) 17 | { 18 | var a = cmdLine.Keys.Where(cl => !cl.StartsWith("-") && !cl.StartsWith("/")); 19 | if (a.Count() > 0) 20 | return a.First(); 21 | 22 | return null; 23 | } 24 | 25 | static void Main(string[] args) 26 | { 27 | Dictionary aliases = new Dictionary(); 28 | aliases.Add("-d", "--deck"); 29 | aliases.Add("-b", "--binary"); 30 | aliases.Add("-?", "--help"); 31 | aliases.Add("-h", "--help"); 32 | 33 | Dictionary cmdLine = CommandLineHelper.SplitCommandLine(Environment.CommandLine, aliases, true); 34 | if (cmdLine.Count == 0) 35 | { 36 | Console.WriteLine("This is MIX v0.1, (c) 2009 George Tryfonas\nAn mplementation of the machine described by Don Knuth.\n\nType '?' or 'help' at the prompt for instructions.\n"); 37 | MIXController c = new MIXController(); 38 | c.Interface(); 39 | } 40 | else 41 | { 42 | Stream stream; 43 | 44 | MIXMachine machine = new MIXMachine(); 45 | string inFile = GetInputFile(cmdLine); 46 | if (string.IsNullOrEmpty(inFile)) 47 | stream = Console.OpenStandardInput(); 48 | else 49 | stream = new FileStream(inFile, FileMode.Open); 50 | 51 | if (cmdLine.ContainsKey("--deck")) 52 | { 53 | machine.RedirectDevice(MIXMachine.CARD_READER, stream); 54 | machine.LoadDeck(); 55 | } 56 | else if (cmdLine.ContainsKey("--binary")) 57 | { 58 | IFormatter formatter = new BinaryFormatter(); 59 | MIXWord startLoc = (MIXWord)formatter.Deserialize(stream); 60 | List data = (List)formatter.Deserialize(stream); 61 | 62 | machine.LoadImage(data); 63 | machine.PC = startLoc; 64 | machine.Run(); 65 | } 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/MIXAsm/MIXAsm.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | {EE59ABE9-5D6B-4AF3-B4EE-CBDAC9754D64} 8 | Exe 9 | Properties 10 | MIXAsm 11 | MIXAsm 12 | v4.6.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {5A13219C-54BF-4368-9379-3FD5BDC65C76} 52 | MIXLib 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /src/MIXLib/Devices.cd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | YEAAAAAAAGAAAAFEAAAAAAQAgAAAAAABAAAAASAIACg= 14 | Devices.cs 15 | 16 | 17 | 18 | 19 | 20 | AEAAAAAAACAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA= 21 | Devices.cs 22 | 23 | 24 | 25 | 26 | 27 | AEAAAAAAACAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA= 28 | Devices.cs 29 | 30 | 31 | 32 | 33 | 34 | AEAAAAAAACAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA= 35 | Devices.cs 36 | 37 | 38 | 39 | 40 | 41 | AEAAAAAAACAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA= 42 | Devices.cs 43 | 44 | 45 | 46 | 47 | 48 | AEAAAAAAACAAAAAAAAAAQAAAgAAAAAAAAAAAAAAAAAg= 49 | Devices.cs 50 | 51 | 52 | 53 | 54 | 55 | AEAAAgAAACAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAg= 56 | Devices.cs 57 | 58 | 59 | 60 | 61 | 62 | AEAAAAAAACAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA= 63 | Devices.cs 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /doc/mwmac.tex: -------------------------------------------------------------------------------- 1 | % Macros for MIXWare Report 2 | 3 | \newif\ifusehrule 4 | \newcount\utilmix 5 | 6 | \def\loccount{{\ooalign{\hfil\lower.07ex\hbox{|*|}\hfil\crcr\Orb}}} 7 | \def\MIX{{\tt MIX}} 8 | \def\MIXAL{{\tt MIXAL}} 9 | \def\lalr#1{{\sl LALR}(#1)} 10 | \def\ll#1{{\sl LL}(#1)} 11 | 12 | \def\beginlisting{ 13 | \bgroup\offinterlineskip\halign\bgroup\offinterlineskip 14 | \vbox{\offinterlineskip\hbox{\vrule height2pt width0pt}\hbox{\strut\tt##:\hfil}\hbox{\vrule height2pt width0pt}}\quad&% memory location 15 | ##&% instruction word 16 | \quad\hfil\vbox{\offinterlineskip\hbox{\vrule height2pt width0pt}\hbox{\strut\sevenrm##}\hbox{\vrule height2pt width0pt}}&% line number 17 | \ \vbox{\offinterlineskip\hbox{\vrule height2pt width0pt}\hbox to 20pc{\strut##\hfil}\hbox{\vrule height2pt width0pt}}\cr% source code 18 | } 19 | 20 | \def\endlisting{\egroup\egroup} 21 | 22 | \def\mixword#1.#2.#3.#4.#5.#6.{% 23 | \vbox{\offinterlineskip% 24 | \ifnum\count0>\utilmix 25 | \global\utilmix=\count0\hrule 26 | \else 27 | \ifusehrule\hrule\fi 28 | \fi% 29 | \global\usehrulefalse% 30 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 31 | \hbox{% 32 | \vrule% 33 | \hbox to 15pt{\strut\hfil#1\hfil}% 34 | \vrule% 35 | \hbox to 15pt{\hfil\tt#2\hfil}% 36 | \vrule% 37 | \hbox to 15pt{\hfil\tt#3\hfil}% 38 | \vrule% 39 | \hbox to 15pt{\hfil\tt#4\hfil}% 40 | \vrule% 41 | \hbox to 15pt{\hfil\tt#5\hfil}% 42 | \vrule% 43 | \hbox to 15pt{\hfil\tt#6\hfil}% 44 | \vrule% 45 | }% 46 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 47 | \hrule% 48 | }% 49 | } 50 | 51 | \def\mixinst#1.#2.#3.#4.#5.{% 52 | \offinterlineskip\vbox{\offinterlineskip% 53 | \ifnum\count0>\utilmix 54 | \global\utilmix=\count0\hrule 55 | \else 56 | \ifusehrule\hrule\fi 57 | \fi% 58 | \global\usehrulefalse% 59 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 60 | \hbox{% 61 | \vrule% 62 | \hbox to 15pt{\strut\hfil#1\hfil}% 63 | \vrule% 64 | \hbox to 30.4pt{\hfil\tt#2\thinspace}% 65 | \vrule% 66 | \hbox to 15pt{\hfil\tt#3\hfil}% 67 | \vrule% 68 | \hbox to 15pt{\hfil\tt#4\hfil}% 69 | \vrule% 70 | \hbox to 15pt{\hfil\tt#5\hfil}% 71 | \vrule% 72 | }% 73 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 74 | \hrule% 75 | }% 76 | } 77 | -------------------------------------------------------------------------------- /src/MIXLib/MIXLib.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | {5A13219C-54BF-4368-9379-3FD5BDC65C76} 8 | Library 9 | Properties 10 | MIXLib 11 | MIXLib 12 | v4.6.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 68 | -------------------------------------------------------------------------------- /src/MIXLib/CmdLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace MIXLib.Util 6 | { 7 | public static class CommandLineHelper 8 | { 9 | public static Dictionary SplitCommandLine(string commandLine, Dictionary aliases) 10 | => SplitCommandLine(commandLine, aliases, false); 11 | 12 | public static Dictionary SplitCommandLine(string commandLine, Dictionary aliases, bool noCase) 13 | { 14 | bool inQuotes = false; 15 | Dictionary result = new Dictionary(); 16 | 17 | var argList = commandLine.Split(c => 18 | { 19 | if (c == '\"') 20 | inQuotes = !inQuotes; 21 | 22 | return !inQuotes && c == ' '; 23 | }) 24 | .Select(arg => 25 | { 26 | if (noCase) 27 | return arg.Trim().TrimMatchingQuotes('\"').ToLower(); 28 | else 29 | return arg.Trim().TrimMatchingQuotes('\"'); 30 | }).Where(arg => !string.IsNullOrEmpty(arg)).Skip(1); 31 | 32 | foreach (var a in argList) 33 | { 34 | var parts = a.Split(':'); 35 | 36 | if (parts.Length == 1) 37 | { 38 | if (aliases.ContainsKey(parts.First())) 39 | result.Add(aliases[parts.First()], null); 40 | else 41 | result.Add(parts.First(), null); 42 | } 43 | else 44 | { 45 | string k = parts.First(); 46 | string v = string.Join(":", parts.Skip(1).ToArray()); 47 | 48 | if (aliases.ContainsKey(k)) 49 | k = aliases[k]; 50 | 51 | result.Add(k, v); 52 | } 53 | } 54 | 55 | return result; 56 | } 57 | 58 | public static IEnumerable Split(this string str, 59 | Func controller) 60 | { 61 | int nextPiece = 0; 62 | 63 | for (int c = 0; c < str.Length; c++) 64 | { 65 | if (controller(str[c])) 66 | { 67 | yield return str.Substring(nextPiece, c - nextPiece); 68 | nextPiece = c + 1; 69 | } 70 | } 71 | 72 | yield return str.Substring(nextPiece); 73 | } 74 | 75 | public static string TrimMatchingQuotes(this string input, char quote) 76 | { 77 | if ((input.Length >= 2) && 78 | (input[0] == quote) && (input[input.Length - 1] == quote)) 79 | return input.Substring(1, input.Length - 2); 80 | 81 | return input; 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /doc/frontmatter.tex: -------------------------------------------------------------------------------- 1 | \font\booktitlefont=cmssdc10 at 46pt 2 | \font\chapterfont=cmr10 at 28pt 3 | \def\clos#1{{\rm clos}\left(#1\right)} 4 | % 5 | \pageno=-1 6 | \font\auth=cmssdc10 scaled\magstep4 7 | \font\elevenbf=cmbx10 scaled\magstephalf 8 | \font\elevenit=cmti10 scaled\magstephalf 9 | \font\elevenrm=cmr10 scaled\magstephalf 10 | \titlepage 11 | \line{\booktitlefont\hfill The MIXWare} 12 | \smallskip 13 | \line{\booktitlefont \hfill Report and Manual} 14 | \vskip 1pc 15 | \baselineskip 13pt \elevenbf 16 | \halign to\hsize{#\hfil\tabskip 0pt plus 1fil&#\hfil\tabskip0pt\cr 17 | \kern4.4mm\auth GEORGE \kern-1pt TRYFONAS& 18 | \tt george.tryfonas@gmail.com\cr} 19 | \vfill 20 | \eject 21 | 22 | % blank page 23 | \titlepage 24 | \null\vfill 25 | \eject 26 | 27 | % the introduction 28 | \titlepage 29 | \def\rhead{Introduction} 30 | \vbox to 8pc{ 31 | \rightline{\titlefont Introduction}\vss} 32 | {\topskip 9pc 33 | \vskip-\parskip 34 | \tenpoint\noindent\hang\hangafter-2 35 | \smash{\lower12pt\hbox to 0pt{\hskip-\hangindent\chapterfont T\hfill}}\hskip-16pt 36 | {\sc HE} \MIX\ computer is an imaginary computer invented by Don 37 | Knuth in the 1960s in order to present his exposition on computer algorithms. 38 | As Knuth puts it, the use of an imaginary computer and machine language helps 39 | avoid distracting the reader with the technicalities of one particular computer 40 | system, and the focus remains on truths that have always been---and will always 41 | be---valid, independent of any kind of technological evolution or current trends. 42 | 43 | There is no doubt about the truth of this statement. However, another kind of problem 44 | presents itself now. The \MIX\ computer is, well, $\ldots$imaginary. A reader cannot 45 | experiment with it, or even have a go at solving the exercises by sitting in front 46 | of a real computer terminal and writing programs. Nor even can one be certain 47 | that a particular solution to an exercise is correct, unless one checks the answer 48 | to the exercise, and even then, there may be many different solutions to a 49 | problem, but the answers present only one. Unless of course the reader is 50 | inclined to simulate \MIX\ in his or her head, or on a piece of paper. And these 51 | may very well have been Knuth's intentions for his readers. After all, there is no 52 | doubt that the reader that will get the most out of the books is the one who is 53 | patient and dilligent enough to go through this kind of process. But it still is a 54 | daunting task, often too frustrating, and for many people in many ways, a 55 | distraction of the kind that Knuth wanted for his readers to avoid in the first place. 56 | 57 | Apparently, these issues have been prevailing for quite some time, since many people 58 | have developed simulators for Knuth's mythical machine over the years. The software 59 | you now have on your hands is another such attempt. But why bother making yet another 60 | simulator, you may ask? That is a good question. This present attempt in no way claims 61 | to solve any problems that previous implementations do not. As a matter of fact, it 62 | may have less bells and whistles than most. It might be less friendly, less complete, 63 | or even slower in its calculations. But it delivers, correctly. And what has actually 64 | been implemented, was done exactly by the book, literally speaking. 65 | 66 | The question remains, then. Why another \MIX\ simulator? Here is the answer: 67 | for the fun of it. And the learning experience. Writing such a piece of software, 68 | however trivial it may seem, presents a number of great challenges. It is an 69 | exercise in compiler design, input\slash output, data structures and more. 70 | A computer simulator is a platform which, by definition, provides its clients 71 | with {\it everything that the actual computer provides}, imaginary or not. 72 | Furthermore, it must be done in the best possible way given the programming 73 | tools. 74 | 75 | The MIXWare are written in Microsoft Visual C\# v3.5, which is a pure object-oriented 76 | language. 77 | 78 | \medskip 79 | \line{{\sl Athens, Greece}\hfil---G. T.} 80 | \line{\sl June 2009\hfil} 81 | 82 | } 83 | \endchapter 84 | 85 | 'Tis the gift to be simple, 'tis the gift to be free. 86 | \author{JOSEPH BRACKETT}, {\sl Simple Gifts} (1848) 87 | 88 | \bigskip 89 | 90 | Everything should be made as simple as possible, 91 | but no simpler. 92 | \author{ALBERT EINSTEIN}, {\sl On the Method of % 93 | Theoretical Physics} (1933) 94 | \eject -------------------------------------------------------------------------------- /doc/eps/program.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\GTryf\AppData\Local\Temp\jfig-tmp4110209973326973592.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 13:58:58 2009 5 | %%For: GTryf@PC155 () 6 | %%BoundingBox: 0 0 796 162 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 162 moveto 0 0 lineto 796 0 lineto 796 162 lineto closepath clip newpath 49 | -27.6 29.1 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0.06299 0.06299 sc 89 | % 90 | % Fig objects follow 91 | % 92 | % Polyline 93 | 7.500 slw 94 | n 2025 -1170 m 3735 -1170 l 3735 -585 l 2025 -585 l 95 | cp gs col0 s gr 96 | /Helvetica ff 270.00 scf sf 97 | 2250 -765 m 98 | gs 1 -1 sc (instruction) col0 sh gr 99 | % Polyline 100 | gs clippath 101 | 13065 -828 m 13065 -972 l 12733 -971 l 13033 -899 l 12733 -827 l cp 102 | eoclip 103 | n 3735 -900 m 104 | 13050 -900 l gs col0 s gr gr 105 | 106 | % arrowhead 107 | n 12733 -827 m 13033 -899 l 12733 -971 l 12793 -899 l 12733 -827 l 108 | cp gs 0.00 setgray ef gr col0 s 109 | % Polyline 110 | gs clippath 111 | 2040 -828 m 2040 -972 l 1708 -971 l 2008 -899 l 1708 -827 l cp 112 | eoclip 113 | n 450 -900 m 114 | 2025 -900 l gs col0 s gr gr 115 | 116 | % arrowhead 117 | n 1708 -827 m 2008 -899 l 1708 -971 l 1768 -899 l 1708 -827 l 118 | cp gs 0.00 setgray ef gr col0 s 119 | % Polyline 120 | gs clippath 121 | 1512 -915 m 1368 -915 l 1368 -582 l 1440 -882 l 1512 -582 l cp 122 | eoclip 123 | n 3735 -900 m 4140 -900 l 4140 450 l 1440 450 l 124 | 1440 -900 l gs col0 s gr gr 125 | 126 | % arrowhead 127 | n 1512 -582 m 1440 -882 l 1368 -582 l 1440 -642 l 1512 -582 l 128 | cp gs 0.00 setgray ef gr col0 s 129 | /Helvetica ff 270.00 scf sf 130 | 900 -1800 m 131 | gs 1 -1 sc (Program) col0 sh gr 132 | $F2psEnd 133 | rs 134 | -------------------------------------------------------------------------------- /doc/fig/expr.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1466.0 900 315 Expression\001 11 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 12 | 2 1 1.0 144.00 240.00 13 | 10035 7425 9495 7425 9495 4725 8415 4725 14 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 15 | 2 1 1.0 144.00 240.00 16 | 10035 6525 9495 6525 9495 4725 8415 4725 17 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 18 | 2 1 1.0 144.00 240.00 19 | 10035 5625 9495 5625 9495 4725 8415 4725 20 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 21 | 2 1 1.0 144.00 240.00 22 | 10035 3825 9495 3825 9495 4725 8415 4725 23 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 24 | 2 1 1.0 144.00 240.00 25 | 10035 2925 9495 2925 9495 4725 8415 4725 26 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 27 | 2 1 1.0 144.00 240.00 28 | 7335 4725 7200 4725 7200 1575 29 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 30 | 2 1 1.0 144.00 240.00 31 | 11025 6525 11025 7425 10575 7425 32 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 33 | 2 1 1.0 144.00 240.00 34 | 11025 5625 11025 6525 10575 6525 35 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 36 | 2 1 1.0 144.00 240.00 37 | 11025 4725 11025 5625 10575 5625 38 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 39 | 2 1 1.0 144.00 240.00 40 | 11025 4725 10575 4725 41 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 2 42 | 2 1 1.0 144.00 240.00 43 | 11025 3825 10575 3825 44 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 5 45 | 2 1 1.0 144.00 240.00 46 | 12375 1575 12375 4725 11025 4725 11025 2925 47 | 10575 2925 48 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 49 | 2 1 1.0 144.00 240.00 50 | 3465 2250 4005 2250 4005 1575 5805 1575 51 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 52 | 2 1 1.0 144.00 240.00 53 | 3465 900 4005 900 4005 1575 5805 1575 54 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 55 | 2 1 1.0 144.00 240.00 56 | 2250 1575 2250 2250 2925 2250 57 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 3 58 | 2 1 1.0 144.00 240.00 59 | 2250 1575 2250 900 2925 900 60 | 6 10575 5310 10035 5850 61 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 10305 5580 270 270 10035 5310 10575 5850 62 | 4 0 0 100 1 16 18.0 0.0 4 383.0 83.0 10256 5715 /\001 63 | -6 64 | 6 10575 6210 10035 6750 65 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 10305 6480 270 270 10035 6210 10575 6750 66 | 4 0 0 100 1 16 18.0 0.0 4 383.0 166.0 10211 6615 //\001 67 | -6 68 | 6 10575 7155 10035 7695 69 | 6 10575 7155 10035 7695 70 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 10305 7425 270 270 10035 7155 10575 7695 71 | -6 72 | 4 0 0 100 1 16 18.0 0.0 4 383.0 83.0 10256 7515 :\001 73 | -6 74 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 0 0 2 75 | 450 1575 2115 1575 76 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 77 | 2 1 1.0 144.00 240.00 78 | 4185 1575 5805 1575 79 | 6 6885 1348 5805 1800 80 | 4 0 0 100 1 16 18.0 0.0 4 383.0 650.0 6030 1665 atom\001 81 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 82 | 5805 1350 6885 1350 6885 1800 5805 1800 5805 1350 83 | -6 84 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 85 | 2 1 1.0 144.00 240.00 86 | 6885 1575 13050 1575 87 | 6 3465 1980 2925 2520 88 | 6 3465 1980 2925 2520 89 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 3195 2250 270 270 2925 1980 3465 2520 90 | -6 91 | 4 0 0 100 1 16 18.0 0.0 4 383.0 100.0 3146 2340 -\001 92 | -6 93 | 6 3465 630 2925 1170 94 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 3195 900 270 270 2925 630 3465 1170 95 | 4 0 0 100 1 16 18.0 0.0 4 383.0 183.0 3105 1021 +\001 96 | -6 97 | 6 10575 2655 10035 3195 98 | 4 0 0 100 1 16 18.0 0.0 4 383.0 183.0 10215 3046 +\001 99 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 10305 2925 270 270 10035 2655 10575 3195 100 | -6 101 | 6 10575 3555 10035 4095 102 | 4 0 0 100 1 16 18.0 0.0 4 383.0 100.0 10256 3915 -\001 103 | 6 10575 3555 10035 4095 104 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 10305 3825 270 270 10035 3555 10575 4095 105 | -6 106 | -6 107 | 6 10575 4455 10035 4995 108 | 1 1 0 1 0 0 100 1 -1 0 1 0.0 10305 4725 270 270 10035 4455 10575 4995 109 | 4 0 0 100 1 16 18.0 0.0 4 383.0 116.0 10256 4905 *\001 110 | -6 111 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 0 0 2 112 | 9360 4725 10035 4725 113 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 114 | 2 1 1.0 144.00 240.00 115 | 9360 4725 8415 4725 116 | 6 8415 4498 7335 4950 117 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 118 | 7335 4500 8415 4500 8415 4950 7335 4950 7335 4500 119 | 4 0 0 100 1 16 18.0 0.0 4 383.0 650.0 7560 4815 atom\001 120 | -6 121 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 0 0 2 122 | 2115 1575 4185 1575 123 | -------------------------------------------------------------------------------- /doc/appendixa.tex: -------------------------------------------------------------------------------- 1 | \beginchapter Appendix A. Example Program Listing 2 | 3 | The following is the listing of the program |PRIMES.MIXAL|, 4 | as generated by |MIXASM|. End-of-instruction comments have been 5 | stripped in order for it to fit the page. 6 | \bigskip 7 | \beginlisting 8 | \omit\global\usehruletrue&\omit&1&|* Table of primes (TAOCP p. 148, Program P)|\cr 9 | \omit\global\usehruletrue&\omit&2&|*|\cr 10 | \omit\global\usehruletrue&\omit&3&|L EQU 500|\cr 11 | \omit\global\usehruletrue&\omit&4&|OUTDEV EQU 18|\cr 12 | \omit\global\usehruletrue&\omit&5&|PRIME EQU -1|\cr 13 | \omit\global\usehruletrue&\omit&6&|BUF0 EQU 2000|\cr 14 | \omit\global\usehruletrue&\omit&7&|BUF1 EQU BUF0+25|\cr 15 | \omit\global\usehruletrue&\omit&8&| ORIG 3000|\cr 16 | 3000&\mixinst$+$.0.0.18.35.&9&|START IOC 0(OUTDEV)|\cr 17 | 3001&\mixinst$+$.2050.0.5.9.&10&| LD1 =1-L=|\cr 18 | 3002&\mixinst$+$.2051.0.5.10.&11&| LD2 =3=|\cr 19 | 3003&\mixinst$+$.1.0.0.49.&12&|2H INC1 1|\cr 20 | 3004&\mixinst$+$.499.1.5.26.&13&| ST2 PRIME+L,1|\cr 21 | 3005&\mixinst$+$.3016.0.1.41.&14&| J1Z 2F|\cr 22 | 3006&\mixinst$+$.2.0.0.50.&15&|4H INC2 2|\cr 23 | 3007&\mixinst$+$.2.0.2.51.&16&| ENT3 2|\cr 24 | 3008&\mixinst$+$.0.0.2.48.&17&|6H ENTA 0|\cr 25 | 3009&\mixinst$+$.0.2.2.55.&18&| ENTX 0,2|\cr 26 | 3010&\mixinst$-$.1.3.5.4.&19&| DIV PRIME,3|\cr 27 | 3011&\mixinst$+$.3006.0.1.47.&20&| JXZ 4B|\cr 28 | 3012&\mixinst$-$.1.3.5.56.&21&| CMPA PRIME,3|\cr 29 | 3013&\mixinst$+$.1.0.0.51.&22&| INC3 1|\cr 30 | 3014&\mixinst$+$.3008.0.6.39.&23&| JG 6B|\cr 31 | 3015&\mixinst$+$.3003.0.0.39.&24&| JMP 2B|\cr 32 | 3016&\mixinst$+$.1995.0.18.37.&25&|2H OUT TITLE(OUTDEV)|\cr 33 | 3017&\mixinst$+$.2035.0.2.52.&26&| ENT4 BUF1+10|\cr 34 | 3018&\mixinst$-$.50.0.2.53.&27&| ENT5 -50|\cr 35 | 3019&\mixinst$+$.501.0.0.53.&28&|2H INC5 L+1|\cr 36 | 3020&\mixinst$-$.1.5.5.8.&29&|4H LDA PRIME,5|\cr 37 | 3021&\mixinst$+$.0.0.1.5.&30&| CHAR|\cr 38 | 3022&\mixinst$+$.0.4.12.31.&31&| STX 0,4(1:4)|\cr 39 | 3023&\mixinst$+$.1.0.1.52.&32&| DEC4 1|\cr 40 | 3024&\mixinst$+$.50.0.1.53.&33&| DEC5 50|\cr 41 | 3025&\mixinst$+$.3020.0.2.45.&34&| J5P 4B|\cr 42 | 3026&\mixinst$+$.0.4.18.37.&35&| OUT 0,4(OUTDEV)|\cr 43 | 3027&\mixinst$+$.24.4.5.12.&36&| LD4 24,4|\cr 44 | 3028&\mixinst$+$.3019.0.0.45.&37&| J5N 2B|\cr 45 | 3029&\mixinst$+$.0.0.2.5.&38&| HLT|\cr 46 | \omit\global\usehruletrue&\omit&39&|* Initial contents.|\cr 47 | \omit\global\usehruletrue&\omit&40&| ORIG PRIME+1|\cr 48 | 0000&\mixinst$+$.0.0.0.2.&41&| CON 2|\cr 49 | \omit\global\usehruletrue&\omit&42&| ORIG BUF0-5|\cr 50 | 1995&\mixinst$+$.393.19.22.23.&43&|TITLE ALF FIRST|\cr 51 | 1996&\mixinst$+$.6.9.25.5.&44&| ALF FIVE|\cr 52 | 1997&\mixinst$+$.8.24.15.4.&45&| ALF HUND|\cr 53 | 1998&\mixinst$+$.1221.4.0.17.&46&| ALF RED P|\cr 54 | 1999&\mixinst$+$.1225.14.5.22.&47&| ALF RIMES|\cr 55 | \omit\global\usehruletrue&\omit&48&| ORIG BUF0+24|\cr 56 | 2024&\mixinst$+$.0.0.31.51.&49&| CON BUF1+10|\cr 57 | \omit\global\usehruletrue&\omit&50&| ORIG BUF1+24|\cr 58 | 2049&\mixinst$+$.0.0.31.26.&51&| CON BUF0+10|\cr 59 | \omit\global\usehruletrue&\omit&52&| END START|\cr 60 | \omit&\omit&\omit&\omit\strut\cr 61 | \multispan4\global\usehruletrue\leaders\hrule\hfil{\it MAIN SYMBOLS}\leaders\hrule\hfil\cr 62 | \omit&\omit&\omit&\omit\strut\cr 63 | L&\mixword$+$.0.0.0.7.52.&=&500\cr 64 | OUTDEV&\mixword$+$.0.0.0.0.18.&=&18\cr 65 | PRIME&\mixword$-$.0.0.0.0.1.&=&-1\cr 66 | BUF0&\mixword$+$.0.0.0.31.16.&=&2000\cr 67 | BUF1&\mixword$+$.0.0.0.31.41.&=&2025\cr 68 | START&\mixword$+$.0.0.0.46.56.&=&3000\cr 69 | TITLE&\mixword$+$.0.0.0.31.11.&=&1995\cr 70 | \omit&\omit&\omit&\omit\strut\cr 71 | \multispan4\global\usehruletrue\leaders\hrule\hfil{\it LOCAL SYMBOLS}\leaders\hrule\hfil\cr 72 | \omit&\omit&\omit&\omit\strut\cr 73 | \|2-1\|&\mixword$+$.0.0.0.46.59.&=&3003\cr 74 | \|4-1\|&\mixword$+$.0.0.0.46.62.&=&3006\cr 75 | \|6-1\|&\mixword$+$.0.0.0.47.0.&=&3008\cr 76 | \|2-2\|&\mixword$+$.0.0.0.47.8.&=&3016\cr 77 | \|2-3\|&\mixword$+$.0.0.0.47.11.&=&3019\cr 78 | \|4-2\|&\mixword$+$.0.0.0.47.12.&=&3020\cr 79 | \omit&\omit&\omit&\omit\strut\cr 80 | \multispan4\global\usehruletrue\leaders\hrule\hfil{\it LITERALS}\leaders\hrule\hfil\cr 81 | \omit&\omit&\omit&\omit\strut\cr 82 | =-499=&\mixword$+$.0.0.0.32.2.&=&2050\cr 83 | =3=&\mixword$+$.0.0.0.32.3.&=&2051\cr 84 | \endlisting 85 | 86 | \endchapter 87 | \eject -------------------------------------------------------------------------------- /doc/fig/instruction.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.0 7 | Single 8 | -2 9 | 1200 2 10 | 6 5175 4365 4005 4950 11 | 4 0 0 100 1 16 18.0 0.0 4 383.0 633.0 4275 4770 END\001 12 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 13 | 4005 4365 5175 4365 5175 4950 4005 4950 4005 4365 14 | -6 15 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 16 | 2 1 1.0 144.00 240.00 17 | 5175 4680 5850 4680 5850 2205 6525 2205 18 | 2 1 0 1 0 0 100 1 -1 6.40 0 0 12 1 0 4 19 | 2 1 1.0 144.00 240.00 20 | 3060 2835 3465 2835 3465 4680 4005 4680 21 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1366.0 900 -1350 Instruction\001 22 | 6 3060 2520 1980 3105 23 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 24 | 1980 2520 3060 2520 3060 3105 1980 3105 1980 2520 25 | 4 0 0 100 1 16 18.0 0.0 4 383.0 633.0 2205 2925 label\001 26 | -6 27 | 6 5175 3420 4005 4005 28 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 29 | 4005 3420 5175 3420 5175 4005 4005 4005 4005 3420 30 | 4 0 0 100 1 16 18.0 0.0 4 383.0 650.0 4275 3825 EQU\001 31 | -6 32 | 6 5175 495 4005 1080 33 | 4 0 0 100 1 16 18.0 0.0 4 383.0 533.0 4320 900 ALF\001 34 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 35 | 4005 495 5175 495 5175 1080 4005 1080 4005 495 36 | -6 37 | 6 5175 1485 4005 2070 38 | 4 0 0 100 1 16 18.0 0.0 4 383.0 750.0 4230 1890 ORIG\001 39 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 40 | 4005 1485 5175 1485 5175 2070 4005 2070 4005 1485 41 | -6 42 | 6 5175 2520 4005 3105 43 | 4 0 0 100 1 16 18.0 0.0 4 383.0 666.0 4275 2925 CON\001 44 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 45 | 4005 2520 5175 2520 5175 3105 4005 3105 4005 2520 46 | -6 47 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 48 | 2 1 1.0 144.00 240.00 49 | 3060 2835 4005 2835 50 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 3 51 | 2 1 1.0 144.00 240.00 52 | 3465 2835 3465 1755 4005 1755 53 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 3 54 | 2 1 1.0 144.00 240.00 55 | 3465 1755 3465 765 4005 765 56 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 57 | 2 1 1.0 144.00 240.00 58 | 450 2835 1980 2835 59 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 60 | 2 1 1.0 144.00 240.00 61 | 1395 2835 1395 2115 3240 2115 3240 2835 62 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 63 | 2 1 1.0 144.00 240.00 64 | 5175 765 6660 765 65 | 6 7920 1845 6525 2520 66 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 67 | 6525 1845 7920 1845 7920 2520 6525 2520 6525 1845 68 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1033.0 6750 2295 w-value\001 69 | -6 70 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 71 | 2 1 1.0 144.00 240.00 72 | 5175 1755 5850 1755 5850 2205 6525 2205 73 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 74 | 2 1 1.0 144.00 240.00 75 | 5175 2835 5850 2835 5850 2205 6525 2205 76 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 77 | 2 1 1.0 144.00 240.00 78 | 5175 3735 5850 3735 5850 2205 6525 2205 79 | 6 5490 -405 4005 225 80 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 81 | 4005 -405 5490 -405 5490 225 4005 225 4005 -405 82 | 4 0 0 100 1 16 18.0 0.0 4 383.0 1116.0 4185 0 keyword\001 83 | -6 84 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 85 | 2 1 1.0 144.00 240.00 86 | 3060 2835 3465 2835 3465 -90 4005 -90 87 | 6 7785 -360 6660 180 88 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 89 | 6660 -360 7785 -360 7785 180 6660 180 6660 -360 90 | 4 0 0 100 1 16 18.0 0.0 4 383.0 783.0 6795 0 a-part\001 91 | -6 92 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 93 | 2 1 1.0 144.00 240.00 94 | 5490 -90 6660 -90 95 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 96 | 2 1 1.0 144.00 240.00 97 | 7785 -90 8550 -90 98 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 99 | 2 1 1.0 144.00 240.00 100 | 9675 -90 10395 -90 101 | 6 9675 -360 8550 180 102 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 103 | 8550 -360 9675 -360 9675 180 8550 180 8550 -360 104 | 4 0 0 100 1 16 18.0 0.0 4 383.0 683.0 8685 0 i-part\001 105 | -6 106 | 6 11520 -360 10395 180 107 | 2 2 0 1 0 0 100 1 -1 0 0 0 0 0 0 5 108 | 10395 -360 11520 -360 11520 180 10395 180 10395 -360 109 | 4 0 0 100 1 16 18.0 0.0 4 383.0 700.0 10530 0 f-part\001 110 | -6 111 | 6 7740 495 6660 1035 112 | 2 4 0 1 0 0 100 1 -1 0 0 0 12 0 0 5 113 | 6660 495 7740 495 7740 1035 6660 1035 6660 495 114 | 4 0 0 100 1 16 18.0 0.0 4 383.0 733.0 6840 855 string\001 115 | -6 116 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 2 117 | 2 1 1.0 144.00 240.00 118 | 7920 2205 13050 2205 119 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 120 | 2 1 1.0 144.00 240.00 121 | 11520 -90 12060 -90 12060 2205 13050 2205 122 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 123 | 2 1 1.0 144.00 240.00 124 | 7740 765 12060 765 12060 2205 13005 2205 125 | 2 1 0 1 0 0 100 1 -1 0 0 0 12 1 0 4 126 | 2 1 1.0 144.00 240.00 127 | 3060 2835 3465 2835 3465 3735 4005 3735 128 | -------------------------------------------------------------------------------- /src/MIXLib/Parser/Set.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MIXLib.Parser 6 | { 7 | public class Set 8 | { 9 | #region "Data" 10 | 11 | bool flagsEnum; 12 | readonly System.Collections.BitArray members; 13 | Dictionary mapMember2Index; 14 | #endregion 15 | 16 | #region "ctors" 17 | public Set() 18 | { 19 | Initialize(); 20 | members = new System.Collections.BitArray(mapMember2Index.Count); 21 | } 22 | 23 | private Set(System.Collections.BitArray members) 24 | { 25 | Initialize(); 26 | this.members = members; 27 | } 28 | 29 | private void Initialize() 30 | { 31 | if (typeof(TEnum).BaseType != typeof(System.Enum)) 32 | throw new ApplicationException(string.Format("Generic type parameter <{0}> is not an enum type!", 33 | typeof(TEnum).FullName)); 34 | flagsEnum = typeof(TEnum).GetCustomAttributes(typeof(System.FlagsAttribute), true).Length > 0; 35 | 36 | int i = 0; 37 | mapMember2Index = new Dictionary(); 38 | foreach (TEnum m in Enum.GetValues(typeof(TEnum))) 39 | mapMember2Index.Add(m, i++); 40 | } 41 | 42 | #endregion 43 | 44 | #region "Working with the set" 45 | public void Clear() 46 | { 47 | members.SetAll(false); 48 | } 49 | 50 | public Set Add(TEnum member) 51 | { 52 | members.Set(mapMember2Index[member], true); 53 | return this; 54 | } 55 | 56 | public Set Add(Set otherSet) 57 | { 58 | if (otherSet != null) members.Or(otherSet.members); 59 | return this; 60 | } 61 | 62 | public Set Remove(TEnum member) 63 | { 64 | members.Set(mapMember2Index[member], false); 65 | return this; 66 | } 67 | 68 | public Set Remove(Set otherSet) 69 | { 70 | if (otherSet != null) 71 | for (int i = 0; i < members.Count; i++) 72 | if (otherSet.members[i]) 73 | members[i] = false; 74 | return this; 75 | } 76 | 77 | public Set Intersect(Set otherSet) 78 | { 79 | if (otherSet != null) members.And(otherSet.members); 80 | return this; 81 | } 82 | 83 | public bool Contains(TEnum member) => members[mapMember2Index[member]]; 84 | 85 | public int Cardinality => members.Length; 86 | 87 | #endregion 88 | 89 | #region "Overrides" 90 | 91 | public override bool Equals(object obj) => this == (Set)obj; 92 | 93 | public override int GetHashCode() => members.GetHashCode(); 94 | 95 | public override string ToString() 96 | { 97 | string[] names = Enum.GetNames(typeof(TEnum)); 98 | 99 | StringBuilder memberNames = new StringBuilder("["); 100 | for (int i = 0; i < members.Count; i++) 101 | if (members[i]) 102 | { 103 | if (memberNames.Length > 1) memberNames.Append(","); 104 | memberNames.Append(names[i]); 105 | } 106 | memberNames.Append("]"); 107 | 108 | return memberNames.ToString(); 109 | } 110 | 111 | #endregion 112 | 113 | #region "Operators" 114 | 115 | // intersection 116 | public static Set operator &(Set left, Set right) 117 | { 118 | System.Collections.BitArray result = new System.Collections.BitArray(new bool[left.members.Count]); 119 | result.Or(left.members); 120 | if (right != null) result.And(right.members); 121 | return new Set(result); 122 | } 123 | 124 | // union 125 | public static Set operator |(Set left, Set right) 126 | { 127 | System.Collections.BitArray result = new System.Collections.BitArray(new bool[left.members.Count]); 128 | result.Or(left.members); 129 | if (right != null) result.Or(right.members); 130 | return new Set(result); 131 | } 132 | 133 | public static bool operator ==(Set left, Set right) 134 | { 135 | if (right != null) 136 | { 137 | for (int i = 0; i < left.members.Count; i++) 138 | if (left.members[i] != right.members[i]) return false; 139 | return true; 140 | } 141 | else 142 | return false; 143 | } 144 | 145 | public static bool operator !=(Set left, Set right) 146 | => !(left == right); 147 | 148 | #endregion 149 | 150 | #region "Iterator" 151 | 152 | public IEnumerator GetEnumerator() 153 | { 154 | TEnum[] memberValues = (TEnum[])Enum.GetValues(typeof(TEnum)); 155 | 156 | for (int i = 0; i < members.Count; i++) 157 | if (members[i]) 158 | yield return memberValues[i]; 159 | } 160 | 161 | #endregion 162 | } 163 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A Simulator for Knuth's MIX Computer 2 | 3 | ## Introduction and Background 4 | 5 | The MIX computer is an imaginary computer invented by Don Knuth in the 1960s in order to present his exposition on computer algorithms. As Knuth puts it, the use of an imaginary computer and machine language helps avoid distracting the reader with the technicalities of one particular computer system, and the focus remains on truths that have always been-and will always be-valid, independent of any kind of technological evolution or current trends. 6 | 7 | There is no doubt about the truth of this statement. However, another kind of problem presents itself now. The MIX computer is, well, ...imaginary. A reader cannot experiment with it, or even have a go at solving the exercises by sitting in front of a real computer terminal and writing programs. Nor even can one be certain that a particular solution to an exercise is correct, unless one checks the answer to the exercise, and even then, there may be many different solutions to a problem, but the answers present only one. Unless of course the reader is inclined to simulate MIX in his or her head, or on a piece of paper. And these may very well have been Knuth's intentions for his readers. After all, there is no doubt that the reader that will get the most out of the books is the one who is patient and diligent enough to go through this kind of process. But it still is a daunting task, often too frustrating, and for many people in many ways, a distraction of the kind that Knuth wanted for his readers to avoid in the first place. 8 | 9 | This is exactly the problem that the MIX simulator attempts to solve: a tool suite, capable of assembling and executing programs written in the MIXAL language, the MIX computer's assembly language. Features include a simplistic debugger, a complete implementation of the MIX computer's devices, symbol table generation, listing generation and typesetting for TeX, etc. 10 | 11 | The full specification of the MIX computer and the MIXAL assembly language can be found in The Art of Computer Programming vol. 1. In fact, this software package has little use to anybody who has not read, or has no intention to read, this series of books, follow its examples, and solve its exercises. So, have fun using it, but first of all, enjoy reading the books! 12 | 13 | ## Building 14 | 15 | Load the solution in Visual Studio and build. 16 | 17 | ## Using the Tools 18 | 19 | The **MIXWare** distribution contains the complete documentation in the form of a *.pdf* file. In it, you may find the detailed instructions on how to execute the assembler and make the most out of the simulator. However, a (very) brief tutorial follows. 20 | 21 | To assemble a MIXAL program: 22 | 23 | ```sh 24 | MIXASM -f:card -o:primes.deck primes.mixal 25 | ``` 26 | 27 | This command assembles the file "*primes.mixal*" as a punched card deck and saves the output to "*primes.deck*". 28 | 29 | The general syntax for MIXASM is: 30 | 31 | ```sh 32 | MIXASM [arguments] [input-file] 33 | ``` 34 | 35 | where the optional `input-file` parameter is the name of a text file containing MIXAL code (if unspecified, input comes from the keyboard), and the `arguments` govern the compilation process. In particular, the `--output` (or `-o` for short) argument specifies the compiled output filename (if unspecified, it is sent to the standard output), for example *--output:primes.deck* sends the output to the file *primes.deck*. The `--format` (or `-f` for short) argument specifies whether the compiled output will be in the form of a punched card deck or a serialized binary file. For instance, `-f:card` specifies that the output is a card deck, while `-f:binary` specifies that the output is a binary serialized file. `--symtab` (or `-s` for short) outputs the program's symbol table, either to the standard output or to a specified file (works just like the `--output` argument). Similarly, `--list-file` (or `-lf` for short) produces a program listing. In this case, the filename is mandatory. In the case that you requested a listing or a symbol table, you may additionally specify `--pretty-print` (or `-pp` for short) to request that the output be a TeX file so that you may run it through TeX to be typeset nicely. 36 | 37 | To start the simulator: 38 | 39 | ```sh 40 | MIX --deck primes.deck or MIX --binary primes.bin 41 | ``` 42 | 43 | This command starts the simulator and loads the card deck found in the file "*primes.deck*" or "*primes.bin*", depending on whether the source has been compiled to a card deck or to a binary serialized file. 44 | 45 | As soon as the simulator starts, it displays a prompt for you to input your commands. At this point, you may press `?` to get help on additional commands, the most important being "`run`", which begins execution of the program until it halts; "`step`", which executes only the next command pointed to by the Program Counter; and of course, "`quit`", if you've had enough of this! There exist a host of commands, all of which begin with "`show`", that echo the MIX computer's current state, as well as another set of commands, beginning with "`set`", that alter that state. Some examples are: 46 | 47 | | Command | Description | 48 | | ------- | ----------- | 49 | | `show memory` | shows the contents of MIX's memory. You may specify a range, such as in `show memory 3000 3010` to show only 11 words. If you specify a range, you may also request a disassembly, such as in `show memory 3000 3010 with disassembly`. | 50 | | `show state` | shows MIX's internal state, that is, the values of all the registers, flags, and the Program Counter. | 51 | | `set ` | sets the value of a particular MIX register, for example, `set rA 100`. | 52 | 53 | Chapters 1 and 2 of the documentation describe MIXASM and MIX in detail, including the simulator's command set and a full description of the assembler's command line arguments. 54 | 55 | ## Example Programs 56 | 57 | The repository's `Examples` directory contains a few example MIXAL files to get you started. They have all been copied from The Art of Computer Programming book. -------------------------------------------------------------------------------- /src/MIXAsm/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | using System.Runtime.Serialization; 8 | using System.Runtime.Serialization.Formatters.Binary; 9 | 10 | using MIXLib; 11 | using MIXLib.Util; 12 | using MIXLib.Parser; 13 | 14 | namespace MIXAsm 15 | { 16 | class Program 17 | { 18 | private static string GetInputFile(Dictionary cmdLine) 19 | { 20 | var a = cmdLine.Keys.Where(cl => !cl.StartsWith("-") && !cl.StartsWith("/")); 21 | if (a.Count() > 0) 22 | return a.First(); 23 | 24 | return null; 25 | } 26 | 27 | private static string GetOutputFile(Dictionary cmdLine) 28 | { 29 | if (cmdLine.ContainsKey("--output")) 30 | return cmdLine["--output"]; 31 | 32 | return null; 33 | } 34 | 35 | static void Main(string[] args) 36 | { 37 | Dictionary aliases = new Dictionary(); 38 | aliases.Add("-s", "--symtab"); 39 | aliases.Add("-o", "--output"); 40 | aliases.Add("-lf", "--list-file"); 41 | aliases.Add("-f", "--format"); 42 | aliases.Add("-a", "--append-deck"); 43 | aliases.Add("-pp", "--pretty-print"); 44 | aliases.Add("-?", "--help"); 45 | aliases.Add("-h", "--help"); 46 | 47 | Dictionary cmdLine = CommandLineHelper.SplitCommandLine(Environment.CommandLine, aliases, true); 48 | 49 | Console.Error.WriteLine("MIXAL Assembler, (c) 2009 George Tryfonas"); 50 | 51 | string inFile = GetInputFile(cmdLine); 52 | if (string.IsNullOrEmpty(inFile)) 53 | { 54 | Console.Error.WriteLine("No input file specified."); 55 | Environment.Exit(-1); 56 | } 57 | 58 | string outFile = GetOutputFile(cmdLine); 59 | 60 | try 61 | { 62 | MIXAssembler assembler = new MIXAssembler(inFile, outFile); 63 | 64 | if (cmdLine.ContainsKey("--format")) 65 | { 66 | switch (cmdLine["--format"]) 67 | { 68 | case "binary": 69 | assembler = new MIXAssembler(inFile, outFile, Format.Binary); 70 | break; 71 | case "card": 72 | assembler = new MIXAssembler(inFile, outFile, Format.Card); 73 | break; 74 | default: 75 | Console.Error.WriteLine(string.Format("Unknown output format: '{0}'", cmdLine["--format"])); 76 | System.Environment.Exit(-1); 77 | break; 78 | } 79 | } 80 | else 81 | assembler = new MIXAssembler(inFile, outFile); 82 | 83 | if (cmdLine.ContainsKey("--symtab")) 84 | { 85 | assembler.MakeSymbolTable = true; 86 | assembler.SymbolTableFile = cmdLine["--symtab"]; 87 | } 88 | 89 | if (cmdLine.ContainsKey("--list-file")) 90 | assembler.ListingFile = cmdLine["--list-file"]; 91 | 92 | Console.Error.WriteLine(string.Format("Output file is: '{0}'\nOutput format is: {1}", 93 | string.IsNullOrEmpty(assembler.OutputFile) ? "CONSOLE" : assembler.OutputFile, assembler.OutputFormat)); 94 | 95 | int wordCount = assembler.Assemble(); 96 | if (assembler.Errors.Count() > 0) 97 | { 98 | foreach (var e in assembler.Errors) 99 | Console.Error.WriteLine(string.Format("Error at {0},{1}: {2}", e.Line, e.Column, e.Text)); 100 | Console.Error.WriteLine("Assembly did not complete due to errors."); 101 | } 102 | else 103 | { 104 | Console.Error.WriteLine(string.Format("{0} word(s) assembled.", wordCount)); 105 | if (assembler.Warnings.Count() > 0) 106 | { 107 | foreach (var e in assembler.Warnings) 108 | Console.Error.WriteLine(string.Format("Error at {0},{1}: {2}", e.Line, e.Column, e.Text)); 109 | Console.Error.WriteLine("Assembly completed with warnings."); 110 | } 111 | else 112 | Console.Error.WriteLine("Assembly completed successfully."); 113 | 114 | if (assembler.OutputFormat == Format.Card && cmdLine.ContainsKey("--append-deck")) 115 | { 116 | string deckFile = cmdLine["--append-deck"]; 117 | Console.Error.WriteLine(string.Format("Appending deck file: '{0}'", deckFile)); 118 | StreamReader reader = new StreamReader(deckFile); 119 | string deck = reader.ReadToEnd(); 120 | reader.Close(); 121 | StreamWriter writer = new StreamWriter(assembler.OutputFile == null ? Console.OpenStandardOutput() : new FileStream(assembler.OutputFile, FileMode.Append)); 122 | writer.Write(deck); 123 | writer.Close(); 124 | } 125 | 126 | if (cmdLine.ContainsKey("--pretty-print")) 127 | assembler.PrettyPrinter = new TeXPrinter(assembler.InputFile); 128 | 129 | assembler.MakeOther(); 130 | } 131 | } 132 | catch (IOException e) 133 | { 134 | Console.Error.WriteLine("Input/output error: " + e.Message); 135 | Environment.Exit(-1); 136 | } 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /doc/eps/atom.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\GTryf\AppData\Local\Temp\jfig-tmp7739701969726532106.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 15:00:18 2009 5 | %%For: GTryf@PC155 () 6 | %%BoundingBox: 0 0 782 221 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 221 moveto 0 0 lineto 782 0 lineto 782 221 lineto closepath clip newpath 49 | -27.6 221.5 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /DrawEllipse { 84 | /endangle exch def 85 | /startangle exch def 86 | /yrad exch def 87 | /xrad exch def 88 | /y exch def 89 | /x exch def 90 | /savematrix mtrx currentmatrix def 91 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 92 | closepath 93 | savematrix setmatrix 94 | } def 95 | 96 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 97 | /$F2psEnd {$F2psEnteredState restore end} def 98 | 99 | $F2psBegin 100 | 10 setmiterlimit 101 | 0.06299 0.06299 sc 102 | % 103 | % Fig objects follow 104 | % 105 | /Helvetica ff 270.00 scf sf 106 | 855 405 m 107 | gs 1 -1 sc (Atom) col0 sh gr 108 | /Helvetica ff 270.00 scf sf 109 | 3666 1197 m 110 | gs 1 -1 sc (defined) col0 sh gr 111 | % Polyline 112 | 7.500 slw 113 | n 3330 855 m 3150 855 3150 1575 180 arcto 4 {pop} repeat 114 | 3150 1755 4995 1755 180 arcto 4 {pop} repeat 115 | 5175 1755 5175 1035 180 arcto 4 {pop} repeat 116 | 5175 855 3330 855 180 arcto 4 {pop} repeat 117 | cp gs col0 s gr 118 | % Ellipse 119 | n 4230 3150 360 360 0 360 DrawEllipse gs col0 s gr 120 | 121 | /Helvetica ff 270.00 scf sf 122 | 4185 3285 m 123 | gs 1 -1 sc (*) col0 sh gr 124 | % Polyline 125 | gs clippath 126 | 12840 2322 m 12840 2178 l 12508 2178 l 12808 2250 l 12508 2322 l cp 127 | eoclip 128 | n 4590 3150 m 7425 3150 l 7425 2250 l 129 | 12825 2250 l gs col0 s gr gr 130 | 131 | % arrowhead 132 | n 12508 2322 m 12808 2250 l 12508 2178 l 12568 2250 l 12508 2322 l 133 | cp gs 0.00 setgray ef gr col0 s 134 | % Polyline 135 | gs clippath 136 | 12840 2322 m 12840 2178 l 12508 2178 l 12808 2250 l 12508 2322 l cp 137 | eoclip 138 | n 5175 1350 m 7425 1350 l 7425 2250 l 139 | 12825 2250 l gs col0 s gr gr 140 | 141 | % arrowhead 142 | n 12508 2322 m 12808 2250 l 12508 2178 l 12568 2250 l 12508 2322 l 143 | cp gs 0.00 setgray ef gr col0 s 144 | % Polyline 145 | gs clippath 146 | 3885 3222 m 3885 3078 l 3553 3078 l 3853 3150 l 3553 3222 l cp 147 | eoclip 148 | n 450 2250 m 2250 2250 l 2250 3150 l 149 | 3870 3150 l gs col0 s gr gr 150 | 151 | % arrowhead 152 | n 3553 3222 m 3853 3150 l 3553 3078 l 3613 3150 l 3553 3222 l 153 | cp gs 0.00 setgray ef gr col0 s 154 | % Polyline 155 | gs clippath 156 | 3165 1422 m 3165 1278 l 2833 1278 l 3133 1350 l 2833 1422 l cp 157 | eoclip 158 | n 450 2250 m 2250 2250 l 2250 1350 l 159 | 3150 1350 l gs col0 s gr gr 160 | 161 | % arrowhead 162 | n 2833 1422 m 3133 1350 l 2833 1278 l 2893 1350 l 2833 1422 l 163 | cp gs 0.00 setgray ef gr col0 s 164 | % Polyline 165 | n 3330 2025 m 3150 2025 3150 2295 180 arcto 4 {pop} repeat 166 | 3150 2475 4995 2475 180 arcto 4 {pop} repeat 167 | 5175 2475 5175 2205 180 arcto 4 {pop} repeat 168 | 5175 2025 3330 2025 180 arcto 4 {pop} repeat 169 | cp gs col0 s gr 170 | % Polyline 171 | gs clippath 172 | 3165 2322 m 3165 2178 l 2833 2178 l 3133 2250 l 2833 2322 l cp 173 | eoclip 174 | n 2025 2250 m 175 | 3150 2250 l gs col0 s gr gr 176 | 177 | % arrowhead 178 | n 2833 2322 m 3133 2250 l 2833 2178 l 2893 2250 l 2833 2322 l 179 | cp gs 0.00 setgray ef gr col0 s 180 | % Polyline 181 | n 450 2250 m 182 | 2025 2250 l gs col0 s gr 183 | % Polyline 184 | gs clippath 185 | 12840 2322 m 12840 2178 l 12508 2178 l 12808 2250 l 12508 2322 l cp 186 | eoclip 187 | n 5175 2250 m 188 | 12825 2250 l gs col0 s gr gr 189 | 190 | % arrowhead 191 | n 12508 2322 m 12808 2250 l 12508 2178 l 12568 2250 l 12508 2322 l 192 | cp gs 0.00 setgray ef gr col0 s 193 | /Helvetica ff 270.00 scf sf 194 | 3666 2366 m 195 | gs 1 -1 sc (number) col0 sh gr 196 | /Helvetica ff 270.00 scf sf 197 | 3666 1557 m 198 | gs 1 -1 sc (symbol) col0 sh gr 199 | $F2psEnd 200 | rs 201 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/visualstudio 3 | 4 | ### VisualStudio ### 5 | ## Ignore Visual Studio temporary files, build results, and 6 | ## files generated by popular Visual Studio add-ons. 7 | ## 8 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 9 | 10 | # User-specific files 11 | *.suo 12 | *.user 13 | *.userosscache 14 | *.sln.docstates 15 | 16 | # User-specific files (MonoDevelop/Xamarin Studio) 17 | *.userprefs 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | bld/ 27 | [Bb]in/ 28 | [Oo]bj/ 29 | [Ll]og/ 30 | 31 | # Visual Studio 2015 cache/options directory 32 | .vs/ 33 | # Uncomment if you have tasks that create the project's static files in wwwroot 34 | #wwwroot/ 35 | 36 | # MSTest test Results 37 | [Tt]est[Rr]esult*/ 38 | [Bb]uild[Ll]og.* 39 | 40 | # NUNIT 41 | *.VisualState.xml 42 | TestResult.xml 43 | 44 | # Build Results of an ATL Project 45 | [Dd]ebugPS/ 46 | [Rr]eleasePS/ 47 | dlldata.c 48 | 49 | # .NET Core 50 | project.lock.json 51 | project.fragment.lock.json 52 | artifacts/ 53 | **/Properties/launchSettings.json 54 | 55 | *_i.c 56 | *_p.c 57 | *_i.h 58 | *.ilk 59 | *.meta 60 | *.obj 61 | *.pch 62 | *.pdb 63 | *.pgc 64 | *.pgd 65 | *.rsp 66 | *.sbr 67 | *.tlb 68 | *.tli 69 | *.tlh 70 | *.tmp 71 | *.tmp_proj 72 | *.log 73 | *.vspscc 74 | *.vssscc 75 | .builds 76 | *.pidb 77 | *.svclog 78 | *.scc 79 | 80 | # Chutzpah Test files 81 | _Chutzpah* 82 | 83 | # Visual C++ cache files 84 | ipch/ 85 | *.aps 86 | *.ncb 87 | *.opendb 88 | *.opensdf 89 | *.sdf 90 | *.cachefile 91 | *.VC.db 92 | *.VC.VC.opendb 93 | 94 | # Visual Studio profiler 95 | *.psess 96 | *.vsp 97 | *.vspx 98 | *.sap 99 | 100 | # TFS 2012 Local Workspace 101 | $tf/ 102 | 103 | # Guidance Automation Toolkit 104 | *.gpState 105 | 106 | # ReSharper is a .NET coding add-in 107 | _ReSharper*/ 108 | *.[Rr]e[Ss]harper 109 | *.DotSettings.user 110 | 111 | # JustCode is a .NET coding add-in 112 | .JustCode 113 | 114 | # TeamCity is a build add-in 115 | _TeamCity* 116 | 117 | # DotCover is a Code Coverage Tool 118 | *.dotCover 119 | 120 | # Visual Studio code coverage results 121 | *.coverage 122 | *.coveragexml 123 | 124 | # NCrunch 125 | _NCrunch_* 126 | .*crunch*.local.xml 127 | nCrunchTemp_* 128 | 129 | # MightyMoose 130 | *.mm.* 131 | AutoTest.Net/ 132 | 133 | # Web workbench (sass) 134 | .sass-cache/ 135 | 136 | # Installshield output folder 137 | [Ee]xpress/ 138 | 139 | # DocProject is a documentation generator add-in 140 | DocProject/buildhelp/ 141 | DocProject/Help/*.HxT 142 | DocProject/Help/*.HxC 143 | DocProject/Help/*.hhc 144 | DocProject/Help/*.hhk 145 | DocProject/Help/*.hhp 146 | DocProject/Help/Html2 147 | DocProject/Help/html 148 | 149 | # Click-Once directory 150 | publish/ 151 | 152 | # Publish Web Output 153 | *.[Pp]ublish.xml 154 | *.azurePubxml 155 | # TODO: Uncomment the next line to ignore your web deploy settings. 156 | # By default, sensitive information, such as encrypted password 157 | # should be stored in the .pubxml.user file. 158 | #*.pubxml 159 | *.pubxml.user 160 | *.publishproj 161 | 162 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 163 | # checkin your Azure Web App publish settings, but sensitive information contained 164 | # in these scripts will be unencrypted 165 | PublishScripts/ 166 | 167 | # NuGet Packages 168 | *.nupkg 169 | # The packages folder can be ignored because of Package Restore 170 | **/packages/* 171 | # except build/, which is used as an MSBuild target. 172 | !**/packages/build/ 173 | # Uncomment if necessary however generally it will be regenerated when needed 174 | #!**/packages/repositories.config 175 | # NuGet v3's project.json files produces more ignorable files 176 | *.nuget.props 177 | *.nuget.targets 178 | 179 | # Microsoft Azure Build Output 180 | csx/ 181 | *.build.csdef 182 | 183 | # Microsoft Azure Emulator 184 | ecf/ 185 | rcf/ 186 | 187 | # Windows Store app package directories and files 188 | AppPackages/ 189 | BundleArtifacts/ 190 | Package.StoreAssociation.xml 191 | _pkginfo.txt 192 | 193 | # Visual Studio cache files 194 | # files ending in .cache can be ignored 195 | *.[Cc]ache 196 | # but keep track of directories ending in .cache 197 | !*.[Cc]ache/ 198 | 199 | # Others 200 | ClientBin/ 201 | ~$* 202 | *~ 203 | *.dbmdl 204 | *.dbproj.schemaview 205 | *.jfm 206 | *.pfx 207 | *.publishsettings 208 | orleans.codegen.cs 209 | 210 | # Since there are multiple workflows, uncomment next line to ignore bower_components 211 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 212 | #bower_components/ 213 | 214 | # RIA/Silverlight projects 215 | Generated_Code/ 216 | 217 | # Backup & report files from converting an old project file 218 | # to a newer Visual Studio version. Backup files are not needed, 219 | # because we have git ;-) 220 | _UpgradeReport_Files/ 221 | Backup*/ 222 | UpgradeLog*.XML 223 | UpgradeLog*.htm 224 | 225 | # SQL Server files 226 | *.mdf 227 | *.ldf 228 | *.ndf 229 | 230 | # Business Intelligence projects 231 | *.rdl.data 232 | *.bim.layout 233 | *.bim_*.settings 234 | 235 | # Microsoft Fakes 236 | FakesAssemblies/ 237 | 238 | # GhostDoc plugin setting file 239 | *.GhostDoc.xml 240 | 241 | # Node.js Tools for Visual Studio 242 | .ntvs_analysis.dat 243 | node_modules/ 244 | 245 | # Typescript v1 declaration files 246 | typings/ 247 | 248 | # Visual Studio 6 build log 249 | *.plg 250 | 251 | # Visual Studio 6 workspace options file 252 | *.opt 253 | 254 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 255 | *.vbw 256 | 257 | # Visual Studio LightSwitch build output 258 | **/*.HTMLClient/GeneratedArtifacts 259 | **/*.DesktopClient/GeneratedArtifacts 260 | **/*.DesktopClient/ModelManifest.xml 261 | **/*.Server/GeneratedArtifacts 262 | **/*.Server/ModelManifest.xml 263 | _Pvt_Extensions 264 | 265 | # Paket dependency manager 266 | .paket/paket.exe 267 | paket-files/ 268 | 269 | # FAKE - F# Make 270 | .fake/ 271 | 272 | # JetBrains Rider 273 | .idea/ 274 | *.sln.iml 275 | 276 | # CodeRush 277 | .cr/ 278 | 279 | # Python Tools for Visual Studio (PTVS) 280 | __pycache__/ 281 | *.pyc 282 | 283 | # Cake - Uncomment if you are using it 284 | # tools/** 285 | # !tools/packages.config 286 | 287 | # Telerik's JustMock configuration file 288 | *.jmconfig 289 | 290 | # BizTalk build output 291 | *.btp.cs 292 | *.btm.cs 293 | *.odx.cs 294 | *.xsd.cs 295 | 296 | ### VisualStudio Patch ### 297 | # By default, sensitive information, such as encrypted password 298 | # should be stored in the .pubxml.user file. 299 | 300 | 301 | # End of https://www.gitignore.io/api/visualstudio 302 | 303 | doc/*.log 304 | doc/*.pdf 305 | doc/*.dvi 306 | doc/*.aux 307 | 308 | .vscode 309 | 310 | -------------------------------------------------------------------------------- /src/MIXLib/Machine.cd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | BAAIAAgAAgwUIgRSEARCCAIQBoIBCEAKIxIAKTEVQko= 98 | Machine.cs 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | YEAAAAAAAGAAAAFEAAAAAAQAgAAAAAABAAAAASAIACg= 127 | Devices.cs 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | ARgACAABIAAAAFAEyIGCIhRCAAAABIIAAABwIAAABzA= 137 | MIXWord.cs 138 | 139 | 140 | 141 | 142 | 143 | AAAAAAAQAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQQ= 144 | InstructionInfo.cs 145 | 146 | 147 | 148 | 149 | 150 | 152 | 153 | AAAAAAAAAAAEAAQAAAAAAAQAAAAAAAAAAAAAAAAAAAA= 154 | MIXInstruction.cs 155 | 156 | 157 | 158 | 159 | 160 | AAAAAAAAAAABAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAA= 161 | Machine.cs 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /doc/eps/ipart.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\George\AppData\Local\Temp\jfig-tmp7148498884111542474.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 01:14:06 2009 5 | %%For: George@MOSQUITO (U-MOSQUITO\George,S-1-5-21-4166747469-2723723270-1828463590-1000) 6 | %%BoundingBox: 0 0 796 136 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 136 moveto 0 0 lineto 796 0 lineto 796 136 lineto closepath clip newpath 49 | -27.6 83.0 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /reencdict 12 dict def /ReEncode { reencdict begin 84 | /newcodesandnames exch def /newfontname exch def /basefontname exch def 85 | /basefontdict basefontname findfont def /newfont basefontdict maxlength dict def 86 | basefontdict { exch dup /FID ne { dup /Encoding eq 87 | { exch dup length array copy newfont 3 1 roll put } 88 | { exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall 89 | newfont /FontName newfontname put newcodesandnames aload pop 90 | 128 1 255 { newfont /Encoding get exch /.notdef put } for 91 | newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat 92 | newfontname newfont definefont pop end } def 93 | /isovec [ 94 | 8#055 /minus 8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde 95 | 8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis 96 | 8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron 97 | 8#220 /dotlessi 8#230 /oe 8#231 /OE 98 | 8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling 99 | 8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis 100 | 8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot 101 | 8#255 /hyphen 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus 102 | 8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph 103 | 8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine 104 | 8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf 105 | 8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute 106 | 8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring 107 | 8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute 108 | 8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute 109 | 8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve 110 | 8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply 111 | 8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex 112 | 8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave 113 | 8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring 114 | 8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute 115 | 8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute 116 | 8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve 117 | 8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide 118 | 8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex 119 | 8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def 120 | /Helvetica /Helvetica-iso isovec ReEncode 121 | /DrawEllipse { 122 | /endangle exch def 123 | /startangle exch def 124 | /yrad exch def 125 | /xrad exch def 126 | /y exch def 127 | /x exch def 128 | /savematrix mtrx currentmatrix def 129 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 130 | closepath 131 | savematrix setmatrix 132 | } def 133 | 134 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 135 | /$F2psEnd {$F2psEnteredState restore end} def 136 | 137 | $F2psBegin 138 | 10 setmiterlimit 139 | 0.06299 0.06299 sc 140 | % 141 | % Fig objects follow 142 | % 143 | /Helvetica-iso ff 270.00 scf sf 144 | 900 -450 m 145 | gs 1 -1 sc (I-Part) col0 sh gr 146 | /Helvetica-iso ff 270.00 scf sf 147 | 5850 1080 m 148 | gs 1 -1 sc (expression) col0 sh gr 149 | 7.500 slw 150 | % Ellipse 151 | n 2475 990 315 315 0 360 DrawEllipse gs col0 s gr 152 | 153 | /Helvetica-iso ff 270.00 scf sf 154 | 2475 990 m 155 | gs 1 -1 sc (,) col0 sh gr 156 | % Polyline 157 | gs clippath 158 | 10647 -15 m 10503 -15 l 10503 317 l 10575 17 l 10647 317 l cp 159 | eoclip 160 | n 7515 990 m 10575 990 l 161 | 10575 0 l gs col0 s gr gr 162 | 163 | % arrowhead 164 | n 10647 317 m 10575 17 l 10503 317 l 10575 257 l 10647 317 l 165 | cp gs 0.00 setgray ef gr col0 s 166 | % Polyline 167 | gs clippath 168 | 5640 1062 m 5640 918 l 5308 918 l 5608 990 l 5308 1062 l cp 169 | eoclip 170 | n 2790 990 m 171 | 5625 990 l gs col0 s gr gr 172 | 173 | % arrowhead 174 | n 5308 1062 m 5608 990 l 5308 918 l 5368 990 l 5308 1062 l 175 | cp gs 0.00 setgray ef gr col0 s 176 | % Polyline 177 | gs clippath 178 | 2175 1062 m 2175 918 l 1843 918 l 2143 990 l 1843 1062 l cp 179 | eoclip 180 | n 1575 0 m 1575 990 l 181 | 2160 990 l gs col0 s gr gr 182 | 183 | % arrowhead 184 | n 1843 1062 m 2143 990 l 1843 918 l 1903 990 l 1843 1062 l 185 | cp gs 0.00 setgray ef gr col0 s 186 | % Polyline 187 | gs clippath 188 | 13065 72 m 13065 -72 l 12733 -72 l 13033 0 l 12733 72 l cp 189 | eoclip 190 | n 450 0 m 191 | 13050 0 l gs col0 s gr gr 192 | 193 | % arrowhead 194 | n 12733 72 m 13033 0 l 12733 -72 l 12793 0 l 12733 72 l 195 | cp gs 0.00 setgray ef gr col0 s 196 | % Polyline 197 | n 5625 675 m 7515 675 l 7515 1305 l 5625 1305 l 198 | cp gs col0 s gr 199 | $F2psEnd 200 | rs 201 | -------------------------------------------------------------------------------- /doc/eps/fpart.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\George\AppData\Local\Temp\jfig-tmp7148498884111542474.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 01:32:05 2009 5 | %%For: George@MOSQUITO (U-MOSQUITO\George,S-1-5-21-4166747469-2723723270-1828463590-1000) 6 | %%BoundingBox: 0 0 796 142 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 142 moveto 0 0 lineto 796 0 lineto 796 142 lineto closepath clip newpath 49 | -27.6 94.3 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /reencdict 12 dict def /ReEncode { reencdict begin 84 | /newcodesandnames exch def /newfontname exch def /basefontname exch def 85 | /basefontdict basefontname findfont def /newfont basefontdict maxlength dict def 86 | basefontdict { exch dup /FID ne { dup /Encoding eq 87 | { exch dup length array copy newfont 3 1 roll put } 88 | { exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall 89 | newfont /FontName newfontname put newcodesandnames aload pop 90 | 128 1 255 { newfont /Encoding get exch /.notdef put } for 91 | newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat 92 | newfontname newfont definefont pop end } def 93 | /isovec [ 94 | 8#055 /minus 8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde 95 | 8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis 96 | 8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron 97 | 8#220 /dotlessi 8#230 /oe 8#231 /OE 98 | 8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling 99 | 8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis 100 | 8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot 101 | 8#255 /hyphen 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus 102 | 8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph 103 | 8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine 104 | 8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf 105 | 8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute 106 | 8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring 107 | 8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute 108 | 8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute 109 | 8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve 110 | 8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply 111 | 8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex 112 | 8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave 113 | 8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring 114 | 8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute 115 | 8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute 116 | 8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve 117 | 8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide 118 | 8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex 119 | 8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def 120 | /Helvetica /Helvetica-iso isovec ReEncode 121 | /DrawEllipse { 122 | /endangle exch def 123 | /startangle exch def 124 | /yrad exch def 125 | /xrad exch def 126 | /y exch def 127 | /x exch def 128 | /savematrix mtrx currentmatrix def 129 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 130 | closepath 131 | savematrix setmatrix 132 | } def 133 | 134 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 135 | /$F2psEnd {$F2psEnteredState restore end} def 136 | 137 | $F2psBegin 138 | 10 setmiterlimit 139 | 0.06299 0.06299 sc 140 | % 141 | % Fig objects follow 142 | % 143 | /Helvetica-iso ff 270.00 scf sf 144 | 1350 -360 m 145 | gs 1 -1 sc (F-Part) col0 sh gr 146 | /Helvetica-iso ff 270.00 scf sf 147 | 2475 1260 m 148 | gs 1 -1 sc (\() col0 sh gr 149 | % Polyline 150 | 7.500 slw 151 | n 4005 900 m 5940 900 l 5940 1485 l 4005 1485 l 152 | cp gs col0 s gr 153 | /Helvetica-iso ff 270.00 scf sf 154 | 4275 1305 m 155 | gs 1 -1 sc (expression) col0 sh gr 156 | % Ellipse 157 | n 7425 1170 315 315 0 360 DrawEllipse gs col0 s gr 158 | 159 | % Polyline 160 | gs clippath 161 | 13065 72 m 13065 -72 l 12733 -72 l 13033 0 l 12733 72 l cp 162 | eoclip 163 | n 450 0 m 164 | 13050 0 l gs col0 s gr gr 165 | 166 | % arrowhead 167 | n 12733 72 m 13033 0 l 12733 -72 l 12793 0 l 12733 72 l 168 | cp gs 0.00 setgray ef gr col0 s 169 | % Polyline 170 | gs clippath 171 | 2220 1242 m 2220 1098 l 1888 1098 l 2188 1170 l 1888 1242 l cp 172 | eoclip 173 | n 1350 0 m 1350 1170 l 174 | 2205 1170 l gs col0 s gr gr 175 | 176 | % arrowhead 177 | n 1888 1242 m 2188 1170 l 1888 1098 l 1948 1170 l 1888 1242 l 178 | cp gs 0.00 setgray ef gr col0 s 179 | % Polyline 180 | gs clippath 181 | 4020 1242 m 4020 1098 l 3688 1098 l 3988 1170 l 3688 1242 l cp 182 | eoclip 183 | n 2835 1170 m 184 | 4005 1170 l gs col0 s gr gr 185 | 186 | % arrowhead 187 | n 3688 1242 m 3988 1170 l 3688 1098 l 3748 1170 l 3688 1242 l 188 | cp gs 0.00 setgray ef gr col0 s 189 | % Polyline 190 | gs clippath 191 | 7125 1242 m 7125 1098 l 6793 1098 l 7093 1170 l 6793 1242 l cp 192 | eoclip 193 | n 5940 1170 m 194 | 7110 1170 l gs col0 s gr gr 195 | 196 | % arrowhead 197 | n 6793 1242 m 7093 1170 l 6793 1098 l 6853 1170 l 6793 1242 l 198 | cp gs 0.00 setgray ef gr col0 s 199 | % Polyline 200 | gs clippath 201 | 9972 -15 m 9828 -15 l 9828 317 l 9900 17 l 9972 317 l cp 202 | eoclip 203 | n 7740 1170 m 9900 1170 l 204 | 9900 0 l gs col0 s gr gr 205 | 206 | % arrowhead 207 | n 9972 317 m 9900 17 l 9828 317 l 9900 257 l 9972 317 l 208 | cp gs 0.00 setgray ef gr col0 s 209 | /Helvetica-iso ff 270.00 scf sf 210 | 7380 1260 m 211 | gs 1 -1 sc (\)) col0 sh gr 212 | % Ellipse 213 | n 2520 1170 315 315 0 360 DrawEllipse gs col0 s gr 214 | 215 | $F2psEnd 216 | rs 217 | -------------------------------------------------------------------------------- /doc/eps/wvalue.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\George\AppData\Local\Temp\jfig-tmp7148498884111542474.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 01:10:23 2009 5 | %%For: George@MOSQUITO (U-MOSQUITO\George,S-1-5-21-4166747469-2723723270-1828463590-1000) 6 | %%BoundingBox: 0 0 796 252 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 252 moveto 0 0 lineto 796 0 lineto 796 252 lineto closepath clip newpath 49 | -27.6 213.0 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /reencdict 12 dict def /ReEncode { reencdict begin 84 | /newcodesandnames exch def /newfontname exch def /basefontname exch def 85 | /basefontdict basefontname findfont def /newfont basefontdict maxlength dict def 86 | basefontdict { exch dup /FID ne { dup /Encoding eq 87 | { exch dup length array copy newfont 3 1 roll put } 88 | { exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall 89 | newfont /FontName newfontname put newcodesandnames aload pop 90 | 128 1 255 { newfont /Encoding get exch /.notdef put } for 91 | newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat 92 | newfontname newfont definefont pop end } def 93 | /isovec [ 94 | 8#055 /minus 8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde 95 | 8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis 96 | 8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron 97 | 8#220 /dotlessi 8#230 /oe 8#231 /OE 98 | 8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling 99 | 8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis 100 | 8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot 101 | 8#255 /hyphen 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus 102 | 8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph 103 | 8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine 104 | 8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf 105 | 8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute 106 | 8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring 107 | 8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute 108 | 8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute 109 | 8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve 110 | 8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply 111 | 8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex 112 | 8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave 113 | 8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring 114 | 8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute 115 | 8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute 116 | 8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve 117 | 8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide 118 | 8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex 119 | 8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def 120 | /Helvetica /Helvetica-iso isovec ReEncode 121 | /DrawEllipse { 122 | /endangle exch def 123 | /startangle exch def 124 | /yrad exch def 125 | /xrad exch def 126 | /y exch def 127 | /x exch def 128 | /savematrix mtrx currentmatrix def 129 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 130 | closepath 131 | savematrix setmatrix 132 | } def 133 | 134 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 135 | /$F2psEnd {$F2psEnteredState restore end} def 136 | 137 | $F2psBegin 138 | 10 setmiterlimit 139 | 0.06299 0.06299 sc 140 | % 141 | % Fig objects follow 142 | % 143 | /Helvetica-iso ff 270.00 scf sf 144 | 900 -225 m 145 | gs 1 -1 sc (W-Value) col0 sh gr 146 | /Helvetica-iso ff 270.00 scf sf 147 | 6885 3105 m 148 | gs 1 -1 sc (,) col0 sh gr 149 | % Polyline 150 | 7.500 slw 151 | n 7875 495 m 9045 495 l 9045 1170 l 7875 1170 l 152 | cp gs col0 s gr 153 | /Helvetica-iso ff 270.00 scf sf 154 | 8100 945 m 155 | gs 1 -1 sc (f-part) col0 sh gr 156 | % Polyline 157 | n 2025 495 m 3915 495 l 3915 1170 l 2025 1170 l 158 | cp gs col0 s gr 159 | /Helvetica-iso ff 270.00 scf sf 160 | 2250 945 m 161 | gs 1 -1 sc (expression) col0 sh gr 162 | % Polyline 163 | gs clippath 164 | 3132 1155 m 2988 1155 l 2988 1487 l 3060 1187 l 3132 1487 l cp 165 | eoclip 166 | n 6615 3105 m 3060 3105 l 167 | 3060 1170 l gs col0 s gr gr 168 | 169 | % arrowhead 170 | n 3132 1487 m 3060 1187 l 2988 1487 l 3060 1427 l 3132 1487 l 171 | cp gs 0.00 setgray ef gr col0 s 172 | % Polyline 173 | gs clippath 174 | 2040 927 m 2040 783 l 1708 783 l 2008 855 l 1708 927 l cp 175 | eoclip 176 | n 1350 225 m 1350 855 l 177 | 2025 855 l gs col0 s gr gr 178 | 179 | % arrowhead 180 | n 1708 927 m 2008 855 l 1708 783 l 1768 855 l 1708 927 l 181 | cp gs 0.00 setgray ef gr col0 s 182 | % Polyline 183 | gs clippath 184 | 10872 210 m 10728 210 l 10728 542 l 10800 242 l 10872 542 l cp 185 | eoclip 186 | n 9045 855 m 10800 855 l 187 | 10800 225 l gs col0 s gr gr 188 | 189 | % arrowhead 190 | n 10872 542 m 10800 242 l 10728 542 l 10800 482 l 10872 542 l 191 | cp gs 0.00 setgray ef gr col0 s 192 | % Polyline 193 | gs clippath 194 | 13065 297 m 13065 153 l 12733 153 l 13033 225 l 12733 297 l cp 195 | eoclip 196 | n 450 225 m 197 | 13050 225 l gs col0 s gr gr 198 | 199 | % arrowhead 200 | n 12733 297 m 13033 225 l 12733 153 l 12793 225 l 12733 297 l 201 | cp gs 0.00 setgray ef gr col0 s 202 | % Polyline 203 | gs clippath 204 | 7185 3033 m 7185 3177 l 7517 3177 l 7217 3105 l 7517 3033 l cp 205 | eoclip 206 | n 10125 855 m 10125 3105 l 207 | 7200 3105 l gs col0 s gr gr 208 | 209 | % arrowhead 210 | n 7517 3033 m 7217 3105 l 7517 3177 l 7457 3105 l 7517 3033 l 211 | cp gs 0.00 setgray ef gr col0 s 212 | % Polyline 213 | gs clippath 214 | 7890 927 m 7890 783 l 7558 783 l 7858 855 l 7558 927 l cp 215 | eoclip 216 | n 3915 855 m 217 | 7875 855 l gs col0 s gr gr 218 | 219 | % arrowhead 220 | n 7558 927 m 7858 855 l 7558 783 l 7618 855 l 7558 927 l 221 | cp gs 0.00 setgray ef gr col0 s 222 | % Ellipse 223 | n 6907 3082 292 292 0 360 DrawEllipse gs col0 s gr 224 | 225 | $F2psEnd 226 | rs 227 | -------------------------------------------------------------------------------- /src/MIXAsm/Assembler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | 6 | using System.Runtime.Serialization; 7 | using System.Runtime.Serialization.Formatters.Binary; 8 | 9 | using MIXLib; 10 | using MIXLib.Util; 11 | using MIXLib.Parser; 12 | 13 | namespace MIXAsm 14 | { 15 | public enum Format 16 | { 17 | Card, 18 | Binary 19 | } 20 | 21 | public class MIXAssembler 22 | { 23 | public string InputFile { get; private set; } 24 | public string OutputFile { get; private set; } 25 | public Format OutputFormat { get; set; } 26 | public IPrettyPrinter PrettyPrinter { get; set; } 27 | private readonly Parser parser; 28 | 29 | public string ListingFile { get; set; } 30 | public bool MakeSymbolTable { get; set; } 31 | 32 | private string symbTabFile; 33 | public string SymbolTableFile 34 | { 35 | get => symbTabFile; 36 | set 37 | { 38 | if (!string.IsNullOrEmpty(value)) 39 | MakeSymbolTable = true; 40 | symbTabFile = value; 41 | } 42 | } 43 | 44 | public MIXAssembler(string inputFile, string outputFile, Format outputFormat) 45 | { 46 | InputFile = inputFile; 47 | OutputFormat = outputFormat; 48 | ListingFile = null; 49 | MakeSymbolTable = false; 50 | SymbolTableFile = null; 51 | OutputFile = outputFile; 52 | PrettyPrinter = new PlainTextPrinter(); 53 | 54 | TextReader reader = new StreamReader(InputFile); 55 | this.parser = new Parser(reader); 56 | } 57 | 58 | public MIXAssembler(string inputFile, string outputFile) : this(inputFile, outputFile, Format.Binary) { } 59 | 60 | public MIXAssembler(string inputFile, Format outputFormat) : this(inputFile, null, outputFormat) { } 61 | 62 | public MIXAssembler(string inputFile) : this(inputFile, null, Format.Binary) { } 63 | 64 | public int Assemble() 65 | { 66 | parser.ParseProgram(); 67 | 68 | if (Errors.Count() == 0) 69 | { 70 | if (OutputFormat == Format.Binary) 71 | AssembleBinary(); 72 | else 73 | AssembleCards(); 74 | 75 | return parser.Assembly.Count(); 76 | } 77 | else 78 | return 0; 79 | } 80 | 81 | public IEnumerable Errors { get { return parser.Errors; } } 82 | public IEnumerable Warnings { get { return parser.Warnings; } } 83 | 84 | private void AssembleCards() 85 | { 86 | StreamWriter writer; 87 | if (string.IsNullOrEmpty(OutputFile)) 88 | writer = new StreamWriter(Console.OpenStandardOutput(), System.Text.Encoding.UTF8); 89 | else 90 | writer = new StreamWriter(OutputFile, false, System.Text.Encoding.UTF8); 91 | 92 | // Write out the loading routine 93 | writer.WriteLine(" O O6 Z O6 I C O4 0 EH A F F CF 0 E EU 0 IH G BB EJ CA. Z EU EH E BA"); 94 | writer.WriteLine(" EU 2A-H S BB C U 1AEH 2AEN V E CLU ABG Z EH E BB J B. A 9 "); 95 | 96 | byte remainder = (byte)(parser.Assembly.Count() % 7); 97 | string comment = Path.GetFileNameWithoutExtension(InputFile).PadRight(5).Substring(0, 5).ToUpper(); 98 | 99 | string outp = ""; 100 | 101 | var interim = parser.Assembly.OrderBy(x => x.Location) 102 | .Select((x, i) => new { Index = i, Value = x }) 103 | .GroupBy(x => x.Index - x.Value.Location) 104 | .Select(x => x.Select((v, i) => new { Index = i, Value = v.Value }) 105 | .GroupBy(l => l.Index / 7) 106 | .Select(k => k.Select(v => v.Value)).ToList() 107 | .ToList()) 108 | .ToList(); 109 | 110 | List> chunks = new List>(); 111 | foreach (var i in interim) 112 | foreach (var i2 in i) 113 | chunks.Add(i2.ToList()); 114 | 115 | foreach (var chunk in chunks) 116 | { 117 | outp = comment + chunk.Count + string.Format("{0:0000}", chunk.First().Location); 118 | foreach (var cell in chunk) 119 | { 120 | int v = cell.Contents.Value; 121 | 122 | if (v < 0) 123 | { 124 | outp += Math.Abs(v).ToString().PadLeft(10, '0'); 125 | // Replace the last digit with the appropriate code 126 | byte c = MIXMachine.CHAR_TABLE[outp[outp.Length - 1]]; 127 | outp = outp.Substring(0, outp.Length - 1); 128 | outp += MIXMachine.CHAR_TABLE.Where(entry => entry.Value == c - 20).First().Key.ToString(); ; 129 | } 130 | else 131 | outp += v.ToString().PadLeft(10, '0'); 132 | } 133 | writer.WriteLine(outp.PadRight(80)); 134 | } 135 | 136 | // Transfer card 137 | writer.WriteLine(("TRANS0" + parser.StartLoc.Value.ToString().PadLeft(4, '0')).PadRight(80)); 138 | 139 | writer.Flush(); 140 | writer.Close(); 141 | } 142 | 143 | private void AssembleBinary() 144 | { 145 | IFormatter formatter = new BinaryFormatter(); 146 | Stream stream; 147 | if (string.IsNullOrEmpty(OutputFile)) 148 | stream = Console.OpenStandardOutput(); 149 | else 150 | stream = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None); 151 | 152 | formatter.Serialize(stream, parser.StartLoc); 153 | formatter.Serialize(stream, parser.Assembly); 154 | formatter.Serialize(stream, parser.SymbolTable); 155 | stream.Close(); 156 | } 157 | 158 | public void MakeOther() 159 | { 160 | if (this.MakeSymbolTable) 161 | { 162 | StreamWriter writer; 163 | if (this.SymbolTableFile == null) 164 | writer = new StreamWriter(Console.OpenStandardOutput()); 165 | else 166 | writer = new StreamWriter(this.SymbolTableFile, false, System.Text.Encoding.UTF8); 167 | 168 | writer.WriteLine(PrettyPrinter.Preamble); 169 | MakeSymbols(writer); 170 | writer.WriteLine(PrettyPrinter.PostDocText); 171 | 172 | writer.Flush(); 173 | writer.Close(); 174 | } 175 | 176 | if (!string.IsNullOrEmpty(this.ListingFile)) 177 | { 178 | StreamWriter writer = new StreamWriter(this.ListingFile, false, System.Text.Encoding.UTF8); 179 | 180 | writer.WriteLine(PrettyPrinter.Preamble); 181 | MakeListing(writer); 182 | writer.WriteLine(PrettyPrinter.PostDocText); 183 | 184 | writer.Flush(); 185 | writer.Close(); 186 | } 187 | } 188 | 189 | private void MakeListing(StreamWriter writer) 190 | { 191 | StreamReader reader = new StreamReader(InputFile); 192 | 193 | int line = 1; 194 | var al = parser.Assembly.ToList(); 195 | while (reader.Peek() != -1) 196 | { 197 | string strLine = reader.ReadLine(); 198 | MemoryCell cell = al.Find(c => c.SourceLocation == line); 199 | 200 | if (al.Exists(c => c.SourceLocation == line)) 201 | writer.WriteLine(PrettyPrinter.FormatInstruction(cell.Location, cell.Contents, line, strLine)); 202 | else 203 | writer.WriteLine(PrettyPrinter.FormatPseudo(line, strLine)); 204 | 205 | line++; 206 | } 207 | 208 | MakeSymbols(writer); 209 | } 210 | 211 | private void MakeSymbols(StreamWriter writer) 212 | { 213 | var mainSymbs = from s in parser.SymbolTable 214 | where !s.Key.StartsWith("=") && !s.Key.StartsWith("|") 215 | select s; 216 | var localSymbs = from s in parser.SymbolTable 217 | where s.Key.StartsWith("|") 218 | select s; 219 | var lits = from s in parser.SymbolTable 220 | where s.Key.StartsWith("=") 221 | select s; 222 | 223 | writer.Write(PrettyPrinter.EmptyLine); 224 | writer.WriteLine(PrettyPrinter.FormatHeading("MAIN SYMBOLS")); 225 | foreach (var s in mainSymbs) 226 | writer.WriteLine(PrettyPrinter.FormatSymbol(s.Key, s.Value)); 227 | 228 | writer.Write(PrettyPrinter.EmptyLine); 229 | writer.WriteLine(PrettyPrinter.FormatHeading("LOCAL SYMBOLS")); 230 | foreach (var s in localSymbs) 231 | writer.WriteLine(PrettyPrinter.FormatSymbol(s.Key, s.Value)); 232 | 233 | writer.Write(PrettyPrinter.EmptyLine); 234 | writer.WriteLine(PrettyPrinter.FormatHeading("LITERALS")); 235 | foreach (var s in lits) 236 | writer.WriteLine(PrettyPrinter.FormatSymbol(s.Key, s.Value)); 237 | } 238 | } 239 | } -------------------------------------------------------------------------------- /doc/eps/apart.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\GTryf\AppData\Local\Temp\jfig-tmp7739701969726532106.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 15:03:01 2009 5 | %%For: GTryf@PC155 () 6 | %%BoundingBox: 0 0 796 272 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 272 moveto 0 0 lineto 796 0 lineto 796 272 lineto closepath clip newpath 49 | -27.6 233.2 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /reencdict 12 dict def /ReEncode { reencdict begin 84 | /newcodesandnames exch def /newfontname exch def /basefontname exch def 85 | /basefontdict basefontname findfont def /newfont basefontdict maxlength dict def 86 | basefontdict { exch dup /FID ne { dup /Encoding eq 87 | { exch dup length array copy newfont 3 1 roll put } 88 | { exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall 89 | newfont /FontName newfontname put newcodesandnames aload pop 90 | 128 1 255 { newfont /Encoding get exch /.notdef put } for 91 | newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat 92 | newfontname newfont definefont pop end } def 93 | /isovec [ 94 | 8#055 /minus 8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde 95 | 8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis 96 | 8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron 97 | 8#220 /dotlessi 8#230 /oe 8#231 /OE 98 | 8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling 99 | 8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis 100 | 8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot 101 | 8#255 /hyphen 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus 102 | 8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph 103 | 8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine 104 | 8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf 105 | 8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute 106 | 8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring 107 | 8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute 108 | 8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute 109 | 8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve 110 | 8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply 111 | 8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex 112 | 8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave 113 | 8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring 114 | 8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute 115 | 8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute 116 | 8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve 117 | 8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide 118 | 8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex 119 | 8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def 120 | /Helvetica /Helvetica-iso isovec ReEncode 121 | /DrawEllipse { 122 | /endangle exch def 123 | /startangle exch def 124 | /yrad exch def 125 | /xrad exch def 126 | /y exch def 127 | /x exch def 128 | /savematrix mtrx currentmatrix def 129 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 130 | closepath 131 | savematrix setmatrix 132 | } def 133 | 134 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 135 | /$F2psEnd {$F2psEnteredState restore end} def 136 | 137 | $F2psBegin 138 | 10 setmiterlimit 139 | 0.06299 0.06299 sc 140 | % 141 | % Fig objects follow 142 | % 143 | /Helvetica-iso ff 270.00 scf sf 144 | 900 -225 m 145 | gs 1 -1 sc (A-Part) col0 sh gr 146 | /Helvetica-iso ff 270.00 scf sf 147 | 3240 3420 m 148 | gs 1 -1 sc (reference) col0 sh gr 149 | % Polyline 150 | 7.500 slw 151 | n 3150 2700 m 2970 2700 2970 3510 180 arcto 4 {pop} repeat 152 | 2970 3690 4590 3690 180 arcto 4 {pop} repeat 153 | 4770 3690 4770 2880 180 arcto 4 {pop} repeat 154 | 4770 2700 3150 2700 180 arcto 4 {pop} repeat 155 | cp gs col0 s gr 156 | % Polyline 157 | n 1440 810 m 3105 810 l 3105 1260 l 1440 1260 l 158 | cp gs col0 s gr 159 | /Helvetica-iso ff 270.00 scf sf 160 | 1575 1125 m 161 | gs 1 -1 sc (expression) col0 sh gr 162 | % Ellipse 163 | n 1732 1957 292 292 0 360 DrawEllipse gs col0 s gr 164 | 165 | /Helvetica-iso ff 270.00 scf sf 166 | 1665 2070 m 167 | gs 1 -1 sc (=) col0 sh gr 168 | % Polyline 169 | n 2925 1665 m 4410 1665 l 4410 2205 l 2925 2205 l 170 | cp gs col0 s gr 171 | /Helvetica-iso ff 270.00 scf sf 172 | 3150 2025 m 173 | gs 1 -1 sc (w-value) col0 sh gr 174 | % Ellipse 175 | n 5692 1957 292 292 0 360 DrawEllipse gs col0 s gr 176 | 177 | /Helvetica-iso ff 270.00 scf sf 178 | 5625 2070 m 179 | gs 1 -1 sc (=) col0 sh gr 180 | % Polyline 181 | gs clippath 182 | 7047 210 m 6903 210 l 6903 542 l 6975 242 l 7047 542 l cp 183 | eoclip 184 | n 4770 3195 m 6975 3195 l 185 | 6975 225 l gs col0 s gr gr 186 | 187 | % arrowhead 188 | n 7047 542 m 6975 242 l 6903 542 l 6975 482 l 7047 542 l 189 | cp gs 0.00 setgray ef gr col0 s 190 | % Polyline 191 | gs clippath 192 | 2985 3267 m 2985 3123 l 2653 3123 l 2953 3195 l 2653 3267 l cp 193 | eoclip 194 | n 900 225 m 900 3195 l 195 | 2970 3195 l gs col0 s gr gr 196 | 197 | % arrowhead 198 | n 2653 3267 m 2953 3195 l 2653 3123 l 2713 3195 l 2653 3267 l 199 | cp gs 0.00 setgray ef gr col0 s 200 | % Polyline 201 | gs clippath 202 | 13065 297 m 13065 153 l 12733 153 l 13033 225 l 12733 297 l cp 203 | eoclip 204 | n 450 225 m 205 | 13050 225 l gs col0 s gr gr 206 | 207 | % arrowhead 208 | n 12733 297 m 13033 225 l 12733 153 l 12793 225 l 12733 297 l 209 | cp gs 0.00 setgray ef gr col0 s 210 | % Polyline 211 | gs clippath 212 | 1455 1107 m 1455 963 l 1123 963 l 1423 1035 l 1123 1107 l cp 213 | eoclip 214 | n 900 225 m 900 1035 l 215 | 1440 1035 l gs col0 s gr gr 216 | 217 | % arrowhead 218 | n 1123 1107 m 1423 1035 l 1123 963 l 1183 1035 l 1123 1107 l 219 | cp gs 0.00 setgray ef gr col0 s 220 | % Polyline 221 | gs clippath 222 | 1455 2007 m 1455 1863 l 1123 1863 l 1423 1935 l 1123 2007 l cp 223 | eoclip 224 | n 900 225 m 900 1935 l 225 | 1440 1935 l gs col0 s gr gr 226 | 227 | % arrowhead 228 | n 1123 2007 m 1423 1935 l 1123 1863 l 1183 1935 l 1123 2007 l 229 | cp gs 0.00 setgray ef gr col0 s 230 | % Polyline 231 | gs clippath 232 | 2940 2007 m 2940 1863 l 2608 1863 l 2908 1935 l 2608 2007 l cp 233 | eoclip 234 | n 2025 1935 m 235 | 2925 1935 l gs col0 s gr gr 236 | 237 | % arrowhead 238 | n 2608 2007 m 2908 1935 l 2608 1863 l 2668 1935 l 2608 2007 l 239 | cp gs 0.00 setgray ef gr col0 s 240 | % Polyline 241 | gs clippath 242 | 5415 2007 m 5415 1863 l 5083 1863 l 5383 1935 l 5083 2007 l cp 243 | eoclip 244 | n 4410 1935 m 245 | 5400 1935 l gs col0 s gr gr 246 | 247 | % arrowhead 248 | n 5083 2007 m 5383 1935 l 5083 1863 l 5143 1935 l 5083 2007 l 249 | cp gs 0.00 setgray ef gr col0 s 250 | % Polyline 251 | gs clippath 252 | 7047 210 m 6903 210 l 6903 542 l 6975 242 l 7047 542 l cp 253 | eoclip 254 | n 5985 1935 m 6975 1935 l 255 | 6975 225 l gs col0 s gr gr 256 | 257 | % arrowhead 258 | n 7047 542 m 6975 242 l 6903 542 l 6975 482 l 7047 542 l 259 | cp gs 0.00 setgray ef gr col0 s 260 | % Polyline 261 | gs clippath 262 | 7047 210 m 6903 210 l 6903 542 l 6975 242 l 7047 542 l cp 263 | eoclip 264 | n 3105 1035 m 6975 1035 l 265 | 6975 225 l gs col0 s gr gr 266 | 267 | % arrowhead 268 | n 7047 542 m 6975 242 l 6903 542 l 6975 482 l 7047 542 l 269 | cp gs 0.00 setgray ef gr col0 s 270 | /Helvetica-iso ff 270.00 scf sf 271 | 3510 3150 m 272 | gs 1 -1 sc (future) col0 sh gr 273 | $F2psEnd 274 | rs 275 | -------------------------------------------------------------------------------- /src/MIXAsm/PrettyPrinter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using MIXLib; 4 | 5 | namespace MIXAsm 6 | { 7 | public interface IPrettyPrinter 8 | { 9 | string Preamble { get; } 10 | string PostDocText { get; } 11 | string EmptyLine { get; } 12 | 13 | string FormatHeading(string headingText); 14 | string FormatInstruction(int location, MIXWord instruction, int lineNo, string line); 15 | string FormatPseudo(int lineNo, string line); 16 | string FormatSymbol(string name, MIXWord value); 17 | } 18 | 19 | public class PlainTextPrinter 20 | : IPrettyPrinter 21 | { 22 | public string Preamble { get { return string.Empty; } } 23 | public string PostDocText { get { return string.Empty; } } 24 | public string EmptyLine { get { return Environment.NewLine; } } 25 | 26 | public string FormatHeading(string headingText) 27 | => "============== " + headingText + " =============="; 28 | 29 | public string FormatInstruction(int location, MIXWord instruction, int lineNo, string line) 30 | { 31 | string strLine = lineNo.ToString().PadLeft(4) + " " + line; 32 | string firstPart = string.Format("{0:0000}: {1} ", location, instruction.ToInstructionString()); 33 | 34 | strLine = firstPart += strLine; 35 | 36 | return strLine; 37 | } 38 | 39 | public string FormatPseudo(int lineNo, string line) 40 | => new string(' ', 25) + lineNo.ToString().PadLeft(4) + " " + line; 41 | 42 | public string FormatSymbol(string name, MIXWord value) 43 | => name + "\t" + value + " = " + value.Value; 44 | } 45 | 46 | public class TeXPrinter 47 | : IPrettyPrinter 48 | { 49 | private string SourceFile { get; set; } 50 | public TeXPrinter(string sourceFile) 51 | { 52 | SourceFile = sourceFile; 53 | } 54 | 55 | public string Preamble 56 | { 57 | get 58 | { 59 | #region TeX Preamble 60 | return @"\newif\ifusehrule 61 | \newcount\utilmix 62 | 63 | \newskip\ttglue 64 | \def\tenpoint{\def\rm{\fam0\tenrm}% 65 | \textfont0=\tenrm \scriptfont0=\sevenrm \scriptscriptfont0=\fiverm 66 | \textfont1=\teni \scriptfont1=\seveni \scriptscriptfont1=\fivei 67 | \textfont2=\tensy \scriptfont2=\sevensy \scriptscriptfont2=\fivesy 68 | \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex 69 | \def\it{\fam\itfam\tenit}% 70 | \textfont\itfam=\tenit 71 | \def\sl{\fam\slfam\tensl}% 72 | \textfont\slfam=\tensl 73 | \def\bf{\fam\bffam\tenbf}% 74 | \textfont\bffam=\tenbf \scriptfont\bffam=\sevenbf 75 | \scriptscriptfont\bffam=\fivebf 76 | \def\tt{\fam\ttfam\tentt}% 77 | \textfont\ttfam=\tentt 78 | \tt \ttglue=.5em plus.25em minus.15em 79 | \normalbaselineskip=12pt 80 | \def\MF{{\manual META}\-{\manual FONT}}% 81 | \let\sc=\eightrm 82 | \let\big=\tenbig 83 | \setbox\strutbox=\hbox{\vrule height8.5pt depth3.5pt width\z@}% 84 | \normalbaselines\rm} 85 | 86 | \def\ninepoint{\def\rm{\fam0\ninerm}% 87 | \textfont0=\ninerm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm 88 | \textfont1=\ninei \scriptfont1=\sixi \scriptscriptfont1=\fivei 89 | \textfont2=\ninesy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy 90 | \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex 91 | \def\it{\fam\itfam\nineit}% 92 | \textfont\itfam=\nineit 93 | \def\sl{\fam\slfam\ninesl}% 94 | \textfont\slfam=\ninesl 95 | \def\bf{\fam\bffam\ninebf}% 96 | \textfont\bffam=\ninebf \scriptfont\bffam=\sixbf 97 | \scriptscriptfont\bffam=\fivebf 98 | \def\tt{\fam\ttfam\ninett}% 99 | \textfont\ttfam=\ninett 100 | \tt \ttglue=.5em plus.25em minus.15em 101 | \normalbaselineskip=11pt 102 | \def\MF{{\manual hijk}\-{\manual lmnj}}% 103 | \let\sc=\sevenrm 104 | \let\big=\ninebig 105 | \setbox\strutbox=\hbox{\vrule height8pt depth3pt width\z@}% 106 | \normalbaselines\rm} 107 | 108 | \def\eightpoint{\def\rm{\fam0\eightrm}% 109 | \textfont0=\eightrm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm 110 | \textfont1=\eighti \scriptfont1=\sixi \scriptscriptfont1=\fivei 111 | \textfont2=\eightsy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy 112 | \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex 113 | \def\it{\fam\itfam\eightit}% 114 | \textfont\itfam=\eightit 115 | \def\sl{\fam\slfam\eightsl}% 116 | \textfont\slfam=\eightsl 117 | \def\bf{\fam\bffam\eightbf}% 118 | \textfont\bffam=\eightbf \scriptfont\bffam=\sixbf 119 | \scriptscriptfont\bffam=\fivebf 120 | \def\tt{\fam\ttfam\eighttt}% 121 | \textfont\ttfam=\eighttt 122 | \tt \ttglue=.5em plus.25em minus.15em 123 | \normalbaselineskip=9pt 124 | \def\MF{{\manual opqr}\-{\manual stuq}}% 125 | \let\sc=\sixrm 126 | \let\big=\eightbig 127 | \setbox\strutbox=\hbox{\vrule height7pt depth2pt width\z@}% 128 | \normalbaselines\rm} 129 | 130 | \def\tenmath{\tenpoint\fam-1 } % use after $ in ninepoint sections 131 | \def\tenbig#1{{\hbox{$\left#1\vbox to8.5pt{}\right.\n@space$}}} 132 | \def\ninebig#1{{\hbox{$\textfont0=\tenrm\textfont2=\tensy 133 | \left#1\vbox to7.25pt{}\right.\n@space$}}} 134 | \def\eightbig#1{{\hbox{$\textfont0=\ninerm\textfont2=\ninesy 135 | \left#1\vbox to6.5pt{}\right.\n@space$}}} 136 | 137 | \chardef\other=12 138 | \def\ttverbatim{\begingroup 139 | \catcode`\\=\other 140 | \catcode`\{=\other 141 | \catcode`\}=\other 142 | \catcode`\$=\other 143 | \catcode`\&=\other 144 | \catcode`\#=\other 145 | \catcode`\%=\other 146 | \catcode`\~=\other 147 | \catcode`\_=\other 148 | \catcode`\^=\other 149 | \obeyspaces \obeylines \tt} 150 | 151 | \catcode`\|=\active 152 | {\obeylines \gdef|{\ttverbatim \spaceskip\ttglue \let^^M=\ \let|=\endgroup}} 153 | 154 | \def\|{\leavevmode\hbox{\tt\char`\|}} 155 | 156 | \def\beginlisting{ 157 | \bgroup\offinterlineskip\halign\bgroup\offinterlineskip 158 | \vbox{\offinterlineskip\hbox{\vrule height2pt width0pt}\hbox{\strut\tt##:\hfil}\hbox{\vrule height2pt width0pt}}\quad&% memory location 159 | ##&% instruction word 160 | \quad\hfil\vbox{\offinterlineskip\hbox{\vrule height2pt width0pt}\hbox{\strut\sevenrm##}\hbox{\vrule height2pt width0pt}}&% line number 161 | \ \vbox{\offinterlineskip\hbox{\vrule height2pt width0pt}\hbox to 20pc{\strut##\hfil}\hbox{\vrule height2pt width0pt}}\cr% source code 162 | } 163 | 164 | \def\endlisting{\egroup\egroup} 165 | 166 | \def\mixword#1.#2.#3.#4.#5.#6.{% 167 | \vbox{\offinterlineskip% 168 | \ifnum\count0>\utilmix 169 | \global\utilmix=\count0\hrule 170 | \else 171 | \ifusehrule\hrule\fi 172 | \fi% 173 | \global\usehrulefalse% 174 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 175 | \hbox{% 176 | \vrule% 177 | \hbox to 15pt{\strut\hfil#1\hfil}% 178 | \vrule% 179 | \hbox to 15pt{\hfil\tt#2\hfil}% 180 | \vrule% 181 | \hbox to 15pt{\hfil\tt#3\hfil}% 182 | \vrule% 183 | \hbox to 15pt{\hfil\tt#4\hfil}% 184 | \vrule% 185 | \hbox to 15pt{\hfil\tt#5\hfil}% 186 | \vrule% 187 | \hbox to 15pt{\hfil\tt#6\hfil}% 188 | \vrule% 189 | }% 190 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 191 | \hrule% 192 | }% 193 | } 194 | 195 | \def\mixinst#1.#2.#3.#4.#5.{% 196 | \offinterlineskip\vbox{\offinterlineskip% 197 | \ifnum\count0>\utilmix 198 | \global\utilmix=\count0\hrule 199 | \else 200 | \ifusehrule\hrule\fi 201 | \fi% 202 | \global\usehrulefalse% 203 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 204 | \hbox{% 205 | \vrule% 206 | \hbox to 15pt{\strut\hfil#1\hfil}% 207 | \vrule% 208 | \hbox to 30.4pt{\hfil\tt#2\thinspace}% 209 | \vrule% 210 | \hbox to 15pt{\hfil\tt#3\hfil}% 211 | \vrule% 212 | \hbox to 15pt{\hfil\tt#4\hfil}% 213 | \vrule% 214 | \hbox to 15pt{\hfil\tt#5\hfil}% 215 | \vrule% 216 | }% 217 | \hbox{\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt\hskip15pt\vrule height2pt}% 218 | \hrule% 219 | }% 220 | } 221 | 222 | \font\fnamefont=cmssdc10 at 40pt 223 | \font\titlefont=cmssdc10 at 30pt 224 | 225 | \centerline{\fnamefont " + SourceFile.ToUpper() + @"} 226 | \vskip1em 227 | \centerline{\titlefont Program Listing} 228 | \vfill\eject 229 | 230 | \beginlisting"; 231 | #endregion 232 | } 233 | } 234 | public string PostDocText { get { return @"\endlisting\bye"; } } 235 | public string EmptyLine { get { return @"\omit&\omit&\omit&\omit\strut\cr" + Environment.NewLine; } } 236 | 237 | public string FormatHeading(string headingText) 238 | { 239 | return "\\multispan4\\global\\usehruletrue\\leaders\\hrule\\hfil{\\it " 240 | + headingText 241 | + "}\\leaders\\hrule\\hfil\\cr\n\\omit&\\omit&\\omit&\\omit\\strut\\cr"; 242 | } 243 | 244 | public string FormatInstruction(int location, MIXWord instruction, int lineNo, string line) 245 | { 246 | string strLine = string.Format("{0:0000}&\\mixinst${1}$.{2}.{3}.{4}.{5}.&{6}&|{7}|\\cr", 247 | location, instruction[0] == 1 ? "-" : "+", instruction[1, 2], instruction[3], instruction[4], instruction[5], 248 | lineNo, line); 249 | 250 | return strLine; 251 | } 252 | 253 | public string FormatPseudo(int lineNo, string line) 254 | => $"\\omit\\global\\usehruletrue&\\omit&{lineNo}&|{line}|\\cr"; 255 | 256 | public string FormatSymbol(string name, MIXWord value) 257 | => string.Format("{0}&\\mixword${1}$.{2}.{3}.{4}.{5}.{6}.&=&{7}\\cr", name.Replace("|", @"\|"), 258 | value[0] == 1 ? "-" : "+", value[1], value[2], value[3], value[4], value[5], value.Value); 259 | } 260 | } -------------------------------------------------------------------------------- /doc/chapter2.tex: -------------------------------------------------------------------------------- 1 | \beginchapter Chapter 2. MIXASM---\\The MIX Assembler 2 | 3 | The assembler implements all the features of the \MIXAL\ language as 4 | detailed in~{\sl TAOCP, sec.~1.3.2}. See that book section for 5 | the definitive description of the language. The assembler 6 | follows the book faithfully, including the format of the 7 | |ALF| pseudo-operation. Appendix~A has a detailed treatment of 8 | the exact semantics of this particular assembler implementation. 9 | 10 | \subsection RUNNING THE ASSEMBLER. 11 | The assembler is invoked using the following syntax: 12 | \begintt 13 | MIXASM [arguments] [input-filename] 14 | \endtt 15 | where each \ is of the form: 16 | \begindisplay 17 | |--long-arg:value|&or&|-short-arg:value|\cr 18 | \enddisplay 19 | where for each |--long-arg| there exist one or more |-short-arg|s 20 | that perform the equivalent function but are, well, shorter. The 21 | arguments' |value| part is, depending on the argument, either 22 | required, optional, or not applicable. 23 | Here's a list of the possible arguments and a description of 24 | what they do. The applicability of the |value| part is also 25 | discussed here. 26 | \def\drule{\noalign{\smallskip}} 27 | $$ 28 | \tabskip 1em plus .5em minus .5em 29 | \halign to \hsize{#\hfil&#\hfil&\hfil#\cr 30 | {\sl Long Form}&{\sl Short Form}&{\sl Description}\cr 31 | \noalign{\vskip3pt\hrule\smallskip} 32 | |--output:filename|&|-o:filename|&redirects output to |filename|.\cr 33 | \drule 34 | |--symtab[:filename]|&|-s[:filename]|&produces the symbol table. If |filename|\cr 35 | &&is specified, the symbol table is written to that\cr 36 | &&file, otherwise it is sent to standard output.\cr 37 | \drule 38 | |--list-file:filename|&|-lf:filename|&produces a listing and writes it\cr 39 | &&to |filename| (see below).\cr 40 | \drule 41 | |--format:...|&|-f:...|&defines the output format. Can be either\cr 42 | &&|Card| or |Binary| (default is |Binary|, see below).\cr 43 | \drule 44 | |--append-deck:filename|&|-a:filename|&When the output format is |Card|, the\cr 45 | &&|filename| specified gets appended to\cr 46 | &&the output card deck.\cr 47 | \drule 48 | |--pretty-print|&|-pp|&pretty prints the symbol table and\slash or\cr 49 | &&the list file (if requested) for use with \TeX.\cr 50 | \drule 51 | |--version|&|-v|&display version information and exit.\cr 52 | \drule 53 | |--help|&|-h|\cr 54 | &|-?|&display a short help message and exit.\cr 55 | } 56 | $$ 57 | If |input-filename| is not specified then input is done from the standard input. 58 | If the |--output| parameter is omitted then the compiler emits output to the 59 | standard output. The arguments are {\sl not\/} case-sensitive. 60 | Here's a bunch of examples: 61 | $$ 62 | \tabskip 1em plus .5em minus .5em 63 | \halign to \hsize{#\hfil&\hfil#\cr 64 | {\sl Command*}&{\sl Comments}\cr 65 | \noalign{\vskip 3pt\hrule\medskip} 66 | |MIXASM -f:card primes.mixal|&compiles the file |primes.mixal| to\cr 67 | &a card deck and sends the output to the display\cr 68 | \drule 69 | |MIXASM -f:card primes.mixal|\cr 70 | | -lf:primes.tex -pp|&as above, but also pretty-prints the program listing\cr 71 | &for use with \TeX, and saves it to the file |primes.tex|.\cr 72 | \drule 73 | |MIXASM --output:primes.dump|\cr 74 | | < primes.mixal|&compiles the file |primes.mixal| and\cr 75 | &writes the (binary) output to file |primes.dump|\cr 76 | \drule 77 | |MIXASM -f:card primes.mixal|\cr 78 | | |\|| MIX --deck|&compiles the file |primes.mixal| as a card deck\cr 79 | &and starts non-interactive simulation\cr 80 | \noalign{\smallskip\hrule\smallskip} 81 | \multispan2\eightrm*These commands are, of course, all one-liners.\hfil\cr 82 | } 83 | $$ 84 | The last couple of examples are worth particular mention. They bring to 85 | the light the joy of pipelining, which so many UNIX users have come to 86 | worship. Here's why the third example works: |MIXASM|, unless told otherwise, 87 | expects that the file to be assembled comes from the standard input. But 88 | here we redirect the standard input to the file |primes.mixal|. In the 89 | fourth example, we redirect |MIXASM|'s output to the input of |MIX|, 90 | the simulator. Remember that the |--deck| argument informs the simulator 91 | to interpret the input as a card deck. 92 | 93 | The following sections provide a description of the rest of |MIXASM|'s 94 | features (well, except for the dead obvious ones). 95 | 96 | \subsection OUTPUT FORMATS. 97 | |MIXASM| can produce two kinds of output, namely a binary memory dump 98 | or a card deck. Memory dumps are not human-readable and are meant only to be 99 | loaded and executed by |MIXSIM|, the simulator ({\sl cf.}~Chapter~1 100 | and~Appendix~A for techincal details). Card 101 | deck output, however, is in ASCII format and can be read by humans 102 | too---well, at least those that make sense of it. 103 | 104 | A card deck is a text file containing 80-column lines. Each line 105 | represents a punched card and is read by \MIX's card reader. Each 106 | \MIX\ program that has been compiled to a card deck adheres 107 | to the specification given in~{\it TAOCP, sec.~\hbox{1.3.1}, ex.~$26$}: 108 | The first two cards contain a loading routine which serves to load 109 | the rest of the program into the correct locations in memory and 110 | start execution. Note that programs that are compiled to cards 111 | must start at a memory location greater than~$100$, a restriction 112 | that does not apply when a program has been compiled to binary. 113 | This is due to the fact that these locations are occupied by the 114 | loading routine itself. 115 | 116 | When a \MIXAL\ program is compiled to a card deck, one may specify 117 | the |--append-deck| argument, which in effect appends extra cards to 118 | the output deck. For example, typing 119 | \begintt 120 | MIXASM perms.mixal -o:perms.deck -f:binary -a:perms-input.deck 121 | \endtt 122 | will produce the card deck |primes.deck| which will contain the 123 | compiled program plus the cards found in the |primes-input.deck| 124 | card deck (all these files can be found in the {\it Examples} 125 | directory of the MIXWare distribution). This latter deck contains 126 | sample input data for the permutations program. 127 | 128 | There is actually a (good) reason behind this. If you use the 129 | simulator's |loaddeck| command to load the compiled program, 130 | the loader routine, program and all, will execute immediately, 131 | giving you no chance to set up the card reader with any input 132 | data (if there is any, of course). Therefore, the |--append-deck| 133 | argument gives you a chance to set things up beforehand. 134 | 135 | \subsection SYMBOL TABLES. 136 | The argument |--symtab| instructs |MIXASM| to produce a symbol table. 137 | If the |filename| parameter is given to the argument, then the symbol 138 | table is written to that file, otherwise it is sent to the standard 139 | output. 140 | The symbols in \MIX's assembly language are divided into three 141 | categories and so is the symbol table: (1)~the main symbols, which 142 | are |EQU| constants and instruction labels; (2)~the local symbols, 143 | i.e., labels like~|1H| and |9H| in the assembly source, and; 144 | (3)~literals, i.e., the address parts of instructions with the 145 | format |=23//1=|. 146 | 147 | Each segment of the symbol table is divided into three columns. 148 | The first column is the symbol name. The second one is the symbol's 149 | value as it gets stored in a \MIX\ word. The third column is the 150 | symbol's decimal value. Main symbols are copied verbatim as 151 | described. Local symbols and literals, however, receive special 152 | treatment. 153 | 154 | Local symbols get renamed according to the following rule: when 155 | a label of the form $n$|H| is encountered, where $n$ is a digit, 156 | then that label is renamed to 157 | \|\kern-0.2112em$n$|-|$x_n$\kern-0.2112em\|, where $x_n$ is 158 | initially equal to~$1$. If the assembler encounters the label 159 | $n$|H| again, then it increases~$x_n$ by~$1$ and repeats the 160 | renaming process. For example: when the assembler first encounters 161 | a label |2H|, it sets $x_2$ equal to~$1$ and renames the label 162 | to \||2-1|\|. If the assembler encounters the label again further 163 | down the source code, it sets $x_2$ to~$2$ and renames the label 164 | to \||2-2|\|. 165 | 166 | Literals do not appear as symbols in the \MIXAL\ source. They appear as 167 | the address part of \MIXAL\ instructions, for example in the 168 | instruction~|LD2 =3=|, the address~|=3=| is a literal constant. This 169 | has the effect of creating a constant with the value $3$ and creating 170 | an internal symbol whose value is equal to the address that constant 171 | is stored. |MIXASM| names that symbol as the literal---in the given 172 | example that symbol will be called~|=3=|. Note that this implies that 173 | only one constant is created, regardless of how many times the 174 | literal~|=3=| appears in the source code. There is, however, one 175 | exception to this rule, and that is when the literal contains the 176 | location counter, {\sl e.g.} |=*+3=|. See Appendix~A for more details. 177 | 178 | \subsection LIST FILES. 179 | |MIXASM| can produce list files similar to the program listings 180 | in~{\sl The Art of Computer Programming}: for each line of source, 181 | the listing contains the location in memory where that line is assembled, 182 | the assembled word, the line number and the line itself. 183 | If the instruction 184 | is a \MIXAL\ pseudo-instruction, the first two parts are omitted. 185 | The program listing is followed by the symbol table as described 186 | in the previous section. A typical \MIX\ instruction is stored in 187 | a \MIX\ word as follows: 188 | $$ 189 | \global\usehruletrue\mixinst$\pm$.AA.I.F.C. 190 | $$ where |AA| is the address, ranging from $0$ to~$3999$, |I| is 191 | the index, |F| is the field and |C| is the instruction's opcode. For 192 | more information on how these fields are used see~{\it TAOCP, sec.~\hbox{1.3.1}}. 193 | 194 | The list file that |MIXASM| produces is stored in a text file that's 195 | specified as an argument to the |--list-file| parameter. If the 196 | |--pretty-print| option is given to the assembler, the list file is 197 | written in \TeX{} format instead. You may refer to Appendix~A for a full 198 | listing of a short example program, to examine what such listings look like when 199 | they are typeset by \TeX. 200 | \endchapter 201 | 202 | When someone says: `I want a programming language in which 203 | I need only say what I wish done', give him a lollipop. 204 | \author{ALAN PERLIS}, {\sl Software Metrics} (1981) 205 | 206 | \bigskip 207 | 208 | Trying to outsmart a compiler defeats much of the purpose of using one. 209 | \author{KERNIGHAN \& PLAUGER}, {\sl The Elements of Programming Style} (1978) 210 | 211 | \bigskip 212 | 213 | If you can't do it in Fortran, do it in assembly language. 214 | If you can't do it in assembly language, it isn't worth doing. 215 | \author{ED POST}, {\sl Real Programmers Don't Use Pascal} (1983) 216 | \eject -------------------------------------------------------------------------------- /doc/chapter3.tex: -------------------------------------------------------------------------------- 1 | \beginchapter Chapter 3. Simulator Implementation 2 | 3 | We shall inspect, in this and the next chapter, the various details behind the 4 | two principal programs, |MIXASM| and |MIX|. These chapters are concerned a bit 5 | more with the hairy implementation details and a good working knowledge of 6 | object oriented programming is assumed. The actual implementation language is 7 | C\#, but we shall avoid getting into actual programming details. However, will 8 | will talk about classes, structures, methods and inheritance, and the reader is 9 | assumed to know what each of these constructs means. 10 | 11 | We start our discussion with the simulator, which is probably the simplest 12 | of the two programs, therefore easier to grasp. 13 | \medskip 14 | The simulator closely follows the specification given in {\it TAOCP sec. 1.3.1.} 15 | Everything described in that section has been implemented in its entirety. 16 | Perhaps the most challenging task of the implementation process is the fact 17 | that \MIX\ is an archaic design. Many of its components do not exist today. 18 | Certainly there are no card readers, card punches or tape drives. Printers 19 | have stopped being line-oriented. Byte size has been standardized and it 20 | certainly isn't six bits. Computers generally make no distinction between 21 | $+0$ and $-0$. 22 | 23 | Object oriented design helps hide such minor setbacks. We recognize the 24 | abstractions behind the computer specification and create classes to encapsulate 25 | them. For example, we know that a word represents a number, of any radix, 26 | whose minimum and maximum limits are known, and on which we may perform simple 27 | arithmetic. We are not concerned with how many bits represent one word. This is a 28 | minor implementation detail which is kept hidden within the encapsulating class. 29 | 30 | The same goes with the other important parts of the \MIX\ design. 31 | Breaking a \MIX\ computer to its abstract components, we are left with the 32 | following important classes: 33 | $$ 34 | \vbox{\tabskip 3em plus1em minus.5em 35 | \halign to \hsize{&#\hfil\cr 36 | \omit\hfil\MIX\ Abstraction\hfil&\omit\hfil Encapsulating\hfil&\omit\hfil Remarks\hfil\cr 37 | &\omit\hfil Class\hfil\cr 38 | \noalign{\smallskip\hrule\medskip} 39 | Word&|MIXWord|&A word of memory: five bytes and a sign\cr 40 | Instruction&|MIXInstruction|&An abstract \MIX\ instruction, like |LDA|.\cr 41 | &&Consists of an |Execute()| method,\cr 42 | &&which when overridden performs the\cr 43 | &&actual instruction.\cr 44 | Device&|MIXDevice|&An abstract \MIX\ device.\cr 45 | &&Descendants are the concrete \MIX\ devices,\cr 46 | &&such as disk drives, the line printer, {\it etc.}\cr 47 | \MIX&|MIXMachine|&The actual \MIX\ computer.\cr 48 | &&Contains properties such as |Memory|, a set\cr 49 | &&of register properties, the device array {\it etc.}\cr 50 | }} 51 | $$ 52 | \smallskip\centerline{\ninerm{\ninebf Table 3.1} \MIX\ Description}\smallskip 53 | Figure~3.1 shows the overall structure of the \MIX\ simulator design without many 54 | details. The diagram drives home the fact that the |MIXMachine| class is the one 55 | class that brings together the various parts that make up \MIX. 56 | 57 | \epsfxsize=.9\hsize 58 | \centerline{\epsfbox{eps/machine.eps}} 59 | \smallskip\centerline{\ninerm{\ninebf Figure 3.1} \MIX\ Simulator class diagram} 60 | \smallskip\noindent 61 | We now shall discuss the various parts of the \MIX\ architecture as evidenced 62 | in the class diagram in a bit more detail. 63 | \subsection WORDS. 64 | \MIX\ words are used throughout the specification of the \MIX\ machine: 65 | \MIX's memory is an array of \MIX\ words; the \MIX\ registers hold values that 66 | fit into \MIX\ words (in fact, the index registers, rI1--rI6, as well as rJ, 67 | are shorter, but regarding them as such is a good simplification); each \MIX\ 68 | instruction is encoded as a word; device I/O is done by sending and receiving 69 | words to and from the devices. It is a ubiquitous abstraction. 70 | 71 | It follows that such an ever-present abstraction will make very frequent 72 | appearances in any kind of implementation. To this end, we go at great length 73 | to define the |MIXWord| class in such a way that it may be used as naturally as 74 | the standard integral types of the implementation language. The |MIXWord| class 75 | can be constructed from the language's existing integral values (|int| or |byte|) 76 | and can be cast back to them. In the case of |int|, an explicit cast is needed 77 | because the range of a 32-bit integer is greater than that of the 30-bit \MIX\ 78 | word. In addition, we overload the standard C\# arithmetic and relational operators 79 | in such a way that we may write 80 | \begintt 81 | if (w1 > w2) 82 | w1 += 100; 83 | \endtt 84 | Note that because 85 | of our type-coercion operators we are allowed to add a |byte| (such as 100) 86 | to a |MIXWord|. 87 | 88 | An important characteristic of a \MIX\ word is that we can examine the value of, 89 | and assign to, byte slices of it. For example, we can assign the value `1000' 90 | to bytes 2--3 of a word, leaving the rest of the word the same. Or, we can 91 | read the value of bytes 2--4, ignoring the other bytes. These byte slices 92 | are called {\it fields}. 93 | 94 | Because fields are contiguous, it is simple to encapsulate them in the |MIXWord| 95 | class by overloading the |this[]| property. We provide two overloads:\smallskip 96 | \item{1.}|public byte this[byte b]| assigns to or reads the value of a single 97 | byte of the |MIXWord|; and 98 | \item{2.}|public int this[byte l, byte r]| assigns to or reads the value of 99 | a field of the |MIXWord|, defined by the range $l$--$r$, where $l$ is the most 100 | significant byte of the field and $r$ is the least significant byte. 101 | \smallskip\noindent 102 | therefore providing the means to write code such as: 103 | \begintt 104 | MIXWord w = new MIXWord(5000); 105 | w[2,3] = 1000; 106 | int a = w[1,4]; 107 | \endtt 108 | In this way we make the implementation of the \MIX\ instruction set significantly 109 | easier, because the effective address of most instructions takes a field 110 | specification into account. 111 | 112 | Finally, we override the |ToString()| method to return a convenient textual 113 | representation of the word, useful in program listings and in memory dumps. 114 | 115 | \subsection INSTRUCTIONS. 116 | A \MIX\ instruction is encoded in a word according to the conventions specified 117 | in {\it TAOCP sec.~1.3.1}. The \MIX\ central processing unit decodes the word 118 | and, according to the C- and F-fields of the instruction word (see also the 119 | section on list files in the previous chapter), performs a specified 120 | operation using |CONTENTS(M)|, the latter defined as 121 | $$ {\rm CONTENTS}(M)\equiv A(F)+{\rm rI}(I) $$ 122 | where $A$, $F$ and $I$ are the A-, F- and I- fields of the instruction word 123 | respectively. 124 | 125 | To encapsulate this abstraction in the |MIXInstruction| class there are two 126 | distinct paths we may follow. We can either: (1)~create an abstract superclass 127 | and inherit it 157 times, once for each instruction; or (2)~create a concrete 128 | class and instantiate it with a different method delegate 157 times, again once 129 | for each instruction. The first method encapsulates the abstraction at the class 130 | level while the second one at the instance level. 131 | 132 | There are no significant advantages of one method over the other, apart from 133 | the fact that the first one leads to an explosion of subclasses, each one of 134 | which must be named differently, while the second method can be implemented 135 | using anonymous delegates ($\lambda$-expressions). We chose the second method 136 | for this simple reason. 137 | 138 | \subsection DEVICES. 139 | As required by the specification, the \MIX\ computer features asynchronous 140 | I/O. All devices communicate with the computer by sending and receiving 141 | blocks of data, either as full \MIX\ words (in the case of disks and magnetic 142 | tape) or in character mode (for the other devices). In character mode the 143 | sign of the \MIX\ word is ignored and bytes 1--4 are interpreted as a characters 144 | from the \MIX\ character set. Block size varies from device type to device type. 145 | 146 | This abstraction is encapsulated in the |MIXDevice| abstract class and its 147 | subclasses, which are illustrated in Figure~3.2 below: 148 | 149 | \epsfxsize=.9\hsize 150 | \centerline{\epsfbox{eps/devices.eps}} 151 | \smallskip\centerline{\ninerm{\ninebf Figure 3.2} \MIX\ Devices class diagram} 152 | \smallskip\noindent 153 | The |MIXDevice| abstract class contains the core interface to a \MIX\ device. 154 | Its important methods are |In()|, |Out()| and |IOC()|. These methods 155 | simply call the |InProc()|, |OutProc()| and |IOCProc()| methods respectively 156 | in a new thread of execution---this provides the asynchronous device operation 157 | required by the specification. 158 | 159 | Concrete children of the |MIXDevice| class override these last three methods 160 | to provide the functionality of the implemented device. Some devices are meant 161 | only for input, others only for output, in which case the |InProc()| or the 162 | |OutProc()| methods respectively have null implementations. 163 | 164 | The |Ready| property is the device's ``status indicator''. It is cleared 165 | by the |InProc()|, |OutProc()| and |IOCProc()| methods whenever they begin 166 | execution, and reset when they end. It is important that the body of these 167 | methods is written inside a critical region to provide the appropriate 168 | synchronization. C\#'s |lock| primitive is used for this purpose. 169 | 170 | Devices are actually implemented using streams as backing store. Upon instantiation 171 | of a |MIXDevice| subclass, we specify a |Stream| instance for such use, 172 | but it's possible to redirect a device by simply changing the underlying 173 | stream, to either a |MemoryStream|, the standard input/output streams or 174 | a |FileStream|---or |null| if the device is unbacked, making the device behave 175 | as if it did not exist at all. The |Redirect()| method of the |MIXDevice| class 176 | is provided exactly for this purpose. 177 | 178 | \subsection THE MACHINE. 179 | Everything is put together in the |MIXMachine| class. Details such as the 180 | \MIX\ character map, the register set (a set of |MIXWord| properties), the 181 | overflow/comparison indicators, the memory (an array of |MIXWord|s), the 182 | device array and the instruction set are all implemented as properties 183 | in this class. 184 | 185 | A |MIXMachine| instance can load a binary memory dump or a card deck as they 186 | are output from the assembler. There exist methods to execute one instruction 187 | or to execute instructions sequentially until an |HLT| instruction is reached. 188 | Execution is governed by a special property called |PC| (for |P|rogram |C|ounter) 189 | which holds the memory location of the next instruction to be executed. 190 | \endchapter 191 | 192 | One Ring to rule them all, One Ring to find them, 193 | One Ring to bring them all and in the darkness bind them 194 | In the Land of Mordor where the Shadows lie. 195 | \author{J. R. R. TOLKIEN}, {\sl The Fellowship of the Ring} (1954) 196 | \eject -------------------------------------------------------------------------------- /src/MIXLib/Parser/Scanner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using System.Linq; 5 | using System.Collections.Generic; 6 | 7 | namespace MIXLib.Parser 8 | { 9 | public enum TokenType 10 | { 11 | LABEL, 12 | SYMBOL, 13 | NUMBER, 14 | KEYWORD, 15 | STRING, 16 | EQU, 17 | ORIG, 18 | CON, 19 | ALF, 20 | END, 21 | PLUS, 22 | MINUS, 23 | STAR, 24 | SLASH, 25 | SLASHSLASH, 26 | LPAREN, 27 | RPAREN, 28 | COMMA, 29 | COLON, 30 | EQUALS 31 | } 32 | 33 | public struct Token 34 | { 35 | public TokenType Type; 36 | public string Text; 37 | public byte ColumnNumber; 38 | } 39 | 40 | public class ScannerException 41 | : Exception 42 | { 43 | public int LineNumber { get; private set; } 44 | public byte ColumnNumber { get; private set; } 45 | 46 | public ScannerException(int l, byte c, string m) 47 | : base(m) 48 | { 49 | LineNumber = l; 50 | ColumnNumber = c; 51 | } 52 | } 53 | 54 | public sealed class Scanner 55 | { 56 | private enum ScannerState 57 | { 58 | LABEL, 59 | OPCODE, 60 | OPERAND, 61 | STRING 62 | } 63 | 64 | private readonly string line; 65 | private readonly int lineNum; 66 | 67 | public Scanner(int lineNum, string input) 68 | { 69 | this.line = input; 70 | this.lineNum = lineNum; 71 | } 72 | 73 | public IEnumerable Tokens 74 | { 75 | get 76 | { 77 | StringReader input = new StringReader(line); 78 | ScannerState state = ScannerState.LABEL; 79 | byte col = 0, endCol = 0; 80 | 81 | while (input.Peek() != -1) 82 | { 83 | char ch = (char)input.Peek(); 84 | 85 | if (char.IsUpper(ch) || char.IsDigit(ch)) 86 | { 87 | StringBuilder accum = new StringBuilder(); 88 | while (char.IsUpper(ch) || char.IsDigit(ch)) 89 | { 90 | accum.Append(ch); 91 | input.Read(); 92 | endCol++; 93 | 94 | ch = (char)input.Peek(); // Get the next character 95 | } 96 | 97 | int temp = 0; 98 | switch (state) 99 | { 100 | case ScannerState.LABEL: 101 | // Labels cannot be numeric constants 102 | if (int.TryParse(accum.ToString(), out temp)) 103 | { 104 | throw new ScannerException(lineNum, col, "Expected: SYMBOL, Found: NUMBER"); 105 | } 106 | // Symbols can be up to ten characters 107 | if (accum.ToString().Length > 10) 108 | { 109 | throw new ScannerException(lineNum, col, 110 | $"Symbol '{accum}' is too long"); 111 | } 112 | yield return new Token { ColumnNumber = col, Text = accum.ToString(), Type = TokenType.LABEL }; 113 | col = endCol; 114 | break; 115 | 116 | // Opcodes are special MIX keywords 117 | case ScannerState.OPCODE: 118 | // Here we check the text to see that it conforms to the MIX instruction set, or a pseudo op etc... 119 | var tokText = accum.ToString().Trim(); 120 | 121 | if (MIXMachine.INSTRUCTION_LIST.FindIndex(i => i.Name == tokText) != -1) 122 | yield return new Token { ColumnNumber = col, Text = tokText, Type = TokenType.KEYWORD }; 123 | else if (tokText == "ORIG") 124 | yield return new Token { ColumnNumber = col, Text = tokText, Type = TokenType.ORIG }; 125 | else if (tokText == "EQU") 126 | yield return new Token { ColumnNumber = col, Text = tokText, Type = TokenType.EQU }; 127 | else if (tokText == "CON") 128 | yield return new Token { ColumnNumber = col, Text = tokText, Type = TokenType.CON }; 129 | else if (tokText == "ALF") 130 | { 131 | state = ScannerState.STRING; 132 | yield return new Token { ColumnNumber = col, Text = tokText, Type = TokenType.ALF }; 133 | } 134 | else if (tokText == "END") 135 | yield return new Token { ColumnNumber = col, Text = tokText, Type = TokenType.END }; 136 | else 137 | throw new ScannerException(lineNum, col, 138 | $"Expected: KEYWORD or PSEUDO, Found: '{tokText}'"); 139 | 140 | col = endCol; 141 | break; 142 | 143 | // Operands can be any symbol or number 144 | case ScannerState.OPERAND: 145 | if (int.TryParse(accum.ToString(), out temp)) 146 | { 147 | if (accum.ToString().Length > 10) 148 | { 149 | throw new ScannerException(lineNum, col, 150 | $"Number '{accum}' is too long"); 151 | } 152 | yield return new Token { ColumnNumber = col, Text = accum.ToString(), Type = TokenType.NUMBER }; 153 | } 154 | else 155 | { 156 | if (accum.ToString().Length > 10) 157 | { 158 | throw new ScannerException(lineNum, col, 159 | $"Symbol '{accum}' is too long"); 160 | } 161 | yield return new Token { ColumnNumber = col, Text = accum.ToString(), Type = TokenType.SYMBOL }; 162 | } 163 | col = endCol; 164 | break; 165 | } 166 | } 167 | else if (ch == '/') 168 | { 169 | input.Read(); 170 | endCol++; 171 | if ((char)input.Peek() == '/') 172 | { 173 | input.Read(); 174 | endCol++; 175 | yield return new Token { ColumnNumber = col, Text = "//", Type = TokenType.SLASHSLASH }; 176 | } 177 | else 178 | yield return new Token { ColumnNumber = col, Text = "/", Type = TokenType.SLASH }; 179 | col = endCol; 180 | } 181 | else if (char.IsWhiteSpace(ch)) 182 | { 183 | // Read the first blank 184 | input.Read(); 185 | endCol++; 186 | 187 | if (state != ScannerState.STRING) 188 | { 189 | // Change the scanner state 190 | switch (state) 191 | { 192 | case ScannerState.LABEL: 193 | state = ScannerState.OPCODE; 194 | col = ReadToNextChar(input, col); 195 | break; 196 | case ScannerState.OPCODE: 197 | state = ScannerState.OPERAND; 198 | col = ReadToNextChar(input, col); 199 | break; 200 | case ScannerState.OPERAND: 201 | yield break; 202 | } 203 | } 204 | else 205 | { 206 | ch = (char)input.Peek(); 207 | if (char.IsWhiteSpace(ch)) 208 | { 209 | input.Read(); 210 | endCol++; 211 | ch = (char)input.Peek(); 212 | } 213 | string sc = ((char)input.Read()).ToString(); 214 | 215 | // Read four more characters 216 | for (var i = 0; i < 4; i++) 217 | { 218 | if (input.Peek() == -1) 219 | yield return new Token { ColumnNumber = col, Type = TokenType.STRING, Text = sc.PadRight(5) }; 220 | sc += (char)input.Read(); 221 | } 222 | yield return new Token { ColumnNumber = col, Type = TokenType.STRING, Text = sc }; 223 | } 224 | } 225 | else 226 | switch (ch) 227 | { 228 | case '+': 229 | endCol++; 230 | input.Read(); 231 | yield return new Token { ColumnNumber = col, Text = "+", Type = TokenType.PLUS }; 232 | col = endCol; 233 | break; 234 | case '-': 235 | endCol++; 236 | input.Read(); 237 | yield return new Token { ColumnNumber = col, Text = "-", Type = TokenType.MINUS }; 238 | col = endCol; 239 | break; 240 | case '*': 241 | endCol++; 242 | input.Read(); 243 | yield return new Token { ColumnNumber = col, Text = "*", Type = TokenType.STAR }; 244 | col = endCol; 245 | break; 246 | case '(': 247 | endCol++; 248 | input.Read(); 249 | yield return new Token { ColumnNumber = col, Text = "(", Type = TokenType.LPAREN }; 250 | col = endCol; 251 | break; 252 | case ')': 253 | endCol++; 254 | input.Read(); 255 | yield return new Token { ColumnNumber = col, Text = ")", Type = TokenType.RPAREN }; 256 | col = endCol; 257 | break; 258 | case ',': 259 | endCol++; 260 | input.Read(); 261 | yield return new Token { ColumnNumber = col, Text = ",", Type = TokenType.COMMA }; 262 | col = endCol; 263 | break; 264 | case ':': 265 | endCol++; 266 | input.Read(); 267 | yield return new Token { ColumnNumber = col, Text = ":", Type = TokenType.COLON }; 268 | col = endCol; 269 | break; 270 | case '=': 271 | endCol++; 272 | input.Read(); 273 | yield return new Token { ColumnNumber = col, Text = "=", Type = TokenType.EQUALS }; 274 | col = endCol; 275 | break; 276 | default: 277 | throw new ScannerException(lineNum, col, string.Format("Unexpected character: '{0}'", ch)); 278 | } 279 | } 280 | } 281 | } 282 | 283 | private byte ReadToNextChar(TextReader input, byte currCol) 284 | { 285 | char ch = (char)input.Peek(); 286 | 287 | while (char.IsWhiteSpace(ch)) 288 | { 289 | input.Read(); 290 | currCol++; 291 | 292 | ch = (char)input.Peek(); 293 | } 294 | 295 | return currCol; 296 | } 297 | } 298 | } -------------------------------------------------------------------------------- /doc/eps/expr.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\George\AppData\Local\Temp\jfig-tmp7148498884111542474.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 01:30:24 2009 5 | %%For: George@MOSQUITO (U-MOSQUITO\George,S-1-5-21-4166747469-2723723270-1828463590-1000) 6 | %%BoundingBox: 0 0 796 485 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 485 moveto 0 0 lineto 796 0 lineto 796 485 lineto closepath clip newpath 49 | -27.6 485.2 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /reencdict 12 dict def /ReEncode { reencdict begin 84 | /newcodesandnames exch def /newfontname exch def /basefontname exch def 85 | /basefontdict basefontname findfont def /newfont basefontdict maxlength dict def 86 | basefontdict { exch dup /FID ne { dup /Encoding eq 87 | { exch dup length array copy newfont 3 1 roll put } 88 | { exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall 89 | newfont /FontName newfontname put newcodesandnames aload pop 90 | 128 1 255 { newfont /Encoding get exch /.notdef put } for 91 | newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat 92 | newfontname newfont definefont pop end } def 93 | /isovec [ 94 | 8#055 /minus 8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde 95 | 8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis 96 | 8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron 97 | 8#220 /dotlessi 8#230 /oe 8#231 /OE 98 | 8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling 99 | 8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis 100 | 8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot 101 | 8#255 /hyphen 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus 102 | 8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph 103 | 8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine 104 | 8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf 105 | 8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute 106 | 8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring 107 | 8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute 108 | 8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute 109 | 8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve 110 | 8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply 111 | 8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex 112 | 8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave 113 | 8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring 114 | 8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute 115 | 8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute 116 | 8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve 117 | 8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide 118 | 8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex 119 | 8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def 120 | /Helvetica /Helvetica-iso isovec ReEncode 121 | /DrawEllipse { 122 | /endangle exch def 123 | /startangle exch def 124 | /yrad exch def 125 | /xrad exch def 126 | /y exch def 127 | /x exch def 128 | /savematrix mtrx currentmatrix def 129 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 130 | closepath 131 | savematrix setmatrix 132 | } def 133 | 134 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 135 | /$F2psEnd {$F2psEnteredState restore end} def 136 | 137 | $F2psBegin 138 | 10 setmiterlimit 139 | 0.06299 0.06299 sc 140 | % 141 | % Fig objects follow 142 | % 143 | /Helvetica-iso ff 270.00 scf sf 144 | 900 315 m 145 | gs 1 -1 sc (Expression) col0 sh gr 146 | /Helvetica-iso ff 270.00 scf sf 147 | 10256 5715 m 148 | gs 1 -1 sc (/) col0 sh gr 149 | 7.500 slw 150 | % Ellipse 151 | n 10305 6480 270 270 0 360 DrawEllipse gs col0 s gr 152 | 153 | /Helvetica-iso ff 270.00 scf sf 154 | 10211 6615 m 155 | gs 1 -1 sc (//) col0 sh gr 156 | % Ellipse 157 | n 10305 7425 270 270 0 360 DrawEllipse gs col0 s gr 158 | 159 | /Helvetica-iso ff 270.00 scf sf 160 | 10256 7515 m 161 | gs 1 -1 sc (:) col0 sh gr 162 | % Polyline 163 | n 5805 1350 m 6885 1350 l 6885 1800 l 5805 1800 l 164 | cp gs col0 s gr 165 | /Helvetica-iso ff 270.00 scf sf 166 | 6030 1665 m 167 | gs 1 -1 sc (atom) col0 sh gr 168 | % Ellipse 169 | n 3195 2250 270 270 0 360 DrawEllipse gs col0 s gr 170 | 171 | /Helvetica-iso ff 270.00 scf sf 172 | 3146 2340 m 173 | gs 1 -1 sc (-) col0 sh gr 174 | % Ellipse 175 | n 3195 900 270 270 0 360 DrawEllipse gs col0 s gr 176 | 177 | /Helvetica-iso ff 270.00 scf sf 178 | 3105 1021 m 179 | gs 1 -1 sc (+) col0 sh gr 180 | % Ellipse 181 | n 10305 2925 270 270 0 360 DrawEllipse gs col0 s gr 182 | 183 | /Helvetica-iso ff 270.00 scf sf 184 | 10215 3046 m 185 | gs 1 -1 sc (+) col0 sh gr 186 | % Ellipse 187 | n 10305 3825 270 270 0 360 DrawEllipse gs col0 s gr 188 | 189 | /Helvetica-iso ff 270.00 scf sf 190 | 10256 3915 m 191 | gs 1 -1 sc (-) col0 sh gr 192 | % Ellipse 193 | n 10305 4725 270 270 0 360 DrawEllipse gs col0 s gr 194 | 195 | /Helvetica-iso ff 270.00 scf sf 196 | 10256 4905 m 197 | gs 1 -1 sc (*) col0 sh gr 198 | % Polyline 199 | n 7335 4500 m 8415 4500 l 8415 4950 l 7335 4950 l 200 | cp gs col0 s gr 201 | /Helvetica-iso ff 270.00 scf sf 202 | 7560 4815 m 203 | gs 1 -1 sc (atom) col0 sh gr 204 | % Polyline 205 | gs clippath 206 | 8400 4653 m 8400 4797 l 8732 4797 l 8432 4725 l 8732 4653 l cp 207 | eoclip 208 | n 10035 7425 m 9495 7425 l 9495 4725 l 209 | 8415 4725 l gs col0 s gr gr 210 | 211 | % arrowhead 212 | n 8732 4653 m 8432 4725 l 8732 4797 l 8672 4725 l 8732 4653 l 213 | cp gs 0.00 setgray ef gr col0 s 214 | % Polyline 215 | gs clippath 216 | 8400 4653 m 8400 4797 l 8732 4797 l 8432 4725 l 8732 4653 l cp 217 | eoclip 218 | n 10035 6525 m 9495 6525 l 9495 4725 l 219 | 8415 4725 l gs col0 s gr gr 220 | 221 | % arrowhead 222 | n 8732 4653 m 8432 4725 l 8732 4797 l 8672 4725 l 8732 4653 l 223 | cp gs 0.00 setgray ef gr col0 s 224 | % Polyline 225 | gs clippath 226 | 8400 4653 m 8400 4797 l 8732 4797 l 8432 4725 l 8732 4653 l cp 227 | eoclip 228 | n 10035 5625 m 9495 5625 l 9495 4725 l 229 | 8415 4725 l gs col0 s gr gr 230 | 231 | % arrowhead 232 | n 8732 4653 m 8432 4725 l 8732 4797 l 8672 4725 l 8732 4653 l 233 | cp gs 0.00 setgray ef gr col0 s 234 | % Polyline 235 | gs clippath 236 | 8400 4653 m 8400 4797 l 8732 4797 l 8432 4725 l 8732 4653 l cp 237 | eoclip 238 | n 10035 3825 m 9495 3825 l 9495 4725 l 239 | 8415 4725 l gs col0 s gr gr 240 | 241 | % arrowhead 242 | n 8732 4653 m 8432 4725 l 8732 4797 l 8672 4725 l 8732 4653 l 243 | cp gs 0.00 setgray ef gr col0 s 244 | % Polyline 245 | gs clippath 246 | 8400 4653 m 8400 4797 l 8732 4797 l 8432 4725 l 8732 4653 l cp 247 | eoclip 248 | n 10035 2925 m 9495 2925 l 9495 4725 l 249 | 8415 4725 l gs col0 s gr gr 250 | 251 | % arrowhead 252 | n 8732 4653 m 8432 4725 l 8732 4797 l 8672 4725 l 8732 4653 l 253 | cp gs 0.00 setgray ef gr col0 s 254 | % Polyline 255 | gs clippath 256 | 7272 1560 m 7128 1560 l 7128 1892 l 7200 1592 l 7272 1892 l cp 257 | eoclip 258 | n 7335 4725 m 7200 4725 l 259 | 7200 1575 l gs col0 s gr gr 260 | 261 | % arrowhead 262 | n 7272 1892 m 7200 1592 l 7128 1892 l 7200 1832 l 7272 1892 l 263 | cp gs 0.00 setgray ef gr col0 s 264 | % Polyline 265 | gs clippath 266 | 10560 7353 m 10560 7497 l 10892 7497 l 10592 7425 l 10892 7353 l cp 267 | eoclip 268 | n 11025 6525 m 11025 7425 l 269 | 10575 7425 l gs col0 s gr gr 270 | 271 | % arrowhead 272 | n 10892 7353 m 10592 7425 l 10892 7497 l 10832 7425 l 10892 7353 l 273 | cp gs 0.00 setgray ef gr col0 s 274 | % Polyline 275 | gs clippath 276 | 10560 6453 m 10560 6597 l 10892 6597 l 10592 6525 l 10892 6453 l cp 277 | eoclip 278 | n 11025 5625 m 11025 6525 l 279 | 10575 6525 l gs col0 s gr gr 280 | 281 | % arrowhead 282 | n 10892 6453 m 10592 6525 l 10892 6597 l 10832 6525 l 10892 6453 l 283 | cp gs 0.00 setgray ef gr col0 s 284 | % Polyline 285 | gs clippath 286 | 10560 5553 m 10560 5697 l 10892 5697 l 10592 5625 l 10892 5553 l cp 287 | eoclip 288 | n 11025 4725 m 11025 5625 l 289 | 10575 5625 l gs col0 s gr gr 290 | 291 | % arrowhead 292 | n 10892 5553 m 10592 5625 l 10892 5697 l 10832 5625 l 10892 5553 l 293 | cp gs 0.00 setgray ef gr col0 s 294 | % Polyline 295 | gs clippath 296 | 10560 4653 m 10560 4797 l 10892 4797 l 10592 4725 l 10892 4653 l cp 297 | eoclip 298 | n 11025 4725 m 299 | 10575 4725 l gs col0 s gr gr 300 | 301 | % arrowhead 302 | n 10892 4653 m 10592 4725 l 10892 4797 l 10832 4725 l 10892 4653 l 303 | cp gs 0.00 setgray ef gr col0 s 304 | % Polyline 305 | gs clippath 306 | 10560 3753 m 10560 3897 l 10892 3897 l 10592 3825 l 10892 3753 l cp 307 | eoclip 308 | n 11025 3825 m 309 | 10575 3825 l gs col0 s gr gr 310 | 311 | % arrowhead 312 | n 10892 3753 m 10592 3825 l 10892 3897 l 10832 3825 l 10892 3753 l 313 | cp gs 0.00 setgray ef gr col0 s 314 | % Polyline 315 | gs clippath 316 | 10560 2853 m 10560 2997 l 10892 2997 l 10592 2925 l 10892 2853 l cp 317 | eoclip 318 | n 12375 1575 m 12375 4725 l 11025 4725 l 11025 2925 l 319 | 10575 2925 l gs col0 s gr gr 320 | 321 | % arrowhead 322 | n 10892 2853 m 10592 2925 l 10892 2997 l 10832 2925 l 10892 2853 l 323 | cp gs 0.00 setgray ef gr col0 s 324 | % Polyline 325 | gs clippath 326 | 5820 1647 m 5820 1503 l 5488 1503 l 5788 1575 l 5488 1647 l cp 327 | eoclip 328 | n 3465 2250 m 4005 2250 l 4005 1575 l 329 | 5805 1575 l gs col0 s gr gr 330 | 331 | % arrowhead 332 | n 5488 1647 m 5788 1575 l 5488 1503 l 5548 1575 l 5488 1647 l 333 | cp gs 0.00 setgray ef gr col0 s 334 | % Polyline 335 | gs clippath 336 | 5820 1647 m 5820 1503 l 5488 1503 l 5788 1575 l 5488 1647 l cp 337 | eoclip 338 | n 3465 900 m 4005 900 l 4005 1575 l 339 | 5805 1575 l gs col0 s gr gr 340 | 341 | % arrowhead 342 | n 5488 1647 m 5788 1575 l 5488 1503 l 5548 1575 l 5488 1647 l 343 | cp gs 0.00 setgray ef gr col0 s 344 | % Polyline 345 | gs clippath 346 | 2940 2322 m 2940 2178 l 2608 2178 l 2908 2250 l 2608 2322 l cp 347 | eoclip 348 | n 2250 1575 m 2250 2250 l 349 | 2925 2250 l gs col0 s gr gr 350 | 351 | % arrowhead 352 | n 2608 2322 m 2908 2250 l 2608 2178 l 2668 2250 l 2608 2322 l 353 | cp gs 0.00 setgray ef gr col0 s 354 | % Polyline 355 | gs clippath 356 | 2940 972 m 2940 828 l 2608 828 l 2908 900 l 2608 972 l cp 357 | eoclip 358 | n 2250 1575 m 2250 900 l 359 | 2925 900 l gs col0 s gr gr 360 | 361 | % arrowhead 362 | n 2608 972 m 2908 900 l 2608 828 l 2668 900 l 2608 972 l 363 | cp gs 0.00 setgray ef gr col0 s 364 | % Polyline 365 | n 450 1575 m 366 | 2115 1575 l gs col0 s gr 367 | % Polyline 368 | gs clippath 369 | 5820 1647 m 5820 1503 l 5488 1503 l 5788 1575 l 5488 1647 l cp 370 | eoclip 371 | n 4185 1575 m 372 | 5805 1575 l gs col0 s gr gr 373 | 374 | % arrowhead 375 | n 5488 1647 m 5788 1575 l 5488 1503 l 5548 1575 l 5488 1647 l 376 | cp gs 0.00 setgray ef gr col0 s 377 | % Polyline 378 | gs clippath 379 | 13065 1647 m 13065 1503 l 12733 1503 l 13033 1575 l 12733 1647 l cp 380 | eoclip 381 | n 6885 1575 m 382 | 13050 1575 l gs col0 s gr gr 383 | 384 | % arrowhead 385 | n 12733 1647 m 13033 1575 l 12733 1503 l 12793 1575 l 12733 1647 l 386 | cp gs 0.00 setgray ef gr col0 s 387 | % Polyline 388 | n 9360 4725 m 389 | 10035 4725 l gs col0 s gr 390 | % Polyline 391 | gs clippath 392 | 8400 4653 m 8400 4797 l 8732 4797 l 8432 4725 l 8732 4653 l cp 393 | eoclip 394 | n 9360 4725 m 395 | 8415 4725 l gs col0 s gr gr 396 | 397 | % arrowhead 398 | n 8732 4653 m 8432 4725 l 8732 4797 l 8672 4725 l 8732 4653 l 399 | cp gs 0.00 setgray ef gr col0 s 400 | % Polyline 401 | n 2115 1575 m 402 | 4185 1575 l gs col0 s gr 403 | % Ellipse 404 | n 10305 5580 270 270 0 360 DrawEllipse gs col0 s gr 405 | 406 | $F2psEnd 407 | rs 408 | -------------------------------------------------------------------------------- /doc/eps/instruction.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: C:\Users\GTryf\AppData\Local\Temp\jfig-tmp4110209973326973592.fig 3 | %%Creator: fig2dev.exe Version 3.2 Patchlevel 3d 4 | %%CreationDate: Tue Jul 14 13:58:07 2009 5 | %%For: GTryf@PC155 () 6 | %%BoundingBox: 0 0 796 422 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 422 moveto 0 0 lineto 796 0 lineto 796 422 lineto closepath clip newpath 49 | -27.6 312.6 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /reencdict 12 dict def /ReEncode { reencdict begin 84 | /newcodesandnames exch def /newfontname exch def /basefontname exch def 85 | /basefontdict basefontname findfont def /newfont basefontdict maxlength dict def 86 | basefontdict { exch dup /FID ne { dup /Encoding eq 87 | { exch dup length array copy newfont 3 1 roll put } 88 | { exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall 89 | newfont /FontName newfontname put newcodesandnames aload pop 90 | 128 1 255 { newfont /Encoding get exch /.notdef put } for 91 | newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat 92 | newfontname newfont definefont pop end } def 93 | /isovec [ 94 | 8#055 /minus 8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde 95 | 8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis 96 | 8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron 97 | 8#220 /dotlessi 8#230 /oe 8#231 /OE 98 | 8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling 99 | 8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis 100 | 8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot 101 | 8#255 /hyphen 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus 102 | 8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph 103 | 8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine 104 | 8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf 105 | 8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute 106 | 8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring 107 | 8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute 108 | 8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute 109 | 8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve 110 | 8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply 111 | 8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex 112 | 8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave 113 | 8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring 114 | 8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute 115 | 8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute 116 | 8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve 117 | 8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide 118 | 8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex 119 | 8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def 120 | /Helvetica /Helvetica-iso isovec ReEncode 121 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 122 | /$F2psEnd {$F2psEnteredState restore end} def 123 | 124 | $F2psBegin 125 | 10 setmiterlimit 126 | 0.06299 0.06299 sc 127 | % 128 | % Fig objects follow 129 | % 130 | /Helvetica-iso ff 270.00 scf sf 131 | 900 -1350 m 132 | gs 1 -1 sc (Instruction) col0 sh gr 133 | /Helvetica-iso ff 270.00 scf sf 134 | 4275 4770 m 135 | gs 1 -1 sc (END) col0 sh gr 136 | % Polyline 137 | 7.500 slw 138 | n 2160 2520 m 1980 2520 1980 2925 180 arcto 4 {pop} repeat 139 | 1980 3105 2880 3105 180 arcto 4 {pop} repeat 140 | 3060 3105 3060 2700 180 arcto 4 {pop} repeat 141 | 3060 2520 2160 2520 180 arcto 4 {pop} repeat 142 | cp gs col0 s gr 143 | /Helvetica-iso ff 270.00 scf sf 144 | 2205 2925 m 145 | gs 1 -1 sc (label) col0 sh gr 146 | % Polyline 147 | n 4185 3420 m 4005 3420 4005 3825 180 arcto 4 {pop} repeat 148 | 4005 4005 4995 4005 180 arcto 4 {pop} repeat 149 | 5175 4005 5175 3600 180 arcto 4 {pop} repeat 150 | 5175 3420 4185 3420 180 arcto 4 {pop} repeat 151 | cp gs col0 s gr 152 | /Helvetica-iso ff 270.00 scf sf 153 | 4275 3825 m 154 | gs 1 -1 sc (EQU) col0 sh gr 155 | % Polyline 156 | n 4185 495 m 4005 495 4005 900 180 arcto 4 {pop} repeat 157 | 4005 1080 4995 1080 180 arcto 4 {pop} repeat 158 | 5175 1080 5175 675 180 arcto 4 {pop} repeat 159 | 5175 495 4185 495 180 arcto 4 {pop} repeat 160 | cp gs col0 s gr 161 | /Helvetica-iso ff 270.00 scf sf 162 | 4320 900 m 163 | gs 1 -1 sc (ALF) col0 sh gr 164 | % Polyline 165 | n 4185 1485 m 4005 1485 4005 1890 180 arcto 4 {pop} repeat 166 | 4005 2070 4995 2070 180 arcto 4 {pop} repeat 167 | 5175 2070 5175 1665 180 arcto 4 {pop} repeat 168 | 5175 1485 4185 1485 180 arcto 4 {pop} repeat 169 | cp gs col0 s gr 170 | /Helvetica-iso ff 270.00 scf sf 171 | 4230 1890 m 172 | gs 1 -1 sc (ORIG) col0 sh gr 173 | % Polyline 174 | n 4185 2520 m 4005 2520 4005 2925 180 arcto 4 {pop} repeat 175 | 4005 3105 4995 3105 180 arcto 4 {pop} repeat 176 | 5175 3105 5175 2700 180 arcto 4 {pop} repeat 177 | 5175 2520 4185 2520 180 arcto 4 {pop} repeat 178 | cp gs col0 s gr 179 | /Helvetica-iso ff 270.00 scf sf 180 | 4275 2925 m 181 | gs 1 -1 sc (CON) col0 sh gr 182 | % Polyline 183 | n 6705 1845 m 6525 1845 6525 2340 180 arcto 4 {pop} repeat 184 | 6525 2520 7740 2520 180 arcto 4 {pop} repeat 185 | 7920 2520 7920 2025 180 arcto 4 {pop} repeat 186 | 7920 1845 6705 1845 180 arcto 4 {pop} repeat 187 | cp gs col0 s gr 188 | /Helvetica-iso ff 270.00 scf sf 189 | 6750 2295 m 190 | gs 1 -1 sc (w-value) col0 sh gr 191 | % Polyline 192 | n 4185 -405 m 4005 -405 4005 45 180 arcto 4 {pop} repeat 193 | 4005 225 5310 225 180 arcto 4 {pop} repeat 194 | 5490 225 5490 -225 180 arcto 4 {pop} repeat 195 | 5490 -405 4185 -405 180 arcto 4 {pop} repeat 196 | cp gs col0 s gr 197 | /Helvetica-iso ff 270.00 scf sf 198 | 4185 0 m 199 | gs 1 -1 sc (keyword) col0 sh gr 200 | % Polyline 201 | n 6660 -360 m 7785 -360 l 7785 180 l 6660 180 l 202 | cp gs col0 s gr 203 | /Helvetica-iso ff 270.00 scf sf 204 | 6795 0 m 205 | gs 1 -1 sc (a-part) col0 sh gr 206 | % Polyline 207 | n 8550 -360 m 9675 -360 l 9675 180 l 8550 180 l 208 | cp gs col0 s gr 209 | /Helvetica-iso ff 270.00 scf sf 210 | 8685 0 m 211 | gs 1 -1 sc (i-part) col0 sh gr 212 | % Polyline 213 | n 10395 -360 m 11520 -360 l 11520 180 l 10395 180 l 214 | cp gs col0 s gr 215 | /Helvetica-iso ff 270.00 scf sf 216 | 10530 0 m 217 | gs 1 -1 sc (f-part) col0 sh gr 218 | % Polyline 219 | n 6840 495 m 6660 495 6660 855 180 arcto 4 {pop} repeat 220 | 6660 1035 7560 1035 180 arcto 4 {pop} repeat 221 | 7740 1035 7740 675 180 arcto 4 {pop} repeat 222 | 7740 495 6840 495 180 arcto 4 {pop} repeat 223 | cp gs col0 s gr 224 | /Helvetica-iso ff 270.00 scf sf 225 | 6840 855 m 226 | gs 1 -1 sc (string) col0 sh gr 227 | % Polyline 228 | gs clippath 229 | 6540 2277 m 6540 2133 l 6208 2133 l 6508 2205 l 6208 2277 l cp 230 | eoclip 231 | n 5175 4680 m 5850 4680 l 5850 2205 l 232 | 6525 2205 l gs col0 s gr gr 233 | 234 | % arrowhead 235 | n 6208 2277 m 6508 2205 l 6208 2133 l 6268 2205 l 6208 2277 l 236 | cp gs 0.00 setgray ef gr col0 s 237 | % Polyline 238 | gs clippath 239 | 4020 4752 m 4020 4608 l 3688 4608 l 3988 4680 l 3688 4752 l cp 240 | eoclip 241 | n 3060 2835 m 3465 2835 l 3465 4680 l 242 | 4005 4680 l gs col0 s gr gr 243 | 244 | % arrowhead 245 | n 3688 4752 m 3988 4680 l 3688 4608 l 3748 4680 l 3688 4752 l 246 | cp gs 0.00 setgray ef gr col0 s 247 | % Polyline 248 | gs clippath 249 | 4020 2907 m 4020 2763 l 3688 2763 l 3988 2835 l 3688 2907 l cp 250 | eoclip 251 | n 3060 2835 m 252 | 4005 2835 l gs col0 s gr gr 253 | 254 | % arrowhead 255 | n 3688 2907 m 3988 2835 l 3688 2763 l 3748 2835 l 3688 2907 l 256 | cp gs 0.00 setgray ef gr col0 s 257 | % Polyline 258 | gs clippath 259 | 4020 1827 m 4020 1683 l 3688 1683 l 3988 1755 l 3688 1827 l cp 260 | eoclip 261 | n 3465 2835 m 3465 1755 l 262 | 4005 1755 l gs col0 s gr gr 263 | 264 | % arrowhead 265 | n 3688 1827 m 3988 1755 l 3688 1683 l 3748 1755 l 3688 1827 l 266 | cp gs 0.00 setgray ef gr col0 s 267 | % Polyline 268 | gs clippath 269 | 4020 837 m 4020 693 l 3688 693 l 3988 765 l 3688 837 l cp 270 | eoclip 271 | n 3465 1755 m 3465 765 l 272 | 4005 765 l gs col0 s gr gr 273 | 274 | % arrowhead 275 | n 3688 837 m 3988 765 l 3688 693 l 3748 765 l 3688 837 l 276 | cp gs 0.00 setgray ef gr col0 s 277 | % Polyline 278 | gs clippath 279 | 1995 2907 m 1995 2763 l 1663 2763 l 1963 2835 l 1663 2907 l cp 280 | eoclip 281 | n 450 2835 m 282 | 1980 2835 l gs col0 s gr gr 283 | 284 | % arrowhead 285 | n 1663 2907 m 1963 2835 l 1663 2763 l 1723 2835 l 1663 2907 l 286 | cp gs 0.00 setgray ef gr col0 s 287 | % Polyline 288 | gs clippath 289 | 3168 2850 m 3312 2850 l 3312 2518 l 3240 2818 l 3168 2518 l cp 290 | eoclip 291 | n 1395 2835 m 1395 2115 l 3240 2115 l 292 | 3240 2835 l gs col0 s gr gr 293 | 294 | % arrowhead 295 | n 3168 2518 m 3240 2818 l 3312 2518 l 3240 2578 l 3168 2518 l 296 | cp gs 0.00 setgray ef gr col0 s 297 | % Polyline 298 | gs clippath 299 | 6675 837 m 6675 693 l 6343 693 l 6643 765 l 6343 837 l cp 300 | eoclip 301 | n 5175 765 m 302 | 6660 765 l gs col0 s gr gr 303 | 304 | % arrowhead 305 | n 6343 837 m 6643 765 l 6343 693 l 6403 765 l 6343 837 l 306 | cp gs 0.00 setgray ef gr col0 s 307 | % Polyline 308 | gs clippath 309 | 6540 2277 m 6540 2133 l 6208 2133 l 6508 2205 l 6208 2277 l cp 310 | eoclip 311 | n 5175 1755 m 5850 1755 l 5850 2205 l 312 | 6525 2205 l gs col0 s gr gr 313 | 314 | % arrowhead 315 | n 6208 2277 m 6508 2205 l 6208 2133 l 6268 2205 l 6208 2277 l 316 | cp gs 0.00 setgray ef gr col0 s 317 | % Polyline 318 | gs clippath 319 | 6540 2277 m 6540 2133 l 6208 2133 l 6508 2205 l 6208 2277 l cp 320 | eoclip 321 | n 5175 2835 m 5850 2835 l 5850 2205 l 322 | 6525 2205 l gs col0 s gr gr 323 | 324 | % arrowhead 325 | n 6208 2277 m 6508 2205 l 6208 2133 l 6268 2205 l 6208 2277 l 326 | cp gs 0.00 setgray ef gr col0 s 327 | % Polyline 328 | gs clippath 329 | 6540 2277 m 6540 2133 l 6208 2133 l 6508 2205 l 6208 2277 l cp 330 | eoclip 331 | n 5175 3735 m 5850 3735 l 5850 2205 l 332 | 6525 2205 l gs col0 s gr gr 333 | 334 | % arrowhead 335 | n 6208 2277 m 6508 2205 l 6208 2133 l 6268 2205 l 6208 2277 l 336 | cp gs 0.00 setgray ef gr col0 s 337 | % Polyline 338 | gs clippath 339 | 4020 -18 m 4020 -162 l 3688 -161 l 3988 -89 l 3688 -17 l cp 340 | eoclip 341 | n 3060 2835 m 3465 2835 l 3465 -90 l 342 | 4005 -90 l gs col0 s gr gr 343 | 344 | % arrowhead 345 | n 3688 -17 m 3988 -89 l 3688 -161 l 3748 -89 l 3688 -17 l 346 | cp gs 0.00 setgray ef gr col0 s 347 | % Polyline 348 | gs clippath 349 | 6675 -18 m 6675 -162 l 6343 -161 l 6643 -89 l 6343 -17 l cp 350 | eoclip 351 | n 5490 -90 m 352 | 6660 -90 l gs col0 s gr gr 353 | 354 | % arrowhead 355 | n 6343 -17 m 6643 -89 l 6343 -161 l 6403 -89 l 6343 -17 l 356 | cp gs 0.00 setgray ef gr col0 s 357 | % Polyline 358 | gs clippath 359 | 8565 -18 m 8565 -162 l 8233 -161 l 8533 -89 l 8233 -17 l cp 360 | eoclip 361 | n 7785 -90 m 362 | 8550 -90 l gs col0 s gr gr 363 | 364 | % arrowhead 365 | n 8233 -17 m 8533 -89 l 8233 -161 l 8293 -89 l 8233 -17 l 366 | cp gs 0.00 setgray ef gr col0 s 367 | % Polyline 368 | gs clippath 369 | 10410 -18 m 10410 -162 l 10078 -161 l 10378 -89 l 10078 -17 l cp 370 | eoclip 371 | n 9675 -90 m 372 | 10395 -90 l gs col0 s gr gr 373 | 374 | % arrowhead 375 | n 10078 -17 m 10378 -89 l 10078 -161 l 10138 -89 l 10078 -17 l 376 | cp gs 0.00 setgray ef gr col0 s 377 | % Polyline 378 | gs clippath 379 | 13065 2277 m 13065 2133 l 12733 2133 l 13033 2205 l 12733 2277 l cp 380 | eoclip 381 | n 7920 2205 m 382 | 13050 2205 l gs col0 s gr gr 383 | 384 | % arrowhead 385 | n 12733 2277 m 13033 2205 l 12733 2133 l 12793 2205 l 12733 2277 l 386 | cp gs 0.00 setgray ef gr col0 s 387 | % Polyline 388 | gs clippath 389 | 13065 2277 m 13065 2133 l 12733 2133 l 13033 2205 l 12733 2277 l cp 390 | eoclip 391 | n 11520 -90 m 12060 -90 l 12060 2205 l 392 | 13050 2205 l gs col0 s gr gr 393 | 394 | % arrowhead 395 | n 12733 2277 m 13033 2205 l 12733 2133 l 12793 2205 l 12733 2277 l 396 | cp gs 0.00 setgray ef gr col0 s 397 | % Polyline 398 | gs clippath 399 | 13020 2277 m 13020 2133 l 12688 2133 l 12988 2205 l 12688 2277 l cp 400 | eoclip 401 | n 7740 765 m 12060 765 l 12060 2205 l 402 | 13005 2205 l gs col0 s gr gr 403 | 404 | % arrowhead 405 | n 12688 2277 m 12988 2205 l 12688 2133 l 12748 2205 l 12688 2277 l 406 | cp gs 0.00 setgray ef gr col0 s 407 | % Polyline 408 | gs clippath 409 | 4020 3807 m 4020 3663 l 3688 3663 l 3988 3735 l 3688 3807 l cp 410 | eoclip 411 | n 3060 2835 m 3465 2835 l 3465 3735 l 412 | 4005 3735 l gs col0 s gr gr 413 | 414 | % arrowhead 415 | n 3688 3807 m 3988 3735 l 3688 3663 l 3748 3735 l 3688 3807 l 416 | cp gs 0.00 setgray ef gr col0 s 417 | % Polyline 418 | n 4185 4365 m 4005 4365 4005 4770 180 arcto 4 {pop} repeat 419 | 4005 4950 4995 4950 180 arcto 4 {pop} repeat 420 | 5175 4950 5175 4545 180 arcto 4 {pop} repeat 421 | 5175 4365 4185 4365 180 arcto 4 {pop} repeat 422 | cp gs col0 s gr 423 | $F2psEnd 424 | rs 425 | --------------------------------------------------------------------------------