Permalink
Browse files

sum [x * x | x <- [0 .. 50]] in dcpu-16 assembly

  • Loading branch information...
jaspervdj committed Apr 6, 2012
1 parent a891f79 commit 41ce97a8b3deb0c69f950aa6a8d34ec85fa36a8d
Showing with 15 additions and 0 deletions.
  1. +15 −0 examples/sum-squares.s
View
@@ -0,0 +1,15 @@
; X <- sum [n * n | n < [0 .. 50]]
; When finished, X should be 42925 (0xa7ad)
SET X, 0 ; Sum accumulator
SET I, 0 ; Iterator value
SET Y, 50 ; Max value
:loop SET A, I
MUL A, A
ADD X, A
ADD I, 1
IFG I, Y
SET PC, done
SET PC, loop
:done SET I, I

0 comments on commit 41ce97a

Please sign in to comment.