Greatest common divisor: Difference between revisions
Content added Content deleted
(Add 8086 assembly implementation, using AT & T syntax under linux) |
|||
Line 1: | Line 1: | ||
{{task|Arithmetic operations}}[[Category:Recursion]] |
{{task|Arithmetic operations}}[[Category:Recursion]] |
||
This task requires the finding of the greatest common divisor of two integers. |
This task requires the finding of the greatest common divisor of two integers. |
||
=={{header|8086 Assembly}}== |
|||
Using '''AT & T''' syntax under '''linux'''. |
|||
<lang 8086 Assembly> |
|||
.text |
|||
.global pgcd |
|||
pgcd: |
|||
push %ebp |
|||
mov %esp, %ebp |
|||
mov 8(%ebp), %eax |
|||
mov 12(%ebp), %ecx |
|||
push %edx |
|||
.loop: |
|||
cmp $0, %ecx |
|||
je .end |
|||
xor %edx, %edx |
|||
div %ecx |
|||
mov %ecx, %eax |
|||
mov %edx, %ecx |
|||
jmp .loop |
|||
.end: |
|||
pop %edx |
|||
leave |
|||
ret |
|||
</lang> |
|||
=={{header|ActionScript}}== |
=={{header|ActionScript}}== |
||
<lang ActionScript>//Euclidean algorithm |
<lang ActionScript>//Euclidean algorithm |