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

Characteristics of input- output channels, Q. Characteristics of input- out...

Q. Characteristics of input- output channels? The I/O channel represents an extension of DMA concept. An I/O channel has ability to execute I/O instructions that gives complete

Explain the working of static ram - computer memory, Explain the working of...

Explain the working of Static RAM - Computer Memory? SRAM devices tender extremely fast access times (approximately four times faster than DRAM) but are much more expensive to

Convert decimal number to ocatl number, Convert (177.25) 10 to octal A...

Convert (177.25) 10 to octal Ans. 177.25) 10 = (         ) 8 Firstly we take integer part Hence (177) 10 = (261) 8 Now as 0.25 x 8 = 2.00 and 0.00 x 8 = 0 Therefor

What is the difference between dpi and ppi, Question : (a) "Resolution ...

Question : (a) "Resolution refers to the sharpness and clarity of an image" (i) Explain what you understand by the above statement. (ii) What is the difference between D

Classify data networks, Classify data networks. Data Network Classifica...

Classify data networks. Data Network Classifications: Data Networks are classified as per to their geographical coverage: - Wide area networks (WANs) - Metropolitan ar

Where can i find conference information, Georg Thimm handles a webpage that...

Georg Thimm handles a webpage that lets you search for upcoming or past conferences in a range of AI disciplines.

CPE, WHAT IS CPE

WHAT IS CPE

What are concentrators, What are concentrators? Explain how it helps in con...

What are concentrators? Explain how it helps in connecting number of subscribers. In rural areas, subscribers are usually dispersed. This is both unessential and expensive to g

Identify the main enhancements brought along by tkip, Question: (a) Id...

Question: (a) Identify the four main enhancements brought along by TKIP on WPA to solve the problems in WEP. (b) The term WarDriving has been frequently used while talking

Explain the relationship b/w translated & load time address, Explain the re...

Explain the relationship amongst Translated address and Load time address. Translated address: Address assigned through the translator Load time address: Address ass

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