Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are required to write a C program - whose input is a MIPS Assembly Language (MAL) program and - whose output is a listing

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 prog4.out. The program will be executed by a command line of the following form:

prog4.out 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 -1, -c or -b.

If the flag is -1, 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 used.)

If the flag is -b, your program must produce both the listing and the cross-reference table in the specified output file.

Details Regarding MAL Programs:

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

Every line of a MAL program is terminated by the newline ( ) character and has at most 80 characters (including the newline character).

Any line that has # as the first character is a comment line.

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.

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.

Opcodes are not identifiers. Also, operands starting with the symbol $ are not identifiers; they represent registers of the MIPS machine.

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

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago