' Program to output digits of PI
input "Enter number of digits required (multiple of 4): "; ndigits
m = int(ndigits / 4) * 14 or 0
!DIM P% 100, B%(m) : B%() = 20 : [OPT 2
!.pidig mov ebx,^B%(0) : mov ecx,[^c] : xor edx,edx : lea ebp,[ecx*2-1]
!.pi1 imul edx,ecx : mov eax,[ebx+ecx*4] : imul eax,100 : add eax,edx
!cdq : div ebp : mov [ebx+ecx*4],edx : mov edx,eax : sub ebp,2 : loop pi1
!mov eax,edx : ret :]
e = 0
l = 2
for c = m to 14 step -7
!d = USR(pidig)
select case
case d = 99: e = e * 100 + d : l += 2
case c = m: print int(d / 100) / 10; : e = d mod 100
case else:
print right$("00000000000";(e + int(d / 100)), l);
e = d MOD 100 : l = 2
end select
next
end