; ; Computes sum from i = 1 to N, placing result in sum. ; The algorithm used is the straightforward one, not that used by Gauss. ; ; ; we start with a bunch of standard macros ; zero: macro var subge var,var,next endmacro move: macro src,dst subge tmp,tmp,next subge tmp,src,next subge dst,dst,next subge dst,tmp,next endmacro ; ; increments variable var by 1 ; inc: macro var subge var,$-1,next endmacro .org 0x0100 gauss: zero sum zero i loop: inc i move N,k subge k,i,cont ret: subge 0,0,0 ; placeholder cont: zero k subge k,i,next subge sum,k,loop i: .word 0 tmp: .word 0 k: .word 0 N: .word 0 sum: .word 0