DCSPMCompilerV6c

advertisement

Abdullah Sheneamer 2012

Appendix C:

-

How to use DCSPM Compiler

: you can find DCSPM Compiler in

“ http://walrus.uccs.edu/~gsc/pub/master/asheneam/

This Appendix describes how to use DCSPM Compiler.

1 Main Screen: you have three options to compile your code to MSI: a.

You can write Pascal code in the input text. b.

Click “Write the code” button and then write your code and save it. c.

Click the “Browse” button to choose a file as shown in Figure C2.

Figure C1: Main Screen

In the main screen as shown in Figure C1. When you would like to compile your Pascal code you should click on “Compile” Button then, after DCSPM finished compiled your Pascal code, it will

1

Abdullah Sheneamer 2012 generate MSIL.il file and show MSIL screen with the MSIL code of your Pascal code. Figure C3 shows il file generated. You find your MSIL.il file in the same directory of DCSPMcompiler.exe.

If you would like to delete what you wrote in input text, you should click “Clear” button. When click “Exit” the button, you will close your program. When click “If statement Improvement” button after writing if/else statement, you will get the same screen in Figure C3.

Figure C2: Browse Screen

2

Abdullah Sheneamer 2012

Figure C3: MSIL Screen

3

Abdullah Sheneamer 2012

-

How to Test Pascal Code

I have tested nine programs which have different lines such as 11, 22, 33, 44, 55,

66, 77, 88, 99 lines. I did three kinds of test. First test is lexical analysis test. Second test is parser test. Third test is between initial nested if/else statement and improved nested if/else statement.

1Lexical Analysis phase Test

You have to write your Pascal program in main screen see Figure C1. When you click

“Compile” the button which is in main screen, DCSPM will generate the MSIL screen which has two speeds time between using array list and dictionary in the left of the screen such as in Figure C4.

The time speed of lexical analysis is using array list data structure

The time speed of lexical analysis is using dictionary data structure

Figure C4: Time Elapsed of Arraylist and Dictionary

4

Abdullah Sheneamer 2012

I used this code below to test speed of lexical analysis which using array list for symbol table:

System.Diagnostics.

Stopwatch stopwatch = new System.Diagnostics.

Stopwatch ();

Stopwatch stopwatch = new Stopwatch ();

Stopwatch.Start(); lex(); stopwatch.Stop(); speed = "Time Elapsed of Lexical Analysis: " + Elapsed.TotalMilliseconds + "ms" ;

And the code to test the speed of lexical analysis which using dictionary data structure for symbol table:

System.Diagnostics.

Stopwatch stopwatch = new System.Diagnostics.

Stopwatch ();

Stopwatch stopwatch = new Stopwatch ();

Stopwatch.Start();

Improvedlex(); stopwatch.Stop(); speed = "Time Elapsed of Lexical Analysis: " + Elapsed.TotalMilliseconds + "ms" ;

More details about the code see section 5.2 Evaluation and performance.

2Parser phase test

I used the same approach of lexical analysis phase test. I used the same code but I put parser() function instead of lex() function such as the code below:

System.Diagnostics.

Stopwatch stopwatch = new System.Diagnostics.

Stopwatch ();

Stopwatch stopwatch = new Stopwatch ();

Stopwatch.Start(); parser(); stopwatch.Stop(); speed = "Time Elapsed of Parser: " + Elapsed.TotalMilliseconds + "ms" ;

5

Abdullah Sheneamer 2012

3Initial nested if/else statement MSIL and improved nested if/else statement MSIL

I tested initial and improvement if/else MSIL results which are generated in il file by

DCSPM compiler. I created a batch timer.cmd file to calculate time of MSIL results such as the code below:

@echo off echo %time% < nul cmd /c %1 echo %time% < nul

After writing your Pascal program in main screen see Figure C1. When you click

“Compile” the button which is in main screen, DCSPM will generate the MSIL and produce MSIL of your program in a file such as NameOftheProgram.il.

After producing your program MSIL, you should compile your file.il such as in Figure C5

Figure C5: ILASM Command

There is another way to compile your program to MSIL , then compile and run your program

MSIL by using this command “ Compiler.exe NameOfProgram.pas “ , then run your program

MSIL “ilasm NameOfprogram.il” such as in Figure C6

6

Abdullah Sheneamer 2012

Figure C6: How to compile your program and compile your Program to MSIL

When you finished compiling file.il by using ILAsm my .il file, then it will produce the exe with the same name as that of .il file. You should use the command in cmd: timer myfile.exe. To test your program of either initial if/else or improved if/else MSIL results such as in Figure C7. After getting times, you should subtract end time with start time such as end time – start time = 13:52:02.48 – 13:52:02.29 = 19 ms.

Download