Hello,
I have the following files:
mainlinemem.c...
Code:
#include <stdio.h>
int gcdmem(int a,int b);
int main()
{
int result;
int a;
int b;
a = 46;
b = 90;
printf("%d and %d have a gcd of %d\n",a,b,gcdmem(a,b));
a = 9863;
b = 41272;
printf("%d and %d have a gcd of %d\n",a,b,gcdmem(a,b));
}
and:
gcdmem.asm...
Code:
segment .data
segment .bss
x: resd 1
y: resd 1
segment .text
global gcdmem
gcdmem:
push ebp
mov ebp,esp
mov eax,[ebp+8] ; x
mov [x],eax
mov eax,[ebp+12] ; y
mov [y],eax
looptop:
mov eax,[x]
cmp eax,0 ; if (x == 0) we're done
je goback
mov ebx,[y]
cmp eax,ebx ; make certain x is the larger number
jge modulo
mov [x],ebx
mov [y],eax
modulo:
mov ebx,[y]
mov eax,[x]
cdq ; set up for division
idiv ebx ; divide edxeax by ebx
mov [x],edx ; the remainder is in edx
jmp looptop
goback:
mov eax,[y] ; return y
mov esp,ebp
pop ebp
ret
Can anyone show me how to compile these files so I can run it?
I am on Windows XP and have mingw installed, and also NASM and alink.exe.
I've used google to find the answer, but every solution I tried was unsuccessful.