Translate assembly language program to machine , Computer Engineering

Assignment Help:

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.


Related Discussions:- Translate assembly language program to machine

Determine the concepts of object oriented analysis, Determine the concepts ...

Determine the concepts of Object Oriented Analysis  In OOA the initial focus is on identifying objects from the application domain, after that fitting those procedures around

Convert the binary number to gray code, Convert the binary number 10110 to ...

Convert the binary number 10110 to Gray code ? Ans. For changing binary number 10110 in its equivalent Gray code the rules are as, the left most bit that is MSB in Gray code is 1

How to reduce the maximum quantization error, In successive-approximation A...

In successive-approximation A/D converter, offset voltage equal to 1/2 LSB is added to the D/A converter's output. This is done to ? Ans. It is done to reduce the maximum quantiz

Perform binary subtraction on following, Q Perform Binary Subtraction on fo...

Q Perform Binary Subtraction on following: 1) 1101-1000 2) 111.11-101.1 3) 1101.1-1010.01 Q Perform Binary Multiplication & Division on following: 1) 16*2.75 2) 1

Define modem, Define Modem. A modem changes digital signals into audio ...

Define Modem. A modem changes digital signals into audio tones to be transmitted over telephone lines and also changes audio tones from the lines in digitals signals for machin

Implement a memory management system , There should be 1 server thread and ...

There should be 1 server thread and N client threads, where N is supplied by the user as a command line argument. The server opens a file called "all_requests.dat", the file has

What is stack addressing, Q. What is Stack Addressing? In this addressi...

Q. What is Stack Addressing? In this addressing technique operand is implied as top of stack. It isn't explicit however implied. It employs a CPU Register known as Stack Pointe

How do you split hydrogen and oxygen gases, Q. How do you split Hydrogen an...

Q. How do you split Hydrogen and Oxygen gases in industrial electrolysis of water process? Answer:- In oxygen, electrolysis and hydrogen gas are produced at different elec

What is .net and .net framework, What is .NET / .NET Framework?  It i...

What is .NET / .NET Framework?  It is a Framework in which Windows applications might be developed and run. The Microsoft .NET Framework is a platform for building, deploying,

Illustrate about the word processors with its design, Illustrate about the ...

Illustrate about the Word processors with its design Word processors now have many aspects over and above the original task of generating a typed document. This section would

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd