Question

.begin in counter while: load counter compare zero jumpeq done out counter decrement counter jump while...

.begin
in counter
while: load counter
compare zero
jumpeq done
out counter
decrement counter
jump while
done: halt
counter: .data 0
zero: .data 0
.end

Modify the program so it checks to see that the input data is greater than zero before it starts the loop. If that's not the case, the program should halt without any output.

Homework Answers

Answer #1

ANSWER:

I have provided the properly commented and indented code so you can easily copy the code as well as check for correct indentation.
Have a nice and healthy day!!

CODE

.begin
in counter

load counter --loading counter to Register R
compare zero --Comparing R to zero
jumpgt while --If Counter>0, jump to while
jump done    --otherwise jump to done

while: load counter
compare zero
jumpeq done
out counter
decrement counter
jump while
done: halt
counter: .data 0
zero: .data 0
.end
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
[PART ONE OF PROJECT, ALREADY COMPLETED] An accumulator is a primitive kind of calculator that can...
[PART ONE OF PROJECT, ALREADY COMPLETED] An accumulator is a primitive kind of calculator that can evaluate arithmetic expressions. In fact, the Arithmetic-Logic Unit (ALU) of the rst computers was just an accumulator. An arithmetic expression, as you know, consists of two kinds of tokens: operands and operators All our operands will be (float) numbers and for a start, we shall use only two operators: + (plus) and - (minus) A sample run of the program would look like this....
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing associated with the assignment it is failing one part of testing.   Below is the test that fails: Failed test 4: differences in output arguments: -c input data: a b c -c expected stdout: b observed stdout: a b expected stderr: observed stderr: ./test: invalid option -- 'c' Unsure where I have gone wrong. MUST BE WRITTEN IN C++ Task Level 1: Basic operation Complete...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
ch 6 1: It is generally a good idea to gain an understanding of the "size"...
ch 6 1: It is generally a good idea to gain an understanding of the "size" of units. Consider the objects and calculate the kinetic energy of each one. A ladybug weighing 37.3 mg flies by your head at 3.83 km/h . ×10 J A 7.15 kg bowling ball slides (not rolls) down an alley at 17.5 km/h . J A car weighing 1260 kg moves at a speed of 49.5 km/h. 5: The graph shows the ?-directed force ??...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
Business Problem-Solving Case Walmart and Amazon Duke It Out for E-Commerce Supremacy Walmart is the world’s...
Business Problem-Solving Case Walmart and Amazon Duke It Out for E-Commerce Supremacy Walmart is the world’s largest and most successful retailer, with $487.5 billion in 2014 sales and nearly 11,000 stores worldwide, including more than 4,000 in the United States. Walmart has 2.2 million employees and ranks first on the Fortune 500 list of companies. Walmart had such a large and powerful selling machine that it really didn’t have any serious competitors—until now. Today, Walmart’s greatest threat is Amazon.com, often...