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

What is busy hour traffic, Busy hour traffic is the (A)  maximum avera...

Busy hour traffic is the (A)  maximum average simultaneous traffic. (B)  traffic during peak hour. (C)  traffic when all subscribers are engaged. (D)  the durat

Final year project, i want to make final year project in wireless.please he...

i want to make final year project in wireless.please help me to decide the topic???????

Obtain 1''s and 2''s complement, Obtain 1's and 2's complement of 1010 usin...

Obtain 1's and 2's complement of 1010 using only four-digit representation. Solution: 1's complement: 1's complement of 1010 is  Please note that wherever you ha

What is null pointer, What is NULL POINTER Inside main, a FILE * called...

What is NULL POINTER Inside main, a FILE * called file. Afterwards, the fopen function, passing it the path to data file, as well as "r", only intending to read from the file.

State the protected mode interrupt, State the Protected mode interrupt ...

State the Protected mode interrupt In protected mode, interrupts have exactly same assignments just like in real mode though the interrupt vector table is different.  Instead

Paging, specification of paging ram size is 12 frames

specification of paging ram size is 12 frames

What is meant by super scalar processor, What is meant by super scalar proc...

What is meant by super scalar processor?  Super scalar processors are designed to exploit more instruction level parallelism in user programs. This means that multiple function

Transformation – the process of change, TRANSFORMATION - THE PROCESS OF CHA...

TRANSFORMATION - THE PROCESS OF CHANGE Much of contemporary art and design practice and indeed popular culture is dedicated to looking at how change affects us as individuals a

Power and energy, Ask questiPower and EnergyQuestion 4Consider a processor ...

Ask questiPower and EnergyQuestion 4Consider a processor that runs at 2.5 GHz and 1 Volt. When running a given CPU-bound program,the processor consumes 100 W, of which 20 W is leak

Does gimp have scanner support, Yes. It's available on Windows and uses TWA...

Yes. It's available on Windows and uses TWAIN, and on GNU/Linux you constant have a choice among XSane and gnome-scan - both can be used as GIMP plug-ins.

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