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. Working of Fully Parallel Associative Processor? Fully Parallel Associative Processor: This processor accepts the bit parallel memory organisation. There are 2 kinds of this

Explain the significance of different fields of an instruction An instruction is a command given to a computer to perform a particular operation on some given data and the form

Addresses are basically for virtually everything we do on Internet. The IP in TCP/IP is a mechanism for providing addresses for computers on Internet. Internet addresses have two f

A local government organisation needs to deploy a honey net. To this end you are to deploy a honeynet based on the supplied network diagram (separate download) that should give sop

Explain Language Processor Development Tools (LPDTs) through schematic diagram. LPDT that is Language processor development tools focuses upon generation of the analysis phase


Q. Define critical mass and critical volume? The minimum size in which at least one neutron is available for further fission reaction. The throng of the fissile material at the

Determine the hardware for multiplication The hardware for multiplication consists of equipment given in Figure. The multiplier is stored in register and its sign in Q . The se

Q. What do you mean by Drive Cache? Disk cache may be a part of RAM sometimes known as soft disk cache which is used to speed up access time on a disk. In latest technologies s

Q. Explain Design of adder? Adders play one of the most significant roles in binary arithmetic. As a matter of fact fixed point addition is frequently used as a simple measure