I have a piece of nasm assembly code which I want to be yasm compatible, but running the assembler on it gives errors on a couple of nasm-specific macros and includes, mostly related to the conditional
%if __BITS__ == 32
Where __BITS__
is the current bit mode.
Does YASM have equivalent functionality, or any other way to follow a code path depending on the bit mode?
You should be able to define a macro to use instead of bits
, like this (untested):
%macro myBits 1
bits %1
%assign __BITS__ %1
%endmacro
Of course in this case you'd have to replace every occurance of bits 16
, bits 32
and bits 64
in your source code with the equivalent myBits
macro.
Note that I'm not quite sure how bits
is implemented in YASM. It might be that it is a macro itself (that internally relies on a lower level directive like [bits]
). In this case you may be able to redefine the bits
macro and avoid the need to change anything.
For source code that doesn't use the bits
directive at all, I'd just define __BITS__
with the assembler's command line argument.