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

What is function overloading, a. Describe function declaration, function de...

a. Describe function declaration, function definition and function cell using a suitable example. Explain the function prototype? b. What is function overloading? When do we use

An 8086 interrupt, An 8086 interrupt can take placedue to the following rea...

An 8086 interrupt can take placedue to the following reasons: 1.  Hardware interrupts caused by some external hardware device. 2.  Software interrupts that can be invoked wit

What are the parts of a deployment diagram, ? Nodes: A node shows any hardw...

? Nodes: A node shows any hardware component. The configuration of hardware is shown by attributes of nodes. ? Components: A component shows software. Every component straight

How do you add a developer to a trusted publishers list, Whenever a develop...

Whenever a developer is signing into the code project you will have three options they are disable the macro, enable the macro and explicitly trusting the publisher. You can trust

Illustrate the uses of assembly language, Q. Illustrate the Uses of Assembl...

Q. Illustrate the Uses of Assembly Language? Uses of Assembly Language Assembly language is used mainly for writing short, efficient, specific interfacing modules/ subrou

Define signal and component of obejct oriented modeling, Define about sign...

Define about signal and component of obejct oriented modeling A signal is a specification of an asynchronous stimulus communicated among instances. A component is a physical

When page fault frequency in an operating system is reduced, Page fault fre...

Page fault frequency in an operating system is reduced when the? When locality of reference is appropriate to the process so Page fault frequency in an operating system is redu

What do you mean by execution unit, Q. What do you mean by Execution Unit? ...

Q. What do you mean by Execution Unit? Execution unit performs all ALU operations. Execution unit of 8086 is of 16 bits. It also contains the control unit that instructs bus in

Compare single bus structure and multiple bus structure, Compare single bus...

Compare single bus structure and multiple bus structure? A system that having only one bus(i.e only one transfer at a time) is known as a single bus structure. A system is know

What is elapsed time of computer system, What is elapsed time of computer s...

What is elapsed time of computer system? The total time to implement the total program is known as elapsed time. It is affected by the speed of the processor, the disk and the

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