1
Name:
Anonymous
2009-05-06 16:28
Do you guys know how to write this C++ code into assembly language?
<code>
int GCD(int x, int y)
{
x = abs(x); //absolute value
y = abs(y);
do {
int n = x % y;
x = y;
y = n;
} while (y > 0);
return x;
}
</code>
4
Name:
Anonymous
2009-05-06 16:57
But compilers do that, translate sepples into asm.
5
Name:
Anonymous
2009-05-06 17:13
hmm..somethings not right. I'm getting errors.
LCFI5:
movl 12(%ebp), %ecx
; wat
movl %eax, %edx
sarl $31, %edx
xorl %edx, %eax
movl %edx, %esi
subl %eax, %esi
; wat
movl %ecx, %eax
sarl $31, %eax
xorl %eax, %ecx
movl %eax, %edi
subl %ecx, %edi
jmp L4
L8:
movl %edi, %esi
movl %ecx, %edi
L4:
movl %esi, %edx
movl %esi, %eax
sarl $31, %edx
idivl %edi
testl %edx, %edx
movl %edx, %ecx
jg L8
movl %edi, %eax
popl %esi
popl %edi
leave
ret
8
Name:
Anonymous
2009-05-06 17:35
How come I didn't get that...sigh
9
Name:
Anonymous
2009-05-06 18:30
LEARN WHAT A COMPILER IS AND USE IT!
11
Name:
Anonymous
2009-05-07 6:55
No, John, you are the errors.
12
Name:
Anonymous
2009-05-07 12:37
>>10
Once you start declaring variables in your ASM code, you do not really write assembly code, but fall into the endless pit of
fail and
AIDS .
MLIHBT
14
Name:
Anonymous
2010-12-17 1:39
Erika once told me that Xarn is a bad boyfriend