It must have some kind of default. I tried on my machine, which says as
is:
Apple Inc version cctools-836, GNU assembler version 1.38
And I get these results:
$ cat example.s
cmp $0, 8(%rsp)
$ make example.o
as -o example.o example.s
$ otool -tV example.o
example.o:
(__TEXT,__text) section
0000000000000000 cmpl $0x00,0x08(%rsp)
So on my machine, it picked cmpl
. Using gcc
rather than as
gave me the same results, but using clang
produced the error you expect:
$ clang -c example.s
example.s:1:2: error: ambiguous instructions require an explicit suffix (could be 'cmpb', 'cmpw', 'cmpl', or 'cmpq')
cmp $0, 8(%rsp)
^