143k views
0 votes
Write a Marie program named: PROG2.max that will Input a variable named: Max. (Note the file extension must be: .max) If Max is equal to zero, Halt the program. Output the variable Max and then input value(s), adding them to Sum until Sum > Max. You should Output each sum as it is incremented. When Sum > Max, reset variable(s) and start program again. Examples: Input Output Result (Nlax=) 50 50 Store Max (Incr=) 25 25 Incr; Sum < Max, get another (Incr=) 25 50 Incr; Sum = Max, get another (Incr=) 25 75 Incr; Sum > Max, Reset Sum = 0 25 25 Store Max 10 10 Incr; Sum < Max, get another 10 20 her; Sum < Max, get another 10 30 Incr; Sum > Max, Reset Sum = 0 0 Halt (No output!)

User Mohsen TOA
by
8.6k points

1 Answer

4 votes

Answer:

ORG 100

Start, Load Max // Load Max from memory

Skipcond 800 // If Max = 0, skip next instruction

Jump Halt // Jump to Halt if Max = 0

Output // Output Max

Input // Input value for Incr

Store Incr // Store Incr in memory

Loop, Load Incr // Load Incr from memory

Add Sum // Add Incr to Sum

Store Sum // Store Sum in memory

Load Sum // Load Sum from memory

Subt Max // Subtract Max from Sum

Skipcond 400 // If Sum <= Max, skip next instruction

Jump Reset // Jump to Reset if Sum > Max

Output // Output Sum

Input // Input value for Incr

Store Incr // Store Incr in memory

Jump Loop // Jump to Loop

Reset, Clear Sum // Reset Sum to 0

Load Max // Reload Max from memory

Store Max // Store Max back in memory

Jump Loop // Jump back to Loop

Halt, Halt // Halt the program

Max, DEC 50 // Variable for Max, initialized to 50

Incr, DEC 0 // Variable for Incr, initialized to 0

Sum, DEC 0 // Variable for Sum, initialized to 0

END Start // End of program

Step-by-step explanation:

User Miamy
by
9.0k points

No related questions found