Translate assembly language program to machine , Computer Engineering

Assignment Help:

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.


Related Discussions:- Translate assembly language program to machine

We define our own match code id''s for sap matchcodes, Can we define our ow...

Can we define our own Match Code ID's for SAP Matchcodes? Yes, the number 0 to 9 are reserved for us to make our own Match Code Ids for a SAP described Matchcode object.

Logical drives is it possible to fit onto a physical disk, How many logical...

How many logical drives is it possible to fit onto a physical disk? Ans) Maximum of 24 logical drives can be fit into physical disk. The extended partition can only have 23 lo

Explain the programmable rom (prom) - computer memory, Explain the Programm...

Explain the Programmable ROM (PROM) - Computer Memory? This is a kind of ROM that can be programmed using special equipment it can be written to, but only once and this is usef

Use of parallel construct with private clause, Q. Use of parallel construct...

Q. Use of parallel construct with private clause? In this example we would see use of parallel construct with private and firstprivate clauses. At end of program i and j remain

What is replacement policy in cache, Q.What is Replacement Policy in cache?...

Q.What is Replacement Policy in cache? When a new block has to be fetched in cache the other block may have to be replaced to make room for new block. Replacement policy determ

Loop level-levels of parallel processing, Loop Level At this level, rep...

Loop Level At this level, repeated loop iterations are the applicants for parallel execution. However, data dependencies among subsequent iterations may limit parallel executio

Explain all the categories of common control switching, Explain all the cat...

Explain all the categories that are served by Common Control switching. Common Control Switching System: It is a functional block diagram of a common control switching system i

Explain how the server control validation controls work, Briefly explain ho...

Briefly explain how the server control validation controls work? A validation control works by evaluating the value of an input server control on the page to see whether it me

Explain the uses of keyboards, Explain the uses of Keyboards An alphanu...

Explain the uses of Keyboards An alphanumeric keyboard for a graphics system is used primarily as a device for entering text strings. Keyboards can also be provided with featur

Write Your Message!

Captcha
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