Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Marie Assembly language program that takes integers at inputs and return

ID: 3683250 • Letter: W

Question

Write a Marie Assembly language program that takes integers at inputs and returns the sum of the negative numbers and the sum of the positive numbers. For example: the user should be prompted to enter numbers one at a time followed by hitting enter and then when they are done they should type '0' indicating that they are done entering values. The program should add up all the numbers that are> 0 and all the numbers that are < 0. for example, if the user inputs: 5,6,-1 the program should return positive sum = 11 negative sum = -1 (this is all using the marie simulator)

I have almost completed the code but am getting two errors:

clear
while, input x
   store x
   load x
   skipCond 400
   jump end_While
if,   load x
   skipCond 800
   jump else
   load negativeSum
   add x
   store negativeSum
   jump while
else, load positiveSum
   add x
   store positiveSum
   jump while
end_While,output positiveSum
   output negativeSum
   Halt
positiveSum, dec 0
negativeSum, dec 0
x, dec 0

This is what the assembler produces:

Explanation / Answer

What I observed in your code is..
you written if else statement ... but missing endif statement .. i hope it helps you

**** Here is the modified code ***********
clear
while, input x
store x
load x
skipCond 400
jump end_While
if, load x
skipCond 800
jump else
load negativeSum
add x
store negativeSum
jump while
else, load positiveSum
add x
store positiveSum
jump while
end_if,output x
end_While,output positiveSum
output negativeSum
Halt
positiveSum, dec 0
negativeSum, dec 0
x, dec 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote