BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

代码代写|COM S 440/540 Project part 6

代码代写|COM S 440/540 Project part 6

这是一篇美国的汇编代码代写

 

1 Requirements for part 6

When executed with a mode of 6, your compiler should read the specifified input fifile, and check it for correctness (including type checking) as done in part 4. If there are no errors, then your compiler should output an equivalent program in our target language (still Java assembly). For this part of the project,your compiler must generate correct code for expressions (from part 5), and for (possibly nested) branching statements and loops. As usual, error messages should be written to standard error, and your compiler may make a “best effffort” to continue processing the input fifile, or exit. Specififically, your part 5 solution should be modifified to include the following.

  • Type checking of conditions (expressions) within if statements, while loops, do-while loops, and for loops: the condition expression should be a numeric type (char, int, or flfloat).
  • Code generation for if statements (with and without else), while loops, do-while loops, and for loops.
  • Code generation for break and continue statements; error messages when they are not within a loop.
  • The Java main() function should not display the return value of the C main() function.

2 Checking your generated code

Ultimately, you should be able to assemble the code generated by your compiler (using the Krakatau assembler) to obtain a class fifile. You can then run this class fifile, just as if it were compiled from Java source. The script CheckR 6.sh is based on this idea:

  1. It fifirst runs your compiler with mode -6 on the C source code. If the instructor solution generates an error message, then the script checks that your compiler generated an error message on the same line.
  1. Otherwise, the script runs the assembler on your compiler’s output.
  2. The script runs the resulting .class fifile on a JVM, with one or more input fifiles (in case the C source calls getchar()) and checks the output.

As with part 5, you will need libc.class, which implements methods putchar() and getchar(), to be present in the same directory.

You can make your own test fifiles, and generate the expected output fifiles obtained by an executable built with gcc, using the -G switch.

3 Grading

For all students: implement as many or as few features listed below as you wish, but keep in mind that some features will make testing your code much easier, and a defificit of points will impact your overall grade.

Excess points will count as extra credit.

For code generation “without short circuiting”, your compilers will be tested using integer variables for the condition. The basic tests for each construct are as follows, where x is an integer variable.

if (x) { /* statements */ }

if (x) { /* statements */ } else { /* statements */ }

while (x) { /* statements */ }

do { /* statements */ } while (x);

for (/* initialize */; x; /* update */) { /* statements */ }

More advanced tests will use an integer expression, or a single comparison as the condition.

Code generation “with short circuiting” will be tested with a variety of conditions (comparisons and numeric values) connected with operators &&, ||, and !.

bestdaixie

评论已关闭。