tinyvm/programs/euler1_nodiv.vm

32 lines
572 B
Text

# This algorithm was copied from an x86 solution to the first Project Euler problem.
# It was authored by rayfil.
# http://projecteuler.net/index.php?section=forum&id=14
# Specify a label named "start," and it will become the entrypoint for the program.
start: mov ebx, 1000000
xor edx, edx
mov eax, 3
loop0: add edx, eax
add eax, 3
cmp eax, ebx
jl loop0
# A line prepended with a pound sign is commented out
mov eax, 5
loop1: add edx, eax
add eax, 15
cmp eax, ebx
jl loop1
mov eax, 10
loop2: add edx, eax
add eax, 15
cmp eax, ebx
jl loop2
prn edx