Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 5 : [ 4 mark of 1 0 : 1 public / 1 release + secret / 2 secret ] ( filename: asm.c (
Problem : mark of : public releasesecret secret filename: asm.ccpp In this problem, you will write a program that reads a list of mips assembly tokens from standard in will calculate the location of every label, and will substitute a labels location everywhere the label is used. The output of this program is a symbol table on standard error, and a parameter list for compileLine from assignment on standard out. Each numerical parameter must be printed as an unsigned bit decimal number. The symbol table must be printed on standard error. The label's lexeme and its address must be printed on the same line, with the label lexeme first, a space character, then the location in memory as a decimal number. The labels must be in the same order as they are defined. The input to the program is a list of tokens: one token per line, with the token type, a space, the token lexeme, and a unix newline character. The token types are the same as what's defined in Assignment Problem with one addition. The NEWLINE token has been added to delineate new lines from the mips assembly input. The NEWLINE token type doesn't have a lexeme. Consider the mips assembly program: foo: beq $ $ bar bar: add $ $ $ The tokenization of this program is: LABEL foo: NEWLINE ID beq REG $ COMMA comma REG $ COMMA ID bar NEWLINE LABEL bar: NEWLINE ID add REG $ COMMA REG $ COMMA REG $ NEWLINE The output on standard error must be: foo bar The output of the assembler on standard out will be a list of parameters for compileLine one line per call to compileLine, space separated, with no quote characters. The integer parameters can be printed in hex or decimal. Your output cannot contain any labelsit must replace every label use with the label address. For the example input above, the output must be: beq add You are not required to use any of the starter code: you can remove it or change it as you see fit. The correctness of your program is evaluated by checking its output. We are not checking to see if you use compileLine or not. c racket If any errors are present in the tokenized input mips assembly program, your assembler must print ERROR on standard error. It must stop processing input and terminate. Your error message can include a description of the error, at your digression. Each mips instruction will be on only one line. Your assembler is required to handle the word directive. For the line word X your program should output word Y where Y is whatever value X is when interpreted as an unsigned bit decimal number. Two new tools are provided cstokenizer and cscompileline. cstokenizer accepts a mips assembly program and prints a list of tokens suitable for this problem. cscompileline accepts the output of this problem and assembles it into mips machine code. CorrectionsClarifications: Added clarification on how to output word directives June
Problem : mark of : public releasesecret secret
filename: asm.ccpp
In this problem, you will write a program that reads a list of mips assembly tokens from standard in will
calculate the location of every label, and will substitute a labels location everywhere the label is used.
The output of this program is a symbol table on standard error, and a parameter list for compileLine from
assignment on standard out. Each numerical parameter must be printed as an unsigned bit decimal number.
The symbol table must be printed on standard error. The label's lexeme and its address must be printed on the
same line, with the label lexeme first, a space character, then the location in memory as a decimal number. The
labels must be in the same order as they are defined.
The input to the program is a list of tokens: one token per line, with the token type, a space, the token lexeme,
and a unix newline character. The token types are the same as what's defined in Assignment Problem with
one addition. The NEWLINE token has been added to delineate new lines from the mips assembly input. The
NEWLINE token type doesn't have a lexeme.
Consider the mips assembly program:
foo:
beq $ $ bar
bar:
add $ $ $
The tokenization of this program is:
LABEL foo:
NEWLINE
ID beq
REG $
COMMA comma
REG $
COMMA
ID bar
NEWLINE
LABEL bar:
NEWLINE
ID add
REG $
COMMA
REG $
COMMA
REG $
NEWLINE
The output on standard error must be:
foo
bar
The output of the assembler on standard out will be a list of parameters for compileLine one line per call to
compileLine, space separated, with no quote characters. The integer parameters can be printed in hex or decimal.
Your output cannot contain any labelsit must replace every label use with the label address. For the example
input above, the output must be:
beq
add
You are not required to use any of the starter code: you can remove it or change it as you see fit. The correctness
of your program is evaluated by checking its output. We are not checking to see if you use compileLine or not.
c
racket
If any errors are present in the tokenized input mips assembly program, your assembler must print ERROR on
standard error. It must stop processing input and terminate. Your error message can include a description of the
error, at your digression.
Each mips instruction will be on only one line.
Your assembler is required to handle the word directive. For the line word X your program should output word
Y where Y is whatever value X is when interpreted as an unsigned bit decimal number.
Two new tools are provided cstokenizer and cscompileline. cstokenizer accepts a mips assembly
program and prints a list of tokens suitable for this problem. cscompileline accepts the output of this
problem and assembles it into mips machine code.
CorrectionsClarifications:
Added clarification on how to output word directives June
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started