Stéphane thibaud wrote:
> Is it possible to determine the size of a paramter (possibly a
> register) from within a macro in NASM. I have a macro in which I want
> to assemble different code depending of the size of the parameter (16-
> bit or 32-bit). If it's 16-bit the parameter must be copied to a 32-
> bit register that has the first 16-bits cleared and after that the 32-
> bit register can be pushed onto stack. If it's already 32-bit it can
> be pushed on stack immediately. Simply doing 'o32 push reg' doesn't
> solve my problem as the first 16 bits (the most significant bits)
> would be undefined...
Nasm doesn't remember much about "type", including size. If you know
that the parameter is a reg, 16-bit or 32-bit, you might be able to:
....
%ifidni %1, ax
movzx eax, %1
%elifidni %1, bx
movzx ebx, %1
....
....
....
%endif
push %1
....
Maybe a more sophisticated Nasm user can think of a "cleaner" way. I
don't think this is something Nasm's particularly good at...
Best,
Frank


|