Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly Language > Re: Determine t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 7 Topic 4940 of 5166
Post > Topic >>

Re: Determine the size of a parameter from a macro

by Frank Kotler <fbkotler@[EMAIL PROTECTED] > Apr 3, 2008 at 08:43 PM

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
 




 7 Posts in Topic:
Determine the size of a parameter from a macro
=?ISO-8859-1?Q?St=E9phane  2008-04-03 13:25:57 
Re: Determine the size of a parameter from a macro
Frank Kotler <fbkotler  2008-04-03 20:43:24 
Re: Determine the size of a parameter from a macro
"Rod Pemberton"  2008-04-03 20:51:28 
Re: Determine the size of a parameter from a macro
=?ISO-8859-1?Q?St=E9phane  2008-04-03 14:41:36 
Re: Determine the size of a parameter from a macro
Frank Kotler <fbkotler  2008-04-03 22:49:24 
Re: Determine the size of a parameter from a macro
=?ISO-8859-1?Q?St=E9phane  2008-04-04 03:54:12 
Re: Determine the size of a parameter from a macro
=?ISO-8859-1?Q?St=E9phane  2008-04-04 05:58:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Oct 16 0:57:24 CDT 2008.