Translation of this into a generic assembly language

Assignment Help Computer Engineering
Reference no: EM1329079

Consider the following loop:

S:= 0;
for K := 1 to 100 do
S : = S - K;

A straightforward translation of this into a generic assembly language would look something like this:

LD R1,0 ;KEEP VALUE OF S IN R1
LD R2,1 ;KEEP VALUE OF K IN R2
LP SUB R1,R1,R2 ;S := S - K
BEQ R2,100,EXIST ;DONE IF K = 100
ADD R2,R2,1 ;ELSE INCREMENT K
JMP LP ;BACK TO START OF LOOP

A compiler for a RISC machine will introduce delay slots into this code so that the processor can employ the delayed branch mechanism. The JMP instruction is easy to deal with, because this instruction is always followed by the SUB instruction; therefore we can simply place a copy of the SUB instruction in the delay slot after the JMP; The BEQ presents a difficulty. We can't leave the code as is, because the ADD instruction would then be executed one too many times. Therefore, a NOP instruction is needed. Show the resulting code.

Reference no: EM1329079

Questions Cloud

Explain how does e-business affect a company''s strategy : Explain How does e-business affect a company's strategy and what must a company do to transform its strategy when it decides to transform into an e-Business
Explain the action of the function : Describer the action of the function. What is the function in the library that performs a similar calculation.
Psychodynamic approaches leadership theory : In what ways could it be said that with psychodynamic approaches leadership theory has come full circle to trait, skill, and style theory?
Question about strategic supply chain management : Question about Strategic Supply Chain Management - Show the competing and conflicting objectives of these parties.
Translation of this into a generic assembly language : A compiler for a RISC machine would introduce delay slots into this code so that the processor can employ the delayed branch mechanism.
Describe the change : Identify a company that has recently undergone a significant organizational change. Describe the change.
Explain privacy and security and international issues : Explain Privacy and Security and International Issues on the AT and T
Use of information technology : Use of information technology - Describe how the use of information technology can make things worse if it is applied to a poorly thought out process.
Information regarding constitutional interpretation : What differing approaches to constitutional interpretation do you find in the opinions of Justices Kennedy and Scalia in Roper v. Simmons (2005)?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Compare and contrast the useradd

Compare and contrast the useradd and adduser commands in Linux. What is their purpose? Which one would you use? What other processes besides using these two commands might you employ to accomplish the same task?

  Advantages of technologies

List some of the advantages of some of current technologies explained in our reading this week involving VoIP, Virtual Private Networks, Unified Communications, Wi-Fi and wireless technologies such as RFID.

  Write c program ''myls'' that functions like unix command ''ls''

Write C program 'myls' that functions like unix command 'ls'.

  Program to find grade of students on basis of test scores

Write down a C++ program which finds a better grade for a student based upon two test scores. For a numeric average x.

  Drawing the uml state diagram

In the chess game white and black make alternate moves. White takes first move. Both Black and White may finish the game: by winning, by giving up, by draw.

  Write a function that creates a cell and structure array

Write a function that creates a cell and structure array.

  Icmp packets

Involve at least five ICMP packets, and also explain why they would be a problem on the network.

  Definition of method dashedline

Write down the definition of the method dashedLine , with one parameter, an int. If parameter is negative or zero, method does nothing.

  Benefits of utilizing the google

Specify how Google has made it possible for you to have access to the information you have gathered from Internet without your own computer? Provide at least two specific examples and benefits of utilizing the Google.

  How is this achieved in your code

In order for the instance below to work, could you have a variable named "field"? How would the variables on either side of the MOVE statement need to be defined as.

  Consider an adt called squarematrix

Consider an ADT called 'SquareMatrix'

  The difference between a worm and a trojan horse

What do you tell him is the difference between a worm and a Trojan horse. List at least six reasons you can give John for preventing viruses and other malware.

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