Greatest common divisor: Difference between revisions

m
Moving 8086 Assembly to x86 Assembly
(Add 8086 assembly implementation, using AT & T syntax under linux)
m (Moving 8086 Assembly to x86 Assembly)
Line 1:
{{task|Arithmetic operations}}[[Category:Recursion]]
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}}==
<lang ActionScript>//Euclidean algorithm
Line 1,570 ⟶ 1,542:
|1071 1029 gcd
=21
 
 
=={{header|8086x86 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>
Anonymous user