Sei sulla pagina 1di 15

PROGRESS REPORT

emuARM
ARMv5 Emulator machine
Geetika Malhotra 079-1643208, B.Tech. (cse) 8th semester, USIT, GGSIPU 3/12/2012

PROJECT MENTOR (Mrs. Kamaldeep Kaur)

UNIVERSITY SCHOOL OF INFORMATION TECHNOLOGY GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY

Index

1. 2. 3. 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 4. 5.

PROJECT OBJECTIVE SUMMARY ACTIVITIES AND PROGRESS Fully developed error reporting module Enhanced editor IDE with line numbers and title repainted tabbed pane Status window Tree view of Project Intermediate machine code Provision of choice of language for display of register and memory storage values Syntax Highlighter module New Tool Bar and Home Page NEXT STEPS REFERENCES

3 4 6 6 8 11 11 12 12 13 14 15 15

emuARM, an ARM Emulator machine


Report compiled by Reporting period Geetika Malhotra, B.Tech. (cse) 8th semester, USIT, GGSIPU Jan-Mar 2012

Project Objective The main objective of this project is to build a tool to run ARM based assembly language programs on any platform. This emulator machine will have an enhanced editor in the front end to accept the assembly language programs. This editor will have many advanced features like displaying line numbers on the editor pane, having the facility to open multiple tabs simultaneously. Other than the editor pane, the front end will have menu bar, tool bar, status window, tree view of the current working directory and the status window showing the values held by various register or memory. The front end will also display the branch table. It is the task of the front end to save the assembly file and send it to the backend for executing and preparing other deliverables. In case any error comes up, the backend will send an error report to the front end. Front end then displays the error report on the screen to help the user to rectify the same. As a deliverable, the backend produces the intermediate machine code which it saves as a separate file and also displays on the binary window if the user selected that option. Along with the execution option where the entire program gets executed in one go, another option will be introduced where there will be a facility of step by step execution of the code. With this option, one can see the register and memory updates after the execution of each instruction. It will also help in seeing the flow of control with branch instructions. The emulator machine will come along with a user manual and help file to work with the toolkit very easily and simple way. The features of this project are listed as follows: 1. 2. 3. 4. Study ARM architecture Provide ease of creating new assembly file using the IDE. Store all the files in proper format onto the hard disk. Provide Suitable File options which help to retrieve data from the disk and store onto it. Options include Open a file, Save, Save as etc. 5. Execution of the instructions and displaying the results. 6. Display contents of the register set after the execution of each and every instruction. 7. Display the updates made to the flags on the execution of the instructions. 8. Display the contents of the branch table listing all the labels present in the code along with their line numbers. 9. Display the contents of the memory. 10. Provide Editing facility of Cut, Copy, Paste etc. 11. Proper implementation of the instructions in accordance with the architecture of the processor. 12. Completion of all data processing, shift, branch, access of status register, load and store instructions in the backend.
3

13. Execution of barrel shifter. 14. Provide a user friendly environment.

Summary It is a Java based emulator software which runs all the ARMv5 assembly language programs. This project involves the study of the ARM architecture and its instruction set. An emulator is hardware and/or software that duplicates (or emulates) the functions of a first computer system in a different second computer system. The software system has an editor as the front end and will input the assembly language program. The backend executes the program. The ARM emulator will provide an aid to the ARM programmers to run their programs on their computers and debug them before porting the codes to the target machine. The emulation of the ARM processor will help the professors to teach computer architecture course in a similar fashion like they did using SPIM simulator for MIPS processor. The software will provide a graphical user interface to the users to code for ARM processors easily and efficiently. By showing the status of all the registers at the time of running will help make the debugging and understanding easy. From the beginning of this semester till now, many new modules for this project are developed. This is an ongoing project which I continued from my minor project. A certain set of instructions were covered in the minor project with a small utmost necessary UI system. The situation has entirely changed now. The graphical user interface is much more enhanced and several new add-on facilities are put onto it for making the experience more user-friendly. The front end looks like this:

Along with that the error reporting module for the code is prepared. As we all know that doing spelling mistakes is a very common thing. Other than that, a compiler (or similar) should be able to point out the syntactical errors very easily. In order to get rid of the same, this module is ready to use. The updates come up on the status window. A new tabbed pane is developed so that
4

multiple files can be opened at the same time. This project has its user interface in Java Swing. The pre-built jTabbedPane of Java Swing does not come with a close button on the title of each tab which had to be painted separately along with icons and the title of the file. The provision for the binary file i.e. the machine code for the corresponding assembly program is under-progress. Modifications are made on the working of the backend of the project. Care is taken to reduce the number of unnecessary warnings and errors creeping up. More secure and strict type checking is done to ensure that the hash table passes the control to the proper interface. The functioning of the backend is illustrated in the following paragraph that follows. It is a java based application. The editor at the frontend will let the user to enter the code for execution. When the assembly file is created and is made to run, the frontend passes the file to backend where it is tokenized and executed line by line. The block structure of the application is as follows:
Pass 1 Scanning the file Preparing symbol table for all the labels

