How would I make it so my code outputs a zero if it recieves a negative number or zero?   org 100 / prompt the user to enter the values of A,B,C and store them Input        Store A   Output    Input        Store B Output      Input    Output     Store C      Load B      / load B into accumulator Store Count1 / store B in Count variable Loop1,Load A  / load A into accumulator Add Sum1    / add value of accumulator to Sum1 Store Sum1  / store updated value of Sum1  Load Count1  / load value of Count1  Subt Decrement   / Decrement Count1 Store Count1 / store the updated value of Count1 in memory Skipcond 800/ skip if accumulator is negative or zero Jump Count2 / jump to Count2 if Count1 is greater than 0 Jump Loop1  / jump back to the start of Loop1 Count2,Load C / load C into accumulator Store Count1 / store C in Count1 variable Loop2,Load Sum1  / load value of Sum1  Add Sum2    / add value of accumulator to Sum2 Store Sum2  / store the updated value of Sum2  Load Count1  / load value of Count1  Subt Decrement  / Decrement Count1 Store Count1 / store updated value of Count1 Skipcond 800/ skip if accumulator is negative or zero Jump End    / End if Count is equal or less than 0 Jump Loop2  / jump back to the start of Loop2 End,Load Sum2   / load value of Z  Output      / display the sum Z Halt        /default values of A,B,C,Sum1,Sum2 and Count1 A, Dec 0 B, Dec 0 C, Dec 0 Sum1, Dec 0 Sum2, Dec 0 Count1, Dec 0 Decrement, Dec 1   / used to decrement Count1 variable

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 14E
icon
Related questions
Question

How would I make it so my code outputs a zero if it recieves a negative number or zero?

 

org 100

/ prompt the user to enter the values of A,B,C and store them
Input       
Store A  
Output   
Input       
Store B
Output     
Input   
Output    
Store C     


Load B      / load B into accumulator
Store Count1 / store B in Count variable

Loop1,Load A  / load A into accumulator
Add Sum1    / add value of accumulator to Sum1
Store Sum1  / store updated value of Sum1 

Load Count1  / load value of Count1 
Subt Decrement   / Decrement Count1
Store Count1 / store the updated value of Count1 in memory
Skipcond 800/ skip if accumulator is negative or zero
Jump Count2 / jump to Count2 if Count1 is greater than 0
Jump Loop1  / jump back to the start of Loop1

Count2,Load C / load C into accumulator
Store Count1 / store C in Count1 variable

Loop2,Load Sum1  / load value of Sum1 
Add Sum2    / add value of accumulator to Sum2
Store Sum2  / store the updated value of Sum2 


Load Count1  / load value of Count1 
Subt Decrement  / Decrement Count1
Store Count1 / store updated value of Count1
Skipcond 800/ skip if accumulator is negative or zero
Jump End    / End if Count is equal or less than 0
Jump Loop2  / jump back to the start of Loop2

End,Load Sum2   / load value of Z 
Output      / display the sum Z
Halt       

/default values of A,B,C,Sum1,Sum2 and Count1
A, Dec 0
B, Dec 0
C, Dec 0
Sum1, Dec 0
Sum2, Dec 0
Count1, Dec 0
Decrement, Dec 1   / used to decrement Count1 variable

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage