Convert this decimal number to binary and output

Assignment Help Other Engineering
Reference no: EM132107320

This program is to print the binary representation of a decimal number using a divide by 2 conversion routine and the Stack. This program should be written in MIPS/QtSpim

1. Use syscall 4 to prompt for a number between -128 and 127 (0 will terminate the program)

2. Input a number (using syscall 5)

3. If the number is not within the limits, print message at label err and try again.

4. Convert this decimal number to binary and output its binary representation to the console using divide by 2 method.

5. Push each remainder to the stack until 8 digits are stored then pop them to output the result with syscall 1 after an answer header as listed in the declaration.

6. The magnitude of the number will always be 8 bits with MSB =1 for negative numbers and 0 for positive numbers.

7. The program will continue prompting for a number until 0 is entered. If number 0 is entered, the program prints the message at label term in the data declaration and exits the program.

Hint: The 8-bit binary representation of a negative number m is the same as that of the positive number (256 + m).

The beginning of the program and the data declaration are given below:

# Program to convert a number between -128 and 127 to its binary equivalent and

# outputs its binary representation to the console.

.text

main:

.data

prompt: .asciiz "\n Input a decimal number between -128 and 127 (0 to exit): "

answer: .asciiz "\n Binary representation is "

err: .asciiz "\n input error - try again!"

term: .asciiz "\n Program terminated"

Reference no: EM132107320

Questions Cloud

Initial target serum glucose level : When HHNS is treated, the initial target serum glucose level is typically set at the 250 mg/dl range instead of a normal blood glucose level. Why?
Draw the speedup graph as a function of program fractions : A program is run on a computer with multiple processors. When a computation is run in parallel mode, it is 20 times faster.
What are the advantage and disadvantages to using bmi : What values are associated with it Body Mass Index? What are the advantage and disadvantages to using BMI?
Exceptions in relation to other individuals : BMI and race and genetics is a questionable and there should be exceptions in relation to other individuals. In particular that of Latinos, those of Latino
Convert this decimal number to binary and output : Convert this decimal number to binary and output its binary representation to the console using divide by 2 method.
Simulate the roll of a single die using the random number : This program should simulate the roll of a single die (dice) (1-6) using the C++ random number functions.
Which tube showed the greatest degree of lipid : Which tube showed the greatest degree of lipid? how do you show this? Why did the tube mentioned in question 1 have the greatest degree of lipid digestion?
What type of physiologic mechanism of compensation : What type of physiologic mechanism of compensation could occur for this acid-base disturbance?
Records the grams of carbohydrates : Mark reads the food labels of everything he eats for one day and records the grams of carbohydrates, protein, and fat for each item.

Reviews

Write a Review

Other Engineering Questions & Answers

  Characterization technology for nanomaterials

Calculate the reciprocal lattice of the body-centred cubic and Show that the reciprocal of the face-centred cubic (fcc) structure is itself a bcc structure.

  Calculate the gasoline savings

How much gasoline do vehicles with the following fuel efficiencies consume in one year? Calculate the gasoline savings, in gallons per year, created by the following two options. Show all your work, and draw boxes around your answers.

  Design and modelling of adsorption chromatography

Design and modelling of adsorption chromatography based on isotherm data

  Application of mechatronics engineering

Write an essay on Application of Mechatronics Engineering

  Growth chracteristics of the organism

To examine the relationship between fermenter design and operating conditions, oxygen transfer capability and microbial growth.

  Block diagram, system performance and responses

Questions based on Block Diagram, System Performance and Responses.

  Explain the difference in a technical performance measure

good understanding of Mil-Std-499 and Mil-Std-499A

  Electrode impedances

How did this procedure affect the signal observed from the electrode and the electrode impedances?

  Write a report on environmental companies

Write a report on environmental companies

  Scanning electron microscopy

Prepare a schematic diagram below of the major parts of the SEM

  Design a pumping and piping system

creating the pumping and piping system to supply cool water to the condenser

  A repulsive potential energy should be a positive one

Using the data provided on the webvista site in the file marked vdw.txt, try to develop a mathematical equation for the vdW potential we discussed in class, U(x), that best fits the data

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