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
Q. Introduction to the Operating System? An Operating system is software that creates a relation between the User, Hardware and Software. It is an interface between the all.

Explain the term- Variables - Variables are used for local storage of data -  Variables are usually not available to multiple processes and components. -  Variables would

Q. Explain Hardwired control organization? In the hardwired organization control unit is designed as a combinational circuit. The control unit is applied by gates, flip-flops,

What is the importance of XML into EDI and electronic commerce? XML has been explained as lightweight SGML: XML demonstrates great promise for its inherent capability to per

Common Functions of Interrupts: An Interrupt transfers control to the interrupt service routine, generally through the interrupt vector table, which contains the addresses

Explain The Boolean Equations for Logic Circuits? A Boolean equation is the mathematical representation of a logic circuit using standard Boolean terms. All the logic gates (AND,

Explain the Low Level Language - Computer Programming? An assembly language or a machine language is known as Low-level language which are closer to the hardware than are high-

Q. What is Access latency and Rotation Speed? Access latency: A disk access basically moves the arm to selected cylinder and waits for rotational latency that may take less t

If a programmer doesn't wish to make modifies to the document he can lock the document data and its code from more changes by changing the extension of the file system to .MDE. Cha

Your professor wants you to fill a two-dimensional N by N matrix with some numbers by following a specific pattern. According to his explanation as in the figure below, you have to