Skip to content

Instantly share code, notes, and snippets.

Created December 23, 2012 11:32
Show Gist options
  • Save anonymous/4363016 to your computer and use it in GitHub Desktop.
Save anonymous/4363016 to your computer and use it in GitHub Desktop.
assembly
# for each integer from 1 to 1000
# mov ecx, 3
my $ecx = 3;
# mov esi, 3
my $esi = 3;
# mov edi, 3
my $edi = 5;
# xor ebx, ebx
my $ebx = 0; # sum
zero:
# mov eax, ecx
my $eax = $ecx;
# xor edx, edx
# div esi
my $edx = $eax div $esi;
# test edx, edx
# je _yes
goto yes if $edx;
# mov eax, ecx
$eax = $ecx;
# xor edx, edx
# div edi
$edx = $eax div $edi;
# test edx, edx
# jne _no
goto no unless $edx;
yes:
# add ebx, ecx
$ebx += $ecx;
no:
# inc ecx
$ecx++;
# cmp ecx, 1000
# jne _0
goto zero if $ecx != 1000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment