1 A Guide to the MARIE Machine Simulator Environment Accompanying The Essential
1 A Guide to the MARIE Machine Simulator Environment Accompanying The Essentials of Computer Organization and Architecture 3/e by Linda Null and Julia Lobur Version 2.0 – June 2010 Introduction Your authors have made every effort to create a MARIE machine simulator that is as Really Intuitive and Easy to use as the MARIE architecture is to understand. We believe that the best way to gain a deep understanding of the MARIE machine—or any computer system for that matter—is to write programs for it. Toward our goal of helping you to understand how computers really work, we have created the Marie machine simulator, MarieSim. MarieSim is an environment within which you can write your own programs and watch how they would run on a real "von Neumann architecture" computer system. By running programs on this simulator, not only will you see your programs in action, but you will also get a taste of assembler language programming without learning any particular assembly language beyond the simple instructions that your authors have presented. MarieSim was written in the Java language so that the system would be portable to any platform for which a Java Virtual Machine (JVM) is available. Students of Java may wish to look at the simulator's source code, and perhaps even supply improvements or enhancements to its simple functions. As of Version 1.2, the MarieSim environment has also been provided with a data path animator, called MarieDPath. We describe the operation of this simulator following our description of MarieSim operation. Installation The MARIE machine simulator requires Sun's Java SDK 5.0 or later. This software is available at no charge from the java.sun.com Web site. After this package is installed, you may run the simulator directly from the JAR files that have been provided. It is not necessary to unpack or unJAR the MARIE machine simulator and its accompanying datapath simulator in order to run them. All that you need to do is copy, or drag and drop, the respective JAR (Java archive) files to any convenient location on your system, and double click on the icon to invoke the simulator. Proceed to the section of this manual titled, " The MarieSim Environment." If you would prefer to run the Marie simulator from the command prompt, you may use the command: java -jar MarieSim.jar If you prefer, you may manually unpack the class files in order to run the bytecode. The Java archive file MarieSim.jar (case sensitive) can be placed in the directory of your choosing. The following command will uncompress the archive: jar xvf MarieSim.jar If the archive uncompresses correctly, you will have the main MARIE simulator class file, MarieSim1.class and two MARIE code example files in your directory. Jar will also create two subdirectories, Meta-inf, and MarieSimulator. The MarieSimulator 2 subdirector contains all of the (many) other classes required for simulator operation. (The Meta-inf subdirectory is created by jar.) If you also wish to see MARIE's source code, you can obtain the MarieSource.jar file that contains all of the Java source for the Marie simulator. This file is uncompressed in the same way as the simulator jar file: jar xvf MarieSource.jar The java source will be uncompressed into the same directories as the class files. To run the MARIE machine environment, the java classpath must be set to point to the directory where the MarieSim1.class file is located. For example, if your classpath is C:\jdk1.5.0_10, and you have located the MarieSim1.class file in a directory named C:\marie, you must change your classpath to C:\marie. Within a Windows environment, you do this by using the SET command (set CLASSPATH=C:\marie). In a Linux/Unix environment, the .cshrc file contains the classpath. (Check with your system support staff if you are unsure as to how to change this file.) Figure 1: The MarieSim Graphical Environment 3 The MARIE simulator environment is invoked using the command: java MarieSim1 within the directory that contains the MarieSim1.class file. (Note: This command is case sensitive!) Note: On some machines, you may have to also compile the source before the simulator will run properly. You do this through the command: javac MarieSim1.java from the source directory where MarieSim1.java is located. The MarieSim Environment Figure 1 shows the graphical environment of the MARIE machine simulator. The screen consists of four parts: a menu bar, a central monitor area, a memory monitor and a message area. The central monitor area contains a program monitor area, six of MARIE's seven registers, and an output area, representing MARIE's seventh register. The memory monitor area displays the contents of all 4096 addresses of MARIE's memory. Each horizontal row of the memory area contains 16 memory addresses. Therefore, the address labels at the left side of the memory area are given in increments of 16, with titles above each column indicating the offset from the memory address of each row of memory. For example, the memory address DE8 is found in the column labeled +8 of the row labeled DE0. All addresses are given in hexadecimal. As the simulator executes your program, the instructions in the program monitor area are highlighted along with any memory in the memory area that the instruction is accessing. These highlights are most visible (on a fairly "fast" system) when you set a 500 millisecond (or greater) delay between instructions. (See below). With a little experimentation, you will find an optimal value for your system. During the course of executing your program instructions, status messages may appear in the message area at the bottom of the screen. When your program ends, you will see either a "Program halted normally" or "Program halted abnormally" message. If you never see this message, either your program hasn't started running yet, or it is in a loop and you'll need to halt it manually. The MarieSim Controls Menu The menu at the top of the simulator gives you control over the actions and behavior of the MARIE machine Simulator system. The File Menu The features available through the File menu are shown in Figure 2 If you already have an assembled MARIE program at your disposal, all you need to do is load it and run it. If you want to write a program from scratch, you should select the File | Edit option. The Edit option gives you a simple way to write and assemble programs in MARIE assembly language. 4 Figure 2: MarieSim File Menu Options Although you can use any plain text editor (perhaps one with fancier features) to create your source code, the simulator's built-in editor gives you one-button access to the assembler. The MARIE editor frame is shown in Figure 3. Figure 3: The MarieSim Editor 5 The MARIE Editor Once you select File | Edit, and if you do not have a file loaded in the simulator (as shown in Figure 3), the editor frame is displayed with a blank text area. If, however, you have already loaded an assembled file into the simulator, the source code for that file is automatically brought into the editor if the editor can locate it. MARIE assembly code source files must have an ".mas" extension, for MARIE Assem- bler. Both the editor and the assembler recognize files of this type. Once you have saved a file with an ".mas" extension, the Assemble menu option becomes enabled and you can assemble your program by selecting the Assemble current file menu pick. If you load an existing ".mas" file, the Assemble button is automatically enabled. Any modifications that you have made to your assembly-language file are automatically saved by the editor prior to its invoking the assembler. This process is shown in Figure 4, using the example from Table 4.5 in the text. Figure 4: Preparing to Assemble Source Code If the assembler detects errors in your program, the editor sends you a message and the assembly listing file appears in a popup frame as shown in Figure 5. All that you need to do is correct your program and press the Assemble current file button once more. If the file contains no other assembler errors, you will see the screen shown in Figure 6. If you wish, you can display or print the assembly listing file, by using the editor or any text- processing program. The listing file will be placed in the currently-logged directory, along with the "MARIE machine code" file, if assembly was successful. The listing file is a plain-text file with an ".lst" extension. For example, when Fig4_5.mas is assembled, the assembler produces Fig4-5.lst. You may view it, print it, or incorporate it into another document as you would any plain text file. If assembly is error-free, a ".mex" or MARIE EXecutable file 6 will also be placed in the same directory as the source and listing files. This is a binary file (actually a serialized Java object) that is executable by the simulator. Figure 5: An Unsuccessful Assembly For example, if your assembly source code is called MyProg.mas, the listing file will be called MyProg.lst and uploads/Industriel/ marie-guide.pdf
Documents similaires










-
50
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Jan 03, 2021
- Catégorie Industry / Industr...
- Langue French
- Taille du fichier 0.2563MB