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
What is independent process? A process is independent it cannot affect or be affected by the other processes implementing in the system. Any process does not share data with ot

Illustrate about object oriented development object oriented development is not direct way of system development as in this approach a holistic view of application domain is co

The address bus is unidirectional due to the address information is always given by the Micro Processor to address a memory location of an input or output devices.

What are the major characteristics of a pipeline? The major characteristics of a pipeline are: a) Pipelining cannot be executed on a single task, as it works by splitting mu

Why must a modem be used to transmit binary data through a PSTN? (1) Use sketches and additional text to describe the following modulation methods. (a) Amplitude shift keying (b) F

Discuss in detail Table management Techniques? An Assembler uses the subsequent tables: OPTAB: Operation Code Table consists of mnemonic operation code and machine langua

design modulo 12 up synchronous counter using t flip flop

Name and explain the popular techniques to identify free memory areas as a result of allocation and de-allocations in a heap. Two well-liked techniques to identify free memory

Q. What are basic features that collaboration systems might have? ANSWER: Three basic features of collaboration systems are Web-conferencing, project management,

A global variable is a variable A global variable is declared outside the body of each function.