News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Was there a version of MASM that accepted the following syntax?

Started by bugthis, October 14, 2024, 08:01:02 PM

Previous topic - Next topic

bugthis

register = some register like AX, DX, CX etc.
const = a constant (i.e. usually a number like 3, 42, 70, etc.in binary, decimal, octal or hex notation. )
Code (asm) Select
MOV [BX + const], register ; example 1
MOV [BX] const, register ; example 2, Note the missing + operator between [BX] and const.
MOV const [BX], register ; example 3, Note the missing + operator between const and [BX]

All three examples are written abstractly and are from an old book. You might think that this might be a misprint or that the plus sign was accidentally forgotten in both cases, but in the book there is also the following sentence below the examples:
QuoteThe square brackets replace the "+" sign.

So it was not an accident that the plus sign was omitted.

If I make real code from examples 1 and 2 following the above rules, e.g.:
Code (asm) Select
MOV [BX] 42, AX ; example 2, Note the missing + operator between [BX] and 42.
MOV 42 [BX], AX ; example 3, Note the missing + operator between 42 and [BX]

Neither MASM v 5.10 nor JWASM v2.14 accepts this.
I have to put a + sign in both examples so that it assembles without errors.
In my opinion it also makes more sense with a plus sign.

I also tested this with MASM 1.1, but MASM 1.1 does not accept the code for other reasons.

So I wonder, did the author make a mistake when writing the book or is there actually an older version before MASM 5.10 that accepts this syntax? Or is there perhaps a newer version that accepts this without the plus operator?

I have the 9th revised edition of the book here, which was printed in 2000.
The original book is probably much older. I suspect that it was published at least before the i486 and was later revised.

zedd151

Quote from: bugthis on October 14, 2024, 08:01:02 PMNeither MASM v 5.10 nor JWASM v2.14 accepts this.
Then Don't do it! See how simple that is?  :biggrin:

Quote from: bugthis on October 14, 2024, 08:01:02 PMI have to put a + sign in both examples so that it assembles without errors.
In my opinion it also makes more sense with a plus sign.
Then why, oh why, are you still trying to do something that doesn't work? 
Ventanas diez es el mejor.  :azn:

bugthis

You should read more carefully. It doesn't seem to be one of your strengths.

This was my question:
QuoteWas there a version of MASM that accepted the following spelling?
Not more, not less.

zedd151

Quote from: bugthis on October 14, 2024, 10:17:53 PMYou should read more carefully. It doesn't seem to be one of your strengths.
That is quite possible.  :smiley:  Especially before I have had my morning coffee.  :biggrin:

Your question should  probably be: "Was there a version of MASM that accepted the following syntax?"   :tongue:
Ventanas diez es el mejor.  :azn:

bugthis

Quote from: zedd151 on October 14, 2024, 10:27:38 PMYour question should  probably be: "Was there a version of MASM that accepted the following syntax?"   :tongue:

Thanks. I have now corrected it.

bugthis

Okay, thanks to the website pcjs i could do some testing with several versions of MASM.
For the older MASM versions <= 4.0 i had to adjust my code. Basically this was sth. like changing .stack, .data, .code to
data SEGMENT word public 'DATA'
...
data ends

code ...
...
code ends
And
MOV AX, @DATA had to be changed to
MOV AX, DATA

MASM 1.0, 1.06, 1.10, 1.12, 1.25, 2.04, 3.0, 3.01 all throw an error on example 2.
But despite the error message thrown, all of them create an object file that can be linked. And the created executable works.
Example 3 does assemble without errors. Example 1 was not tested.

The error message for example 2 is:
28: Operator was expected
MASM 4.0, 5.0 and 5.01 all throw an error message on example 2 and they do NOT create an object file. Thus there is no EXE that could be run afterwards.
Example 3 does assemble without errors. Example 1 was not tested.

Starting with version 5, the error message for example 2 is:
error A2028: Operator expected

Conclusion:
Only Example 3 can be without the plus operator. That means if the constant comes before the register in the square brackets, then it works.

Works:
MOV const [BX], register ; example 3

Example 2 always throws an error but can still be assembled into an object file up to MASM version 3.01, which can then be linked to an executable program.

Throws an error and from version 4 onwards no OBJ file is created.
MOV [BX] const, register ; example 2Thus, this must be changed to:
MOV [BX] + const, register ; example 2

The most logical explanation is: The author probably referred to example/variant 3 and simply forgot the plus sign in example/variant 2.

EDIT:
Example 3 without the + operator also works with JWASM without errors. Only Example 1 and 2 require a + operator.

_japheth

MOV [BX + const], register ; example 1
MOV [BX] const, register ; example 2, Note the missing + operator between [BX] and const.
MOV const [BX], register ; example 3, Note the missing + operator between const and [BX]

I guess the fact that syntax of example 3 is still valid in Masm v6+ is just indulgence for old code. The "correct" variants probably are:

MOV [BX + const], register
MOV [BX][const], register
MOV [const][BX], register
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

bugthis

Quote from: _japheth on October 15, 2024, 08:07:35 PMI guess the fact that syntax of example 3 is still valid in Masm v6+ is just indulgence for old code.
I agree on that.

QuoteThe "correct" variants probably are:

MOV [BX + const], register
MOV [BX][const], register
MOV [const][BX], register
I just tried this with MASM 1.0, 3.05, 5.10 and JWASM and you might be right.
If you put each value in square brackets there is no error message.

Personally, I will continue to use option 1. I see no advantage in the other two options, apart from more typing and poorer readability.
I would put the fact that they exist down to historical baggage. They probably wanted to be compatible with some Intel or Digital Research assembler.

How does TASM actually do it?