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
Weight Training Calculations: However we have more weights in our network than in perceptrons but we firstly need to introduce the notation as: w ij just to specify the weigh

I want to know...if there is a program available in C code using data structure for online movie booking system

What guarantees the integration of all application modules? The R/3 basis system guarantees the integration of all application modules.  The R/3 basis s/w gives the run time e

Write short note on Associated vs. Common channel signaling. Associated vs Common channel signalling: The out band signalling suffers from the very restricted bandwidth.

Windows Authentication This provider utilizes the authentication capabilities of IIS. After IIS completes its authentication, ASP.NET uses the authenticated identity's token to

A Scanner is a device which allows you to capture photographs or drawings or text from tangible sources (paper or slides etc.) in electronic form. Scanners work by detecting differ

Q. Convert the following BINARY numbers into OCTAL, double check by converting the result OCTAL to BINARY. a) 111.111 b) 10110111 c) 0.11111

How u can create XML file? To write Dataset Contents out to disk as an XML file use: MyDataset.WriteXML(server.MapPath("MyXMLFile.xml"))

Explain differences between folded and non-folded network. Folded network: While all the inlets/outlets are connected to the subscriber lines, the logical connection shows as

Problem (a) Explain the difference between the real mode and the protected mode in the 80x86 family of processors. (b) The 32-bit physical address 047C:0048 is to be conv