1

I have the below program written and tried to compile/build it in XCODE (Version 10.1 (10B61)), but failed.

.386
.model flat
.code

start   PROC
        mov eax,213
        add eax,432

        rel
start   endp
end     start

This code was extracted from a study video on assembly language and I believe XCODE is capable of handling.

However, I'm presented with the following errors,

error: unexpected token at start of statement .386 ^

error: unknown directive .model flat ^

error: unknown directive .code .code ^

error: invalid instruction mnemonic 'start' start PROC ^

error: unknown use of instruction mnemonic without a size suffix mov eax,213 ^

error: unknown use of instruction mnemonic without a size suffix add eax,432 ^

error: invalid instruction mnemonic 'rel' rel ^

error: invalid instruction mnemonic 'start' start endp ^

error: invalid instruction mnemonic 'end' end start

Can someone kindly suggest any solutions, please. By the way, I'm a novice to programming as well and this is the first time I have used XCODE.

Regards Thusitha

Thusitha
  • 11
  • 1
  • That's MASM syntax (the assembler that comes with Visual Studio). XCode uses clang, which like GCC uses GAS syntax for directives, and by default AT&T syntax for instructions. Look at the asm output of a C program you compile, like in [How to remove "noise" from GCC/clang assembly output?](https://stackoverflow.com/q/38552116). Or search for MacOS asm example: anything more than just returning a value is going to depend on calling conventions and x86-64 vs. i386 differences; asm is not portable. Also, `rel` isn't an instruction; you probably meant `ret`. – Peter Cordes May 26 '21 at 19:53

0 Answers0