May 02, 2024, 07:10:33 AMLatest Member: mori
BoutCheetah » Forum » Other » Off Topic » Some Coding Help

Some Coding Help

Started by Pokeh, April 03, 2014, 06:25:18 PM

Previous topic - Next topic

Pokeh

The question:

QuoteWrite 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.

It's in Java, with these commands:



What I've got so far:

Quote.begin
   clear sum
   clear i
   load list
   if i>list then jump
loop:   compare i
   jumpeq i done
   compare list
   if i>0
   add i
   store sum
   increment i
   jump loop
   out sum
done:   halt
i:   .data 0
fifty:   .data 50
list:   .data 4,5,-2,-3,12,0
.end

Bleh

Pokeh

plz someone help i can offer gigas or whatever

Pokeh

https://ca.answers.yahoo.com/question/index?qid=20140403180112AArINIY

seeing shyt like that on the front page of that, don't think so.

i don't wanna be tracked by google either. i'm deleting this topic after I get an answer...

update on what I've got:

Quote.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

Copyright © ZylonGaming 2009 - 2024
-Terms of Use-