Started by Pokeh, April 03, 2014, 06:25:18 PM
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.
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 sumdone: halti: .data 0fifty: .data 50list: .data 4,5,-2,-3,12,0.end
Quote.begin clear sum1 clear sum2 clear i load a compare i jumplt 2 jumpgt 34: load b compare i jumplt 2 jumpgt 35: load c compare i jumplt 2 jumpgt 32: add sum2 store sum2 jump 43: add sum1 store sum1 jump 5 out sum1 out sum2done: haltsum1: .data 0sum2: .data 0i: .data 0a: .data 2b: .data -4c: .data 5.endloop: compare i jumpeq i donex add store sum increment i jump loop end loop