Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to take as input (via stdin) a valid assignment stateme in C and generate MIPS assembly code to perform the given

image text in transcribed

Write a C program to take as input (via stdin) a valid assignment stateme in C and generate MIPS assembly code to perform the given calculation(s). You can assume that each C variable name is one lowercase letter (e.g., a, b, c, etc.) and of type int. Further, positive int constants are also allowed as part of the given expression. For this assignment, you only need to support the addition (+) and subtraction () operators. Note that you should use isspace O, islower O, isdigit), scanf O, etc. to parse the input. The MIPS code you generate must make use of registers $s0,$s1,.. ,$s7 to correspond to C vari- ables and registers $to,St1,.. .$t9 to correspond to any temporary variables you need. Variables in MIPS should match those in C from left to right, meaning that the final result of the assignment statement must end up in register $s0. You can assume that you will not need more than the specific MIPS registers listed here. Below are a few example runs of your program. In the first example, register $s0 corresponds to C variable f, $s1 corresponds to g, and $s2 corresponds to h. bash$ ./a.out Please enter a valid C assignment statement f g+ h 42; The MIPS pseudocode is: add $to, $s1,$s2 sub $s0,$t0,42 bash$ ./a.out Please enter a valid C assignment statement: The MIPS pseudocode is: sub $t0, $s1,12 add $s0, $t0, $s2 bash$ ./a.out Write a C program to take as input (via stdin) a valid assignment stateme in C and generate MIPS assembly code to perform the given calculation(s). You can assume that each C variable name is one lowercase letter (e.g., a, b, c, etc.) and of type int. Further, positive int constants are also allowed as part of the given expression. For this assignment, you only need to support the addition (+) and subtraction () operators. Note that you should use isspace O, islower O, isdigit), scanf O, etc. to parse the input. The MIPS code you generate must make use of registers $s0,$s1,.. ,$s7 to correspond to C vari- ables and registers $to,St1,.. .$t9 to correspond to any temporary variables you need. Variables in MIPS should match those in C from left to right, meaning that the final result of the assignment statement must end up in register $s0. You can assume that you will not need more than the specific MIPS registers listed here. Below are a few example runs of your program. In the first example, register $s0 corresponds to C variable f, $s1 corresponds to g, and $s2 corresponds to h. bash$ ./a.out Please enter a valid C assignment statement f g+ h 42; The MIPS pseudocode is: add $to, $s1,$s2 sub $s0,$t0,42 bash$ ./a.out Please enter a valid C assignment statement: The MIPS pseudocode is: sub $t0, $s1,12 add $s0, $t0, $s2 bash$ ./a.out

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions