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

Write an assembly language program to do the following, and run it and test it o

ID: 3810247 • Letter: W

Question

Write an assembly language program to do the following, and run it and test it on the lab simulator:

Read in integers until a zero is read in. Keep a total of both the quantity and the sum of the negative integers and the positive integers. Once a zero is read in (signifying the end of the input) then:

         If there were more positive than negative integers, or an equal number, print out a 0 and the sum of the positive integers.

         If there were more negative than positive integers, print out a 1 and the sum of the negative integers.

Hand in your answer to this question as

1.      A screen shot of the lab assembler program once your program has been assembled successfully, showing that it assembled successfully.

2.      A complete separate print-out of your source code with comments, as it may not all be visible in the assembler simulator window.

3.      Screen shots of the von Neumann assembler execution window after execution of your program executed with some sample data, for both situations (more negative integers, and more positive integers).

4.      The sample data you used to test the program in both situations.

Note that you can resize both windows by "pulling" on the corners until all of your code is visible.

Explanation / Answer

begin
   clear sum1
   clear sum2
   clear i
   load a
   compare i
   jumplt 2
   jumpgt 3
4:   load b
   compare i
   jumplt 2
   jumpgt 3
5:   load c
   compare i
   jumplt 2
   jumpgt 3
2:   add sum2
   store sum2
   jump 4
3:   add sum1
   store sum1
   jump 5
   out sum1
   out sum2
done:   halt
sum1:   .data 0
sum2:   .data 0
i:   .data 0
a:   .data 2
b:   .data -4
c:    .data 5
.end

loop:   compare i
   jumpeq i done
x   add
   store sum
   increment i
   jump loop
   end loop

i can give you this answe but i dont have any assembler so i cant attach the picture

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