Hi!

Well, this might sound a silly question, but anyway. I am translating a VERY long DOS asm program into win32asm. The original code contained a lot of lines like this:

mov ,al

so I write this:

mov BYTE PTR ,al

If I remove "BYTE PTR" then I get an assembler error: "Invalid instruction operands". Well, I've been using the previous versions of MASM (from 4.00 to 6.11) for all my life and that "BYTE PTR" was only needed in cases where there could be a confusion, for example:

mov ,0 Is zero a byte or a word? -> mov BYTE PTR ,0

But MASM used to be clever enough to guess the proper size if a register like "al" was involved (like in the case above) so that the expression BYTE PTR was redundant. Now I have to write BYTE PTR all the time even if it's obvious I'm talking about bytes, and this makes the code a little bit dirty. Is there an option in MASM to bring that ability back?

Thanks!
Posted on 2002-04-08 16:46:49 by Salieri
If ebx is a pointer to an address in memory then mov , al or mov BYTE PTR , al should work perfectly, if ebx is use to store a value then you should use movzx ebx, al or movsx, al whichever suits your need.

As far as the older masm assemblers, I don't know since I haven't tried the old ones. So I can't comment on that.
Posted on 2002-04-08 17:12:24 by stryker
Salieri,

The syntax,

MOV , AL

is normal MASM syntax which works on every version of ML.EXE from 6.00 upwards. As you have already mentioned, you only use the BYTE PTR directive when the size of the data is not specified as with an immediate value.

Regards,

hutch@movsd.com
Posted on 2002-04-08 19:14:43 by hutch--
Personally, I always prefer to specify the byte/word/dword ptr...
It is clearer in the source and make you figure out in one glance the size of the operand you are working with.
In some cases, it can prevent confusion, because you think your code will do something and when assembled do something else.
If you specify the "byte/word/dword ptr" and are doing something wrong, the assembler will tell you...
Posted on 2002-04-09 03:37:12 by JCP

Personally, I always prefer to specify the byte/word/dword ptr...
It is clearer in the source and make you figure out in one glance the size of the operand you are working with.
In some cases, it can prevent confusion, because you think your code will do something and when assembled do something else.
I fully second that.. also, I prefer to use a more logical U32/S32/P32 (pointer) instead of a generic DWORD, U16/S16 instead of WORD, ASC/U8 instead of BYTE, etc..
Posted on 2002-04-09 05:24:29 by Maverick
Sorry people, you're right. mov ,al is accepted by masm. I wanted to simplify my sample so much that finally it was wrong. The "invalid instruction operands" error happens if I use expresions like this:

buffer label DWORD
[... chunk of memory...]

mov buffer,al

This USED to work properly when assembling 16-bit code, but now it doesn't. I must specify "mov BYTE PTR buffer,al" to make it work, and it shouldn't be needed because ithe size is obvious. Is it that masm is more strict about sizes when it works with 32-bit offsets?

I agree with Readiosys and Maverick, it's smarter to write the types all the time but as I said I am translating a very long 16-bit DOS program and I'd rather not have to add all the BYTE/WORD PTRs by hand (it used to work without that).

Thank you again.
Posted on 2002-04-09 07:21:12 by Salieri