Pass 2 Scan the program line by line Separate comments and blank lines

Execute shift operation (if required)

Tokenize every instruction Pass the instruction to the hash table Execution of the instruction

Get appropriate interface for its execution

Check if condition is true

Execute the instruction

Update flags if S bit is set

emuARM is a microprocessor emulation application. It will execute the instructions given to it in the form of the assembly file and execute it. After the execution, it will provide the register updates and show the details to the user. Current status of the flag register as well as all the 16 registers will be displayed. It scans the program code line by line and executes the instructions. It directly executes the instructions from the assembly language without going into the binary language. The technical details involved in the building of backend are explained as follows: On reading the file from the disk, it is scanned line by line. As we know there can be only a single instruction at each line, every scanned line can be one of the following: 1. A blank line 2. A comment 3. An instruction 4. An instruction followed by a comment We have to ignore the first two cases and move ahead with the next scans of the code. Actual work begins when there is either case 3 or case 4. Lets look at case 4 first. As we know that in assembly language, every comment start with a ;. So, we tokenize the statement with semicolon (;) as the separator and obtain the instruction as the first token. After separating the instruction from the comment, this reduces to case 3.
5

Now, the actual processing of the instruction begins. In an ARM processor, we have something called as a barrel shifter. Having a barrel shifter other than the ALU unit of the processor allows the programmers to perform shift operations in conjunction with other processing operations. Like we can perform left shift as well as add operation in a single operation. First of all, we check whether any shift operation is to be performed on the operands or not. If there is a shift operation, than we execute the operation first and update the corresponding register value. Coming back to our x86 architecture, there we had conditional branch instructions, i.e., we executed the branch operation if the stated condition is true. In ARM microprocessor, we can conditionally execute almost every instruction whether it is addition, subtraction, branching or load. Each instruction in this sense gets variations like ADD, ADDEQ, ADDNE etc. After the execution of barrel shift, the instruction is passed on to a hash function. A hash function is any well-defined procedure or mathematical function that converts a large, possibly variablesized amount of data into a small datum, usually a single integer that may serve as an index to an array .The values returned by a hash function are called hash values, hash codes, hash sums, checksums or simply hashes. On passing the name of the instruction to the hash function, we get the instance of the class from where that instruction will get executed. The instruction along with the operands is sent to the appropriate interface from where the call gets mapped to the required class where the execution of instruction takes place. Flags are updated if the S bit is set.

Activities and Progress 1. Fully developed error reporting module We come across syntactical errors while parsing. In this project, when we catch errors due to improper syntax, we raise exceptions and show the descriptive error details on the status window. In this way, the user gets an idea about the line number of the error along with a hint about the nature of the error. Following screenshots illustrate the way status bar show the nature of the syntactical errors:

