;; file: countEven.s ;; author: MCS-178 ;; date: Fri Sep 6 09:31:56 CDT 2019 ;; ;; This program first reads in a positive integer n that tells ;; how many integers will follow. Then it reads in the next n ;; integers and prints how many of these are even. ;; ;; The SLIM code translates the following python code: ;; ;; n = int(input()) ;; oddCount = 0 ;; for i in range(0, n): ;; ai = int(input()) ;; count += ai % 2 ;; print(n - oddCount) allocate-registers one two n oddCount loop end test ai tmp i evenCount li one 1 li two 2 li loop loopL li end endL read n li oddCount 0 li i 0 loopL: slt test i n jeqz test end read ai rem tmp ai two add oddCount oddCount tmp add i i one j loop endL: sub evenCount n oddCount write evenCount halt