assembly - What is the syntax for OSX x86 GAS .macros? -
i having lot of trouble getting tiny macro work.
.macro int_kernel subl $4, %esp int $0x80 addl $4, %esp .endm
running assembler,
-arch i386 upper.s -o ./upper.o upper.s:51:expecting operand before ','; got nothing upper.s:51:suffix or operands invalid `int' upper.s:51:expecting operand before ','; got nothing
the errors come osx macro syntax using $0,$1,... refer macro's parameters.
correct osx syntax constants in macro?
solution: 2 dollars signs must used in subl $$4, %esp
this correct syntax gas macro. uses no parameters. 3 instructions correct written.
the as
not gnu. it's distant relative, lot of modifications apple, can't rely on gnu documentation explain anything. example, try -arch
option in gnu documentation... doesn't exist.
you're going have refer apple's documentation. keep copy of here: http://developer.apple.com/documentation/developertools/reference/assembler
one simple difference difference have changed end-of-macro directive .endm
.endmacro
. besides that, yes looks replace $0
, $1
, , on macro arguments instead of using named arguments gnu does. , don't tell how include literal $
in macro output! (how did documentation author overlook question? can't rare thing want do)
in summary, since apple has modified assembler different macro syntax , failed document we're left guessing. i'd try putting space after each dollar sign, hoping them through macro process unharmed while not damaging ability recognized immediate operand signifiers. if didn't work, next attempt putting backslash before dollar sign, doubling dollar sign, finding out whether real gnu assembler can installed on macos instead of hacked-and-underdocumented apple version...
Comments
Post a Comment