News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Can MASM32 be precise ?

Started by sw337, September 13, 2006, 11:09:09 AM

Previous topic - Next topic

sw337

I hate to type long directives in assembler.

Look how crafty they were when they invented mnemonics like mul for multiply.

But in MASM32 i have to type OFFSET to get an address offset.

And then i have to type in DWORD PTR for some memory references.

And then i have to type in (SDWORD PTR eax > 0).

Shouldn't an assembler be precise ?


Tedd

Precise does not mean concise :P
It is more likely that the more precise you try to be, the more verbose you must be in order to cover all possible exceptions.

That said, I do agree with you to a point. It's just a matter that masm has been given this syntax, though in many cases the default behaviour is what you want, so there's no requirement to always be so precise (allowing you to be less verbose, and more concise!)
But masm is not the only assembler, and others may have more agreeable syntax.

If you really need to, you can create a few macros that allow you to replace a lot of these longer terms with single letters or shorter words; just keep in mind that readability of code is also a great benefit. ++qs$n/zzf!_*&2 can be a valid program, but you wouldn't want to have to program like that :lol
No snowflake in an avalanche feels responsible.

zooba

C attempts to be concise, especially when it comes to pointers. Of course, there are only so many suitable characters, which is why the ampersand (&) and the asterisk (*) have about 3 meanings each!

Assembly only requires the pointer directives when it can't figure it out by itself (ie. moving an immediate to a dereferenced register memory location, mov [edi], 2?).

The SDWORD PTR is quite a mouthful, but then again, would a slightly different comparision operator be any better? Along with the rules about when and when not to use it? I suspect not.

hutch--

Any of the proper Intel syntax assemblers have the capacity to fully specify the instructions, its just that most are used to using the more compact notation which in most instances it will handle. The reason why you must use the full notation in some instances is to avoid ambiguity or to give the assembler ewnough info to convert the mnemonic into an opcode.

In MASM as with any assembler, you MUST be precise and in some instances that means you must be verbose.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Kestrel

Unsigned, CF (Carry Flag) !

BYTE =  8 bit
WORD = 16 bit
DWORD = 32 bit

   cmp x, y   ; w = x - y
              ; x >= y, CF = 1
              ; x <  y, CF = 0


Signed, SF (Sign Flag) <--  from MSBit of w

SBYTE =  8 bit   
SWORD = 16 bit
SDWORD = 32 bit

   cmp x, y      ; w = x - y
            ; x >= y, SF (MSB of w) = 0
            ; x <  y, SF (MSB of w) = 1


Microsoft MACRO Assembler is "default Unsigned" .

.if (al < 0) ; <-- Never do this ! (al: 0 ~ 0FFh, 0~255) >= 0
   .....
.endif


.if (al < SBYTE ptr 0) ; <- OK. (0~7Fh,0~127) >= 0, (80h~0FFh,-128~-1) < 0
   .....
.endif