Here, line numbers come up along with the nature of the error. In order to find the error in parsing, intensive use of exception handling and string manipulation functions are used. Strict usage of the syntax of the assembly language is taken care of. Like for example every addressing mode of an operand should start with [symbol failing which incurs an error. Following screenshot illustrate that error:

Similarly, other cases are taken cared. Several kinds of exceptions helped in finding the errors. IndexOutOfBounds exception helped in casting an error when program used any register out of its given 0-15 range. Following screenshot illustrate that:

Error handling started in initial stages only. In the backend, when the program is scanned line by line and the scanned line is tokenized. Every token of the line is checked if it is valid or not. The very first check is done at the time of emitting the command to its proper interface by the hashtable. Now, if the command is not a valid one than the control does not move further for the execution of the scanned line. Error is caught and is listed on the status window. Following screenshot illustrates the same:

In the initial version of this project, whenever any error occurred while parsing the program, then, all execution was stopped and an error dialog box was displayed showing that a message that some error occurred while parsing the program. No hint about the nature of the error or the line number was displayed. Following screenshot shows that dialog box:

Other than that, there was no line number display in the initial editor pane. As there was very less user friendly environment, working in that user interface was a difficult experience. Following screenshot shows the old interface:

2.

Enhanced editor IDE with line numbers and title repainted tabbed pane Whenever we write programs for any programming language, having line numbers in the editor pane helps us to track any statement easily. Other than that, it is not possible to track errors without line numbers in the program. The new editor pane is having line numbers on the left hand side. Other than that, the editor pane is tabbed. By being tabbed, we can have multiple files open at the same time. This provides an ease to the programmer. Following screenshots display the new features of the editor:

As we can notice from the screenshot, the editor pane is now having line numbers which help us in easy tracking of bugs while typing. We can denote errors by line numbers and the programmer need not count lines in order to reach to the error. Along with that, the new editor pane is now tabbed in nature i.e. we can have multiple files open at the same time. Note here that, even if many files are open at the same time but the status of the registers and memory is same for all and preserved for everyone. No different set of register set is there. It is so because in a processor, the register set remains the same irrespective of the number of programs currently active on the system. Java swing comes with a jtabbedpane but it does not have a close button on the title of its tabs. Note that if we give the provision to open multiple files at the same time then, there should be a facility to close those files that are not required now or have finished execution. Below is its screenshot.

In order to integrate the newly built codes for the numbered editor pane and the one for the new title of the tabbed pane, following code snippet is used:
9

Here, these two pre-defined functions were quite helpful in integration purpose. JEditorPane txt = new JEditorPane(); txt.setEditorKit(new NumberedEditorKit()); Editor.setTabComponentAt(countOpened, new ButtonTabComponent(Editor));

public void setEditorKit(EditorKit kit) function Sets the currently installed kit for handling content. This is the bound property that establishes the content type of the editor. Any old kit is first deinstalled, then if kit is non-null, the new kit is installed, and a default document created for it. A PropertyChange event ("editorKit") is always fired when setEditorKit is called. public void setTabComponentAt(int index, Component component) function Sets the component that is responsible for rendering the title for the specified tab. A null value means JTabbedPane will render the title and/or icon for the specified tab. A non-null value means the component will render the title and JTabbedPane will not render the title and/or icon. Note: The component must not be one that the developer has already added to the tabbed pane. There is still an issue in the editor pane. When numerous panes get opened than some part of the user interface goes out of the view. To solve this problem, I will add scrolls near the borders of the window. Following is the screenshot.

10

3.

Status window The newly developed status window of the user interface tells about the task that the emulator is performing like when the emulator is opening a file or saving any file. It tells when any error occurs while accessing the file for opening. All the error listing developed by the error handling module are listed on this status window. Hence, this status window has multiple functions. In case any error arises while running the file, it tells us that the build has failed and gives the list of errors along with the line numbers. Below is its screenshot.

4.

Tree view of project This module is not yet integrated with the main project. It will tell about the files present in the current working directory. Files could be opened directly from that directory structure. This is a nice way to interactively open files and display the current files that are present in the working folder. Below is the screenshot.

Note here that this is a general view of how this module will look like. At the time of integration, this module may undergo some changes.
11

5.

Intermediate Machine code A new option in the execute menu of the menu bar is introduced. Here, there is a facility to convert the assembly code into its corresponding machine language code. This is useful for teaching purposes where students can track the binary equivalent of a command using this module. This module displays the binary equivalent in a new read only editor pane with line numbers and some options for traversing through the file at the top of that new pop up window. This intermediate code can also be stored to a file if required. As a separate file is prepared, this is part of the deliverables when the code is executed. Following is the window which will show the binary file:

Note that the back end work of the binary file creation is not yet complete. The deliverable and the display of the binary file will be done very soon as and when the back end coding of the binary conversion will be completed.

6.

Provision of choice of language for display of register and memory storage values It is human mind set to follow decimal number system. But as we know that machine language is made up of 0s and 1s. Computers follow binary number system. In this emulator machine, by default the data that is displayed will be in decimal number system. But if we wish to see the data in hexadecimal or binary then, we can switch to binary or hex mode. Changing to other mode will convert all register values and memory operand values to the selected mode. Following screenshots shows the data in decimal mode:

12

7.

Syntax Highlighter module I have started studying for the building of this module. It will add to the ease of the programmer. It is a general features with the editors of IDE that the keywords, identifiers and literals come in different colours. It helps the user to distinguish between the same. This module will have a flex file integrated with the java code. The flex files are used to build a lexical analyzer. This flex file will have the details about the nature of the identifiers and literals. Along with that, it will have the list of the keywords. This list of keywords will be matched as it is while typing the program. Any match will result in the change in colour of that word. This module is not yet coded.

13

8.

New Tool Bar and Home Page Following is the screenshot of the new tool bar introduced in the front end:

The screenshot for home page is:

14

Next Steps Future steps are listed as follows: 1. Building a new parser machine from where the program can get executed line by line. 2. Building the help manual for the application 3. Preparing deliverable files having machine code and other metadata 4. Preparing list file having details of operands used in the instructions 5. Testing the validity of the parser by comparing the results with the 6. Completing with the instruction set of ARMv5 References 1. David A. Patterson, John L. Hennessy, Computer Organization and Design, ARM Edition 2. Designing a Swing GUI in NetBeans IDE: http://netbeans.org/kb/docs/java/quickstartgui.html 3. ARM information center: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406b/index.html 4. Mark Loy, Robert Eckstein, Dave Wood, James Elliot, and Brian Cole Java Swing, Second Edition, 1998, OReilly and Associates.

15

Potrebbero piacerti anche