Write a mips program that will read in a base

Assignment Help Computer Engineering
Reference no: EM132101186

Please write MIPS program that runs in QtSpim (ex: MipsFile.s)

Write a MIPS program that will read in a base (as an integer) and a value (nonnegative integer but as an ASCII string) in that base and print out the decimal value; you must implement a function (which accepts a base and an address for a string as parameters, and returns the value) and call the function from the main program.

The base will be given in decimal and will be between 2 and 36, and the digits for the values will be in set [0...9, a...z]. You can assume that no overflow will occur and the value is valid in the given base.

An example run will be:

Enter a base (between 2 and 36 in decimal): 2

Enter a number in base 2: 101

The value in decimal is: 5

The program needs to be able to test 3 different cases and run in QtSpim like a .s file

here is a c program that shows the functionality

#include <ctype.h> #include <stdio.h> #include <string.h> int convert2dec(char *str, int base) { int j, val; val = 0; j = 0; while (str[j] > 13) { if (str[j] > 57) val = val * base + str[j]-87; else val = val * base + str[j] - 48; j++; } return val; } int main(int argc, char *argv[]) { int X; char str[256]; printf("Please the base (in decimal): "); scanf("%d", &X); printf("Please enter a nonnegative number: "); scanf("%s", str); printf("The decimal value is %d.\n", convert2dec(str,X)); return 0; }

Reference no: EM132101186

Questions Cloud

Define and integer variable named employeescount : Defines a structure called Employee that contains a character member called id that can hold an id that is up to 9 characters long and a float member.
Create a class with the name student : Create a constructor that initializes all int to 0, float to 0.0, char to ' ', name = "NoName".
Show total distance traveled and total gas consumed : Allow the user to keep entering data in 5 minute increments until the user has no more data to enter. Show total distance traveled, total gas consumed.
Create a class line which consists of start -end coordinates : Create a class Line which consists of start and end coordinates, and line type.The default value for line type should be vertical.
Write a mips program that will read in a base : Write a MIPS program that will read in a base (as an integer) and a value (nonnegative integer but as an ASCII string) in that base.
Give the state of the array after it is max heapified : Give the state of the array after 3 "removes" (we are not really deleting anything) have been performed from the heap in phase 2 of heapsort.
Write a program to ask for the chord : With one cut across the middle of a pizza you can cut off half, that is, 50% of the pizza. With one cut at a different place you can cut off.
Using recursion determine if the string is a palindrome : Using recursion, count how many times each of the letter "a" and "k" are repeated (There may be 0 a and 0 k in the string).
Deterinine the average codeword length : Determine the average information for this message. (You may ignore hyphens, spaces, and punctuation.)

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd