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

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.

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
In what way is stored program control superior to hard wired control? The SPC gains superiority over hard wired because of following points: SP C Ha

Solve the following cryptarithmetic problem using Prolog: P I N G P O N G + F U N --------- I G N I P Each of the 7 different letters stands for a different digit. The

Explain CONGESTION. CONGESTION: This is uneconomic to provide sufficient equipment to carry entire traffic that could possibly be given to a telecommunication system. Inside

Conjunctive Normal Forms: However there for the resolution rule to resolve two sentences so they must both be in a normalised format called as conjunctive normal form, that is

A) Execute a program where an ellipse follows the perimeter of the window. B)  Execute a program that can draw graphs, possibly following your plan from last week. Have it graph

Q. Illustrate the FTP commands? FTP includes many commands however only few are used to retrieve a file. A user is required to understand the three basic commands to connect to

Explain any three parsing techniques. Following are three parsing techniques: Top-down parsing: This parsing can be viewed as an attempt to get left-most derivations of an

We download data which arrives to me in a column. I need to use it in a complex sheet that requires data in a row. How can we convert the column data into row data?   Ans) H

Can you delete a domain, which is being used by data elements? No.

Question: a) Describe what is meant by a "bus". There are two types of bus, dedicated and multiplexed. Give a brief description of both types of buses. b) Briefly explain f