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

Define the object orientation and its analysis, Object Orientation and Anal...

Object Orientation and Analysis An Object is anything that exists within the problem domain that can be recognized by data and/or behaviour. An example of an object is a bike.

Explain the term- signals, Explain the term- Signals -  Signals are use...

Explain the term- Signals -  Signals are used for communication between components -  Signals can be seen as real, physical signals -  Some delay should be incurred in a

What is synchronous message passing, Q. What is Synchronous message passing...

Q. What is Synchronous message passing? In Synchronous message passing is executed on synchronous communication network.  In that case sender and receiver processes should be

How the conversation speed of A/D converter is maximum, The conversation sp...

The conversation speed of an analog to digital converter is maximum with which technique? Ans. With parallel comparator AD converter technique the conversation speed of an ana

Benefits of having densely packed integrated circuits, What are benefits of...

What are benefits of having densely packed Integrated Circuits? These are stated below: Reliability: The integrated circuit interconnections are in fact more reliable

Explain the main part of step by step switching system, Explain the main pa...

Explain the main part of configuration of a step by step switching system with the help of a neat diagram . Configuration of a step by step switching system: A step

Explain LRU page replacement algorithm, Explain LRU Page replacement algori...

Explain LRU Page replacement algorithm. LRU policy: It expands to least recently use. This policy proposes that we remove a page that last usage is farthest from present time

By which the information is stored in ROM, The information in ROM is stored...

The information in ROM is stored ? Ans. By the manufacturer throughout fabrication of the device.

Describe about modem language, Q. Describe about Modem Language? Modems...

Q. Describe about Modem Language? Modems understand a set of instructions known as Hayes Command Set or AT Command Set. These commands are used to communicate with Modem. At ti

Elucidate basic time division time switching method, With the help of block...

With the help of block diagram Elucidate basic time division time switching method. Basic Time Division Switching: Functional blocks of a memory based time division switching

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