working on a school project, I'm trying to figure out how to compile a simple c program with assembly code on Xcode running the latest Xcode update (12.0.1). We are supposed to use AT&T syntax witch is what I found the syntax to be used in Xcode.
Here is the c code:
#include <stdio.h>
extern int MaxOfThree(int, int, int);
int main()
{
printf("The largest value among 1, -4 och -7 is %d\n", MaxOfThree(1,-4,-7));
return 0;
}
Assembly code:
.text
.global MaxOfThree
MaxOfThree:
cmpl %esi, %edi
cmovl %esi, %edi
cmpl %edx, %edi
cmovl %edx, %edi
movl %edi, %eax
ret
The error I'm getting is:
error: unexpected token in directive
.global MaxOfThree MaxOfThree:
^
I also got another error with another program saying absolute addressing is not allowed with x86_64 syntax. what is wrong?