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 stack segment, Q. Define Stack segment ? 8086 Microprocessor su...

Q. Define Stack segment ? 8086 Microprocessor supports Word stack. Stack segment parameters tell the assembler to alert linker that this segment statement states the program s

Branch (control) hazards in computer architecture, Branch (control) hazards...

Branch (control) hazards in computer architecture : Branching hazards (also called control hazards) take place when the processor is told to branch -for example, if a defin

Web designing, how to start a web designing would you please guide me

how to start a web designing would you please guide me

What is mini computer, Q. What is Mini computer? The term minicomputer ...

Q. What is Mini computer? The term minicomputer introduced in 1960's when it was realized that numerous computing tasks don't need an expensive modern mainframe computers howev

What is process control block, What is process control block?  Each pro...

What is process control block?  Each process is shown in the OS by a process control block. It having many pieces of information associated with a specific process.

What is verilog, What is Verilog Verilog  language  is  still  rooted  ...

What is Verilog Verilog  language  is  still  rooted  in  it's  native  interpretative  mode.  Compilation  is  a means of speeding up simulation however has not changed the or

What are the advantages of electronic payment system, What are the advantag...

What are the advantages of electronic payment system? Advantages of the electronic payment system are illustrated below: This gives good security schemes. Four important sec

large block , Given a RAID 3 (bit-interleaved parity) with k disks, how we...

Given a RAID 3 (bit-interleaved parity) with k disks, how well will large block transmits work? How well will it handle a high I/O request rate? Compare the performance to a one di

Define the term internet, Internet:  The Internet, an umbrella term cov...

Internet:  The Internet, an umbrella term cover countless network and services that comprise a super-network, is a global network of computer networks that was started in the 1

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