;samp2.mc ;; by tsaiwn@csie.nctu.edu.tw ;this machine program read N ; and calculate 1+2+...+N 2101 ; R1=1 d624 ; print string "N=" d200 ; read integer into R0 29 01 ; R9 = 1 2500 ; R5 = 0, used to store sum 5 5 5,9 ; R5 = R5 +R9 :again B9 12 ; if done goto :ok 5991 ; R9 = R9 + 1 B0 0a ; goto :again d6 28 ; print "Sum from 1 to " :ok d300 ; out int from R0 d625 ; print "=" 4050 ; move r5 to r0 , the sum d300 ; out int from R0 d620 ; out cr/lf c000 ; halt 0d0a ; CR/LF (:20h) 2424 ; $ 4e3d ; "N=" (:24h) 2424 ; $$ 5375 ; Su (:28h) 6d20 ; m 6672 ; fr 6f6d ; om 2031 ; 1 2074 ; t 6f20 ; o 2424 ; $$ c000 ;end of this program