logo Use SA10RAM to get 10%* Discount.
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

Paramjeet KaurManagement

742 Answers

Hire Me
Narender PatelMathematics

981 Answers

Hire Me
Carlos HowarddEconomics

967 Answers

Hire Me
Marilyn DruetttEngineering

563 Answers

Hire Me
Computer Science

In this project, you will complete two utility functions that will be useful for processing the input for a disassembler You will also complete a test driver to test your two functions.


Project: Disassembler Utility Functions (Phase 1, 1/3 of final project)

In this project, you will complete two utility functions that will be useful for processing the input for a disassembler (in phase 2). You will also complete a test driver to test your two functions. (A test driver is the main function written to "drive" tests of other functions.)

Get started:

The goal of the project is to gain more familiarity with C by writing some useful functions for a future programming project.

Download the code in zip file.

Files description:


Test driver, with main function


Utility function 1, used to verify the input format


Utility function 2, convert input bin to dec


indicates how to compile both this program and the future disassembler program


A simple input test file


A header file


processes command-line arguments passed to the main function; used in test driver


A header file for the following two print functions


Prints debugging messages, used in test driver


Prints error messages, used in verifyMIPSInstruction


Will be used in phase 2


Will be used in phase 2

The Makefile contains information for the make command, telling it how to compile this program (and the future disassembler program). Check the contents of Makefile to understand its structure. To compile this program, type make disUtil at a command-line prompt.


The make command will create a compiled executable called disUtil. You can run your program by typing its name at the command line. It takes two optional parameters: a filename and an integer 1 if you want to turn on debugging. If you run the program with the minimalist starter test file provided above, you'll see that for now it just prints the contents of the test file with a line number inserted at the beginning of each line.

./disUtil testfileStarter.txt

./disUtil testfileStarter.txt 1

Compare the test file with your output and then modify the test file and run the program again to verify its behavior. Test the program with and without the second parameter, 1.

Project description

The input file for the disassembler we will write shortly will contain strings representing MIPS instructions, one per line. Actual MIPS instructions would be stored in 32-bit integers; instead, our file will contain lines of 32 characters ('0' or '1'), where each line represents the 32 bits in a machine language MIPS instruction.


The purpose of the functions you are completing in this project is to read in the strings representing MIPS instructions, make sure they are valid, and decode subsets of the instructions in decimal format.



The main function in the test driver (disUtilDriver.c) currently reads lines in from a file until reaching the end of the file. If the line ends with a newline, the program strips the newline from the string by replacing it with a null byte. The code that is missing should call verifyMIPSInstruction to verify that the format contains a MIPS instruction in the proper format or print an error if it does not. If the instruction is valid, main should call binToDec several times, with various parameters, to test it effectively and print the results. (Until you have completed the missing code in binToDec, a single call will be a sufficient test.)

The verifyMIPSInstruction function should verify that the string provided to it is 32 characters long and that the characters in the string are all 0's or 1's (character '0' or character '1'). If the instruction is valid, verifyMIPSInstruction should return 1. Otherwise, it should print an error message indicating the error and the line on which it occurred before returning 0.

Test your modifications before going further by adding appropriate data to the existing test file or by creating new data files. Be sure to include tests cases that exercise every path through your code as well as all appropriate boundary conditions (e.g., empty lines, too-long lines, invalid data in the first / last positions, etc.).



The binToDec function should interpret a substring of characters in an array as a binary number, convert it to an integer in decimal format, and return the integer. The first parameter is the array of characters; the second and third parameters are the beginning index and ending index of the substring. For example, assume A is a character array that contains the following characters.

       1 0 1 1 0 1 0 0 1

The call binToDec(A, 2, 5) should convert the string of binary digits '1' '1' '0' '1' (the substring A[2] - A[5], inclusive) to the decimal integer 13 and return it. One efficient solution involves building the decimal number from the least significant digit to the most significant digit by adding in (or not) the appropriate power of two. Rather than calculating the power of two for each digit, you can store the power of two in a variable and multiply it by two when you go to the next digit. (What should the power-of-two variable be initialized to for the least significant digit?)

To test binToDec thoroughly, you should call it in a number of different ways whenever the instruction format is valid. Think particularly about what kinds of boundary conditions you should test for.


The Makefile I have provided specifies a set of compiler options that will help you catch many errors at compile time. These options generate warnings about questionable constructions that often indicate programmer confusion or actual logic errors. You may have to make adjustments to the Makefile, though, if the specific options or option names for your compiler are somewhat different.


Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

299 Experts Online