代做数据结构、数据结构编程帮做、代写Programming at the Hardware-Software Interface

CSI 333 – Programming at the Hardware-Software Interface Project III The total grade for the assignment is 100 points. You must follow the programming and documentation guidelines (see file Programming Assignments Requirements and Recommendations.docx). This is a team project (except for those students who have opted to work on their own). Group of two students may work on this project together. Due date: EOD before Lab Class #11. Description: You are required to write a C program  whose input is a MIPS Assembly Language (MAL) program and  whose output is a listing of the MAL program with line numbers and/or a cross-reference table for the MAL program. Details regarding MAL programs and the contents of cross-reference tables are given below. Command Line Details: Suppose the executable version of your program is named prog3. The program will be executed by a command line of the following form. prog3 flag inputfile outputfile In the command line above, the arguments inputfile and outputfile specify the names of the input file (which contains a MAL program) and the output file respectively. A valid flag argument is one of -l, -c or -b.  If the flag is -l, your program must produce only a program listing of the MAL source program in the specified output file. (Program listing is a source code with line numbers for every not blank line).  If the flag is -c, your program must produce only the cross-reference table for the MAL source program in the specified output file. (Cross-reference table is a list of identifiers that specifies the line number where the identifier is defined and the lines where it is usedd.)  If the flag is -b, your program must produce both the listing and the cross-reference table in the specified output file. 2 Details Regarding MAL Programs: 1) Each line of a MAL program may be (a) a blank line (containing only white-space characters), (b) a comment line (a line that starts with the character ’#’) or (c) a MAL statement which has the following fields separated by one or more spaces or tabs: i) an optional label field terminated by ’:’, ii) a mandatory opcode field, iii) an optional operand field consisting of zero or more operands separated by commas, and iv) an optional comment field starting with ’#’. 2) Every line of a MAL program is terminated by the newline (’\n’) character and has at most 80 characters (including the newline character). 3) Any line that has ’#’ as the first character is a comment line. 4) The labels start from the first position, thus, a line that starts with a space or tab does not have a label.) The maximum number of labels that can appear in any MAL program is 100. 5) The first character of any identifier is a lower- or upper-case letter or the underscore character followed by zero or more upper/lower case letters, digits or underscore characters. The identifiers are case sensitive. (Thus, Val and val represent different identifiers.) The maximum length of an identifier is 10. 6) Opcodes are not identifiers. Also, operands starting with the symbol ‘$’ are not identifiers; they represent registers of the MIPS machine. 7) If the operand field of a MAL program starts with the single quote character (’) or the double quote character (&"), then the operand field does not have any identifiers. (The reason is that an operand field starting with the single quote specifies a literal character; an operand field starting with the double quote character specifies a string.) 8) An identifier in a MAL program: (a) is defined in the source line where the identifier appears as a label and (b) is used in lines where it appears in the operand field. Examples: iloop_beg: la $7,arr #Get address of arr into register 7. In the above, the label field has the identifier iloop_beg. The opcode field has la. The two operands are $7 (a register – not an identifier) and arr (an identifier). The operand field is followed by the comment field that starts with the # character. The above statement defines the identifier iloop_beg and uses the identifier arr. loop: sw $15,avg #Store reg. 15 3 In the above instruction, the label is loop, the opcode is sw and the operands are $15 and avg. The instruction defines the identifier loop and uses the identifier avg. A cross-reference table for a MAL program indicates for each identifier, the line number in the source program where the identifier is defined and the line number(s) in the source program where the identifier is used. An example of a MAL program and its cross-reference table are shown below. Be sure to study the example given below before writing your program. Suppose the file example.mal contains the following MAL program. #A sample MAL program. .data #Data segment begins here. avg: .word #Will store the average. i1: .word 20 #First integer. i2: .word 13 #Second integer. i3: .word 82 #Third integer. prompt: .asciiz &"Value is: &" nl: .byte ’\n’ .text #Text segment begins here. __start: lw $15,i1 #$15 contains 20. lw $16,i2 #$16 contains 13. i10: add $15,$15,$16 #Operand field has no ids. lw $16,i3 #$16 contains 82. add $15,$15,$16 #$15 contains the sum (115). li $16,3 #$16 contains 3. div $15,$15,$16 #$15 contains the average (38). i20: sw $15,avg #Store the average. puts prompt put avg putc nl sw $15,avg la $16,i1 sw $15,0($16) add i3,i3,1 done #Similar to halt. 4 After the execution of the program using the command line prog3 -b example.mal output.lst the contents of the output file output.lst should be as shown below. In studying the output file, you should keep the following in mind: (a) The line numbers start at 1. (b) Blank lines in the input file are echoed to the output file; however, they are not numbered. (c) For each identifier, the line numbers where it is used are in increasing order. (d) When an identifier is used several times in a source line (e.g. the identifier i3 appears twice in line 24), the line number appears only once in the list. Contents of the file output.lst: 1 #A sample MAL program. 2 .data #Data segment begins here. 3 avg: .word #Will store the average. 4 i1: .word 20 #First integer. 5 i2: .word 13 #Second integer. 6 i3: .word 82 #Third integer. 7 prompt: .asciiz &"Value is: &" 8 nl: .byte ’\n’ 9 .text #Text segment begins here. 10 __start: lw $15,i1 #$15 contains 20. 11 lw $16,i2 #$16 contains 13. 12 i10: add $15,$15,$16 #Operand field has no ids. 13 lw $16,i3 #$16 contains 82. 14 add $15,$15,$16 #$15 contains the sum (115). 15 li $16,3 #$16 contains 3.代做数据结构实验作业、数据结构编程作业帮做、代写Programming at the Hardware-Software 16 div $15,$15,$16 #$15 contains the average (38). 17 i20: sw $15,avg #Store the average. 18 puts prompt 19 put avg 20 putc nl 5 21 sw $15,avg 22 la $16,i1 23 sw $15,0($16) 24 add i3,i3,1 25 done #Similar to halt. Cross Reference Table Identifier Definition Use avg 3 17 19 21 i1 4 10 22 i2 5 11 i3 6 13 24 prompt 7 18 nl 8 20 __start 10 i10 12 i20 17 Programming Suggestions: (a) Data structure to be used: array (of size 100) of struct, where each struct has the following data members: 1) a char array of size 11 (to store an identifier), 2) an integer (to store the line number where the identifier is defined) and 3) a pointer to a linked list; each node of the list stores an integer for the line number where the identifier is used. (b) Don’t assume any limit on the number of lines in the input file. Read the input line by line (using fgets). For each line of the input file which is not a comment line or a blank line, use strtok to parse the line (i.e., extract the various fields of the instruction). (c) All input files will satisfy the following conditions. 1) The MAL program in the input file won’t contain any errors. 2) Every identifier will be defined somewhere in the MAL program. (However, it is possible that an identifier is not used anywhere.) 6 3) There will be no multiply defined identifiers. (d) You need to check only for the usual command line errors (wrong number of parameters on the command line, invalid flag, the input or the output file can’t be opened). In such a case, your program must output a suitable error message to stderr and stop. (e) The input and output file names must NOT be hard-coded into your program. These files names are available to your program as command line arguments. (f) Program must contain several functions in addition to main. (g) It is advisable for each team member to take the responsibility for one of the program’s major components: 1) Processing each MAL statement (e.g. checking if the statement is a comment, a blank line or a MAL statement, identifying the label and/or the identifiers appearing in a MAL statement). 2) Maintaining the data structure that stores the cross-reference information. Submission: You must perform. submissions as directed by your instructor. Submission should include:  source code for the evaluation – the procedure will be explained in your lab classes,  screenshots with program output. For the team project each team must make only one submission. That is, in each team, ONLY ONE member must do this. Team submissions must include additional documentation in the source file as explained below. Important Notes: ignoring any of the following rules will result in penalty or even ZERO grade for the project. 1. For Project 3 you must turn in the file named as directed by your instructor. 2. At the top of your C source file the following information must appear in the form. of comments: (a) Students working by themselves must have the following information at the beginning of your source file in the form. of comments: i. course code and title, ii. semester, iii. your class ID (e.g., ZR160102), iv. your name, v. your student ID, vi. the name of your lab classes supervisor. 7 (a) Students working in a team must have the following information at the beginning of your source file in the form. of comments: i. course code and title, ii. semester, iii. your class ID (e.g., ZR160102), iv. the names of the two team members, v. the student IDs of the two team members, vi. the name of your lab classes supervisor. vii. A clear explanation of how the work for the project was divided among the two team members. Indicate clearly who developed each function and how the testing work was divided between the team members. 3. Make sure that your programs compile and produce correct results on the lab machines. Programs that cause compiler or linker errors on these machines will NOT receive any credit. Some sample data to test your program: Important Note: Some sample inputs that can be used to test your programs are given below. However, you should remember that when we compile and run your source files, we will use other data. Just because your programs work for the sample inputs given below, you shouldnt assume that they will work for all inputs. Therefore, you should test your programs thoroughly with other input values. Test file test1.mal and the corresponding output file test1_output.txt are attached. The file test1.mal represents a sample input file containing a MAL program. The file test1_output.txt is the result of executing the following command where &"prog3&" is the name of the executable version of your program): prog3 -b test1.mal test1_output.txt Since the above command line uses the flag &"-b&", that the file test1_output.txt contains both the listing and the cross-reference table. If we use the flag &"-l&" on the command line above, the output file must contain ONLY the listing; likewise, if we use the flag &"-c&" on the Unix command line above, the output file must contain ONLY the cross-reference table. Program Grading: Programs will be graded by co- instructors. For students working individually: (a) Correctness: 85 points 8 (b) Structure and documentation: 15 points For students working in a team: (a) Correctness: 65 points (b) Structure and documentation: 15 points (c) Team work: 20 points Each team member must participate in developing, documenting and testing the program. Each team should include additional documentation at the beginning of the source file indicating how the work for the project was divided between the two team members. (Indicate clearly who developed each function and how the testing work was divided between the team members.) After the submission deadline, each team must meet with their instructor who supervises the lab classes. During the meeting, the instructor will ask questions about the team’s program and determine the points for team work. (The two team members may receive different scores for team work.) Example of program execution: The content of input file mal_prog.txt: .data x1: .word 80 x2: .word 0 .text begin: lw $15,x1 add $15,$15,x2 sw $15,x1 end: done Suppose we execute the following Unix command: unix2> prog4.out -b mal_prog.txt output.txt The contents of the file output.txt: 1 .data 2 x1: .word 80 3 x2: .word 0 4 .text 5 begin: lw $15,x1 6 add $15,$15,x2 7 sw $15,x1 8 end: done & 转自:http://ass.3daixie.com/2018053140746269.html

你可能感兴趣的:(代做数据结构、数据结构编程帮做、代写Programming at the Hardware-Software Interface)