Non ancient versions of GNU's Assembler provide support for Intel syntax, but there are some issues. -msyntax=intel
isn't enough if you are looking for something closer to NASM/MASM's intel syntax. -msyntax=intel
will switch the order of the operands so the destination is the first operand and the source operand are after. However you still need to prefix all the register names with %
percent. So you'd likely find this would have worked:
mov %ebx, 0
mov %eax, 1
That would likely fix the errors on the MOV instructions. This is probably not what you want. To use Intel syntax without the %
prefixes you can add this to the top of each of your assembly files:
.intel_syntax noprefix
By specifying this at the top of each of your assembly files you no longer need to assemble with the option -msyntax=intel
.
The junk 'h' after expression
error is because GNU's assembler (even in Intel syntax mode) doesn't support constants with the base specified as a suffix. In your case 80h
isn't recognized. GNU assembler requires base to specified by a prefix like 0x
for hexadecimal. So to eliminate this error use:
int 0x80
Fixing these issues should allow this code to assemble.
.intel_syntax noprefix
– Erse.globl
and.global
– Erseint 80h
toint 0x80
as GNU assembler doesn't support the suffixes likeh
. It uses prefixed notation to determine the base of a number0x
for hex. – Erse