Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

A useful exercise in understanding assembly language and its relation to machine language is to take a short assembly language program and translate it to machine language by hand.

The following program, countbits, counts the number of bits set to 1 in registers $4 and returns the result in register $6.

main: li $10, 32 # set up loop counter

li $6, 0 # clear output sum

main10: andi $12, $11, 1 # test current bit

beq $12, $0, main20 # skip count if not set

addi $6, $6, 1 # otherwise increment count

main20: srl $11, $11, 1 # shift input right

addi $10, $10, -1 # decrement count

bne $10, $0, main10 # continue until zero

li $2, 10 # Halt code

syscall

Translate this program to machine code by hand, explaining for each line how you worked out the machine instruction.

Although it might be tempting to simply let the SPIM assembler do this, the exercise is useful way of learning the MIPS instruction formats. Refer to Appendix B (Assemblers, Linkers and the SPIM simulator) of the text (4th Edition ) for descriptions of MIPS assembly language instructions and the corresponding machine codes.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9525287

Have any Question?


Related Questions in Computer Engineering

You can shuffle a list using randomshufflelstwrite your own

You can shuffle a list using random.shuffle(lst). Write your OWN function without using random.shuffle(lst) to shuffle a list and return the list. Use the following function header: def shuffle(lst): Write a test program ...

What are the best practices to follow for microsoft windows

What are the best practices to follow for Microsoft Windows network security. Which two would you start with and why?

Question suppose you are starting work on a project for an

Question : Suppose you are starting work on a project for an organization that has never used any modeling techniques or tools in designing a system. (Yes, it is hard to imagine, but it does exist.) Your manager is reluc ...

In a survey of 3236 adults 1470 say they have started

In a survey of 3236 adults, 1470 say they have started paying bills online in the last year. Construct a? 99% confidence interval for the population proportion. Interpret the results.

Question research different information systems management

Question : Research different information systems management disaster response plans of major organizations that have had to respond to fairly recent disasters. Discuss the results of the organization's recovery efforts.

Show the entries for the header of a udp user datagram that

Show the entries for the header of a UDP user datagram that carries a message from a TFTP client to a TFTP server. Fill the checksum field with zeros. Choose an appropriate ephemeral port number and the correct well-know ...

Why are we in the golden age of technology entrepreneurship

Why are we in the 'golden age' of technology entrepreneurship? What factors are helping entrepreneurs more rapidly achieve their vision, and with a lower cost?

Sorted golf scores - need flowchartdesign a program that

Sorted Golf Scores - need flowchart Design a program that asks the user to enter 10 golf scores. The scores should be stored in an Integer array. Sort the array in ascending order and display its contents. Looking for "" ...

The diet doctor claims that the average north american is

The diet doctor claims that the average North American is more than 20 pounds overweight. To test his claim, a random sample 30 Of north Americans was weighted, the difference between their actual weight and their ideal ...

Question in official obenglobish the ob characters are

Question : In official Obenglobish, the ob characters are added only before vowels that are pronounced, which means that a word like "game" would become "gobame" rather than gobamobe because the final e is silent. While ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As