progress report.pdf

Upload: geetika-malhotra

Post on 05-Apr-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 progress report.pdf

    1/15

    PROGRESS REPORT

    emuARM

    ARMv5 Emulator machine

    Geetika Malhotra 079-1643208, B.Tech. (cse) 8th semester, USIT, GGSIPU

    3/12/2012

    UNIVERSITY SCHOOL OF INFORMATION TECHNOLOGY

    GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY

    PROJECT MENTOR(Mrs. Kamaldeep Kaur)

  • 7/31/2019 progress report.pdf

    2/15

    2

    Index

    1. PROJECT OBJECTIVE 3

    2. SUMMARY 4

    3. ACTIVITIES AND PROGRESS 6

    3.1 Fully developed error reporting module 6

    3.2 Enhanced editor IDE with line numbers and title repainted tabbed pane 8

    3.3 Status window 11

    3.4 Tree view of Project 11

    3.5 Intermediate machine code 12

    3.6 Provision of choice of language for display of register and memory storage values 12

    3.7 Syntax Highlighter module 13

    3.8 New Tool Bar and Home Page 14

    4. NEXT STEPS 15

    5. REFERENCES 15

  • 7/31/2019 progress report.pdf

    3/15

    3

    emuARM, an ARM Emulator machine

    Report compiled by Geetika Malhotra, B.Tech. (cse) 8th semester, USIT, GGSIPUReporting period 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 likedisplaying 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 taskof 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 frontend. Front end then displays the error report on the screen to help the user to rectify the same. Asa 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 beintroduced 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. Study ARM architecture2. Provide ease of creating new assembly file using the IDE.

    3. Store all the files in proper format onto the hard disk.

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

  • 7/31/2019 progress report.pdf

    4/15

    4

    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 willinput 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 willhelp 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 anongoing 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 entirelychanged 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 readyto use. The updates come up on the status window. A new tabbed pane is developed so that

  • 7/31/2019 progress report.pdf

    5/15

    5

    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 eachtab 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 isdone 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 forexecution. 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:

    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 registerupdates 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 binarylanguage. 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 comment3. 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 inassembly language, every comment start with a ;. So, we tokenize the statement with semi-

    colon (;) as the separator and obtain the instruction as the first token. After separating theinstruction from the comment, this reduces to case 3.

    Execution of the instruction

    Check if condition is true Execute the instruction Update flags if S bit is set

    Tokenize every instruction

    Execute shift operation (if

    required)

    Pass the instruction to the

    hash table

    Get appropriate interface

    for its execution

    Pass 2

    Scan the program line by line Separate comments and blank lines

    Pass 1

    Scanning the file Preparing symbol table for all the labels

  • 7/31/2019 progress report.pdf

    6/15

    6

    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 allowsthe 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 orload. 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 variable-sized 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 theappropriate 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 statusbar 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 areused. 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:

  • 7/31/2019 progress report.pdf

    7/15

    7

    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 scannedline 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 listedon the status window. Following screenshot illustrates the same:

    In the initial version of this project, whenever any error occurred while parsing theprogram, 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 thatdialog box:

  • 7/31/2019 progress report.pdf

    8/15

  • 7/31/2019 progress report.pdf

    9/15

    9

    As we can notice from the screenshot, the editor pane is now having line numbers whichhelp 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 sametime. 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 sameirrespective 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, thereshould 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:

  • 7/31/2019 progress report.pdf

    10/15

    10

    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 adefault document created for it. A PropertyChange event ("editorKit") is always fired

    when setEditorKit is called.

    public void setTabComponentAt(int index, Component component) function Sets thecomponent 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-nullvalue means the component will render the title and JTabbedPane will not render the titleand/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.

  • 7/31/2019 progress report.pdf

    11/15

    11

    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 developedby 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 itsscreenshot.

    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 thatare 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.

  • 7/31/2019 progress report.pdf

    12/15

    12

    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 isuseful 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 thetop 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. Thedeliverable 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 thisemulator 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 operandvalues to the selected mode. Following screenshots shows the data in decimal mode:

  • 7/31/2019 progress report.pdf

    13/15

    13

    7. Syntax Highlighter module

    I have started studying for the building of this module. It will add to the ease of theprogrammer. 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 theidentifiers 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.

  • 7/31/2019 progress report.pdf

    14/15

    14

    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:

  • 7/31/2019 progress report.pdf

    15/15

    15

    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 application3. Preparing deliverable files having machine code and other metadata

    4. Preparing list file having details of operands used in the instructions5. Testing the validity of the parser by comparing the results with the6. Completing with the instruction set of ARMv5

    References

    1. David A. Patterson, John L. Hennessy, Computer Organization and Design, ARM Edition2. Designing a Swing GUI in NetBeans IDE: http://netbeans.org/kb/docs/java/quickstart-

    gui.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.