Practical Numbers by msk

A:.asciz"%d\n"
.globl main
main:enter $8,$0
B:mov Z,%eax
mov Y,%esi
lea 1(%eax),%ebx
C:cmp $500,%ebx
mov %ebx,%edi
jg F
mov $2,%ecx
mov $3,%esi
D:mov %ebx,%edx
mov %ebx,%eax
sar $31,%edx
idiv %ecx
mov $0,%eax
test %edx,%edx
cmove %ecx,%eax
add $1,%ecx
add %eax,%esi
cmp %esi,%ecx
jl D
add $1,%ebx
cmp %edi,%ecx
jle C
mov %esi,Y
mov %edi,Z
mov %edi,4(%esp)
movl $A,(%esp)
call printf
jmp B
F:leave
.comm Z,4,2
.comm Y,4,2

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page