Created
July 23, 2011 10:33
-
-
Save rik0/1101283 to your computer and use it in GitHub Desktop.
Horrible Code Generation from Real Basic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_AtkinSieve.AddNumbers%i4%o<AtkinSieve>i4i4: | |
0007f688 pushl %ebp | |
0007f689 movl %esp,%ebp | |
0007f68b subl $0x00000038,%esp | |
0007f691 movl %esp,0xffffffcc(%ebp) | |
0007f697 movl %ebp,%eax | |
0007f699 movl 0x08(%eax),%eax | |
0007f69c movl %eax,0xf8(%ebp) | |
0007f69f movl %ebp,%eax | |
0007f6a1 movl 0x0c(%eax),%eax | |
0007f6a4 movl %eax,0xf0(%ebp) | |
0007f6a7 movl %ebp,%eax | |
0007f6a9 movl 0x10(%eax),%eax | |
0007f6ac movl %eax,0xe8(%ebp) | |
0007f6af xorl %eax,%eax | |
0007f6b1 movl %eax,0xe0(%ebp) | |
0007f6b4 movl %eax,0xd8(%ebp) | |
0007f6b7 pushl %eax | |
0007f6b8 pushl %eax | |
0007f6b9 pushl %eax | |
0007f6ba pushl 0xf8(%ebp) | |
0007f6bd calll 0x0008029f | |
0007f6c2 movl 0xcc(%ebp),%esp | |
0007f6c5 calll 0x0008022f | |
0007f6ca movl 0xcc(%ebp),%esp | |
0007f6cd movl 0xf0(%ebp),%eax | |
0007f6d0 movl 0xe8(%ebp),%ecx | |
0007f6d3 addl %ecx,%eax | |
0007f6d5 movl %eax,0xd8(%ebp) | |
0007f6d8 movl %eax,0xe0(%ebp) | |
0007f6db jmp 0x0007f6e0 | |
0007f6e0 xorl %eax,%eax | |
0007f6e2 movl %eax,0xd0(%ebp) | |
0007f6e5 jmp 0x0007f6f8 | |
0007f6ea adcl %eax,(%eax,%eax) | |
0007f6ed addb %al,(%eax) | |
0007f6ef addb %dl,%al | |
0007f6f1 decl 0xffffcca5(%ebx) | |
0007f6f7 call *0x50(%eax) | |
0007f6fa pushl %eax | |
0007f6fb pushl 0xf8(%ebp) | |
0007f6fe calll 0x0008024f | |
0007f703 movl 0xcc(%ebp),%esp | |
0007f706 xorl %eax,%eax | |
0007f708 movl %eax,0xf8(%ebp) | |
0007f70b movl 0xd0(%ebp),%ecx | |
0007f70e cmpl %eax,%ecx | |
0007f710 je 0x0007f735 | |
0007f716 pushl %eax | |
0007f717 pushl %eax | |
0007f718 pushl %eax | |
0007f719 pushl %ecx | |
0007f71a calll 0x0008023f | |
0007f71f movl 0xcc(%ebp),%esp | |
0007f722 pushl %eax | |
0007f723 pushl %eax | |
0007f724 pushl %eax | |
0007f725 pushl 0xd0(%ebp) | |
0007f728 calll 0x0008024f | |
0007f72d movl 0xcc(%ebp),%esp | |
0007f730 xorl %eax,%eax | |
0007f732 movl %eax,0xd0(%ebp) | |
0007f735 movl 0xe0(%ebp),%eax | |
0007f738 addl $0x00000038,%esp | |
0007f73e popl %ebp | |
0007f73f ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_AtkinSieve.AddNumbers%i4%o<AtkinSieve>i4i4: | |
0007f688 pushl %ebp | |
0007f689 movl %esp,%ebp | |
0007f68b subl $0x00000038,%esp | |
0007f691 movl %esp,0xffffffcc(%ebp) | |
0007f697 movl %ebp,%eax | |
0007f699 movl 0x08(%eax),%eax | |
0007f69c movl %eax,0xf8(%ebp) | |
0007f69f movl %ebp,%eax | |
0007f6a1 movl 0x0c(%eax),%eax | |
0007f6a4 movl %eax,0xf0(%ebp) | |
0007f6a7 movl %ebp,%eax | |
0007f6a9 movl 0x10(%eax),%eax | |
0007f6ac movl %eax,0xe8(%ebp) | |
0007f6af xorl %eax,%eax | |
0007f6b1 movl %eax,0xe0(%ebp) | |
0007f6b4 movl %eax,0xd8(%ebp) | |
0007f6b7 pushl %eax | |
0007f6b8 pushl %eax | |
0007f6b9 pushl %eax | |
0007f6ba pushl 0xf8(%ebp) | |
0007f6bd calll 0x0008029f | |
0007f6c2 movl 0xcc(%ebp),%esp | |
0007f6c5 calll 0x0008022f | |
0007f6ca movl 0xcc(%ebp),%esp | |
0007f6cd movl 0xf0(%ebp),%eax | |
0007f6d0 movl 0xe8(%ebp),%ecx | |
0007f6d3 addl %ecx,%eax | |
0007f6d5 movl %eax,0xd8(%ebp) | |
0007f6d8 movl %eax,0xe0(%ebp) | |
0007f6db jmp 0x0007f6e0 | |
0007f6e0 xorl %eax,%eax | |
0007f6e2 movl %eax,0xd0(%ebp) | |
0007f6e5 jmp 0x0007f6f8 | |
0007f6ea adcl %eax,(%eax,%eax) | |
0007f6ed addb %al,(%eax) | |
0007f6ef addb %dl,%al | |
0007f6f1 decl 0xffffcca5(%ebx) | |
0007f6f7 call *0x50(%eax) | |
0007f6fa pushl %eax | |
0007f6fb pushl 0xf8(%ebp) | |
0007f6fe calll 0x0008024f | |
0007f703 movl 0xcc(%ebp),%esp | |
0007f706 xorl %eax,%eax | |
0007f708 movl %eax,0xf8(%ebp) | |
0007f70b movl 0xd0(%ebp),%ecx | |
0007f70e cmpl %eax,%ecx | |
0007f710 je 0x0007f735 | |
0007f716 pushl %eax | |
0007f717 pushl %eax | |
0007f718 pushl %eax | |
0007f719 pushl %ecx | |
0007f71a calll 0x0008023f | |
0007f71f movl 0xcc(%ebp),%esp | |
0007f722 pushl %eax | |
0007f723 pushl %eax | |
0007f724 pushl %eax | |
0007f725 pushl 0xd0(%ebp) | |
0007f728 calll 0x0008024f | |
0007f72d movl 0xcc(%ebp),%esp | |
0007f730 xorl %eax,%eax | |
0007f732 movl %eax,0xd0(%ebp) | |
0007f735 movl 0xe0(%ebp),%eax | |
0007f738 addl $0x00000038,%esp | |
0007f73e popl %ebp | |
0007f73f ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim limit As Double = Sqrt(maxInteger) | |
#pragma BackgroundTasks False | |
#pragma BoundsChecking False | |
#pragma NilObjectChecking False | |
for x as Integer = 1 to limit | |
Dim x2 As Integer = x * x | |
Dim x2_3 As Integer = 3 * x2 | |
for y as Integer = 1 to limit | |
Dim y2 As Integer = y * y | |
Dim n As Integer = 4 * x2 + y2 | |
if n <= maxInteger and (n mod 12 = 1 or n mod 12 = 5) then | |
isPrime(n) = not(isPrime(n)) | |
end | |
n = x2_3 + y2 | |
if n <= maxInteger and (n mod 12 = 7) then | |
isPrime(n) = not(isPrime(n)) | |
end | |
n=x2_3 - y2 | |
if (x > y) and (n <= maxInteger) and (n mod 12 = 11) then | |
isPrime(n) = not(isPrime(n)) | |
end | |
next | |
next | |
for n as Integer = 5 to limit step 2 | |
if isPrime(n) then | |
Dim k As Integer = n * n | |
Dim m As Integer = k | |
Dim i As Integer = 1 | |
while m < maxInteger | |
isPrime(k) = False | |
i = i + 2 | |
m = i * k | |
wend | |
end | |
next | |
isPrime(2) = True | |
isPrime(3) = True | |
#pragma BoundsChecking True | |
#pragma BackgroundTasks True | |
#pragma NilObjectChecking True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment