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
Summary of Tasks Task Summary attempts to show amount of duration every task has spent starting from beginning of task until its completion on any processor as displayed in Fi

1. The missionaries and cannibals problem. Three missionaries and three cannibals are on the left river bank, with a boat that can hold one or two people. If on either side of 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

What are the requirements to design Combinational Logic ? Ans . Design Requirements of Combinational Logic:- (i) By the specifications of circuit, we find out the

ENCTYPE="application/x-www-form-urlencoded" and in its place use ENCTYPE="text/plain". The subsequent illustration displays a general form which includes some of the commo

Offset Litho Duplicating Equipment Required Duplicator Plate-making equipment (not always, essential), e.g. printing box and processing unit Plates Paper Ink

When an input signal A=11001 is applied to a NOT gate serially, its output signal is ? Ans. First input applied will be LSB 00110, as A=11001 is serially applied to a NOT gate

Problem (a) Forensic methodology consists of three phases. Briefly explian these three phases. (b) Sometimes it's best not to perform hard-disk acquisition. Provide two

State the Tips of timescale directive Include a `timescale directive at the top of each module, even if there are no delays i n the module, since some simulators may require th

Q. Explain about Microprocessors? Microprocessors have instruction sets ranging from 20 to several hundred instructions, known as microprograms, which are stored in ROM to init