Hello I am writing some simple c/assembly programs for my college course and have run into an unknown compile error using Xcode to build and run. It builds successfully but says "GDB: program received signal: 'EXC_BAD_ACCESS'" I am not sure what that means...maybe i am returning a wrong value from my assembly function? to the main C program...any debug help would be much appreciated.
Here is my C main funciton and Assembly _isOdd(function to tell whether number is odd or even).
P.S. using i386 architecture. Thanks so much
Here is my C main funciton and Assembly _isOdd(function to tell whether number is odd or even).
Code:
int extern _AisOdd;
int main(void) {
int k;
k = AisOdd(5);
printf("\n%d",k);
k = AisOdd(6);
printf("\n%d",k);
return EXIT_SUCCESS;
}
.globl _AisOdd
_AisOdd:
//push base pointer of the calling function
pushl %ebp
movl %esp, %ebp
movl $1, 12(%ebp) //declare int variable t = 1
movl 8(%ebp), %eax //declare int variable x
movl %eax, %ebx
sarl $1, %ebx
movl %ebx, %ecx
sall $1, %ecx
cmpl %ecx, %eax
JNE leave
movl $0, 12(%ebp)
leave:
popl %ebp
ret