Translate assembly language program to machine , Computer Engineering

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


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.

Posted Date: 3/1/2013 12:54:03 AM | Location : United States

Related Discussions:- Translate assembly language program to machine , Assignment Help, Ask Question on Translate assembly language program to machine , Get Answer, Expert's Help, Translate assembly language program to machine Discussions

Write discussion on Translate assembly language program to machine
Your posts are moderated
Related Questions
haw to convert context free grammar to regular grammar

Potential of Parallelism Problems in the actual world differ in respect of the degree of natural parallelism inherent in the personal problem domain. Some problems may be simpl

I can send you the lecture notes and assignments, and you will walk me through (either record a screencast, or kind on the assignments in red colored font) steps on how to do the a

Direct inward dialling is used as a feature in? Direct inward dialling is utilized as a feature in EPABX.

Dynamic modelling: state diagrams A state diagrams allow you to further explore operations and attributes which need to be defined for an object. They comprises of sets of sta

Discuss its advantages over the other evaluation techniques. The expression tree is determined by using a post-order traversal of the expression tree as given here: 1. If such

What are the events used for page headers and footers? The events TOP-OF-PAGE and END-OF-PAGE are used for pager headers and footers.

Your shell should accept and execute the pipe "|"  operator. This will look like the following: | The functionality of this operator is to execute command1 and send i

#example of cascading rollback#

Create a relationship among Employee and Sales tables using Emp No. Enforce referential integrity and select both cascade update and cascade delete options. Save the relationship.