Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Suggested improvement for Wasm: Removing register/label name conflicts

18 views
Skip to first unread message

Paul K. McKneely

unread,
Jan 25, 2012, 11:39:47 AM1/25/12
to
I don't know if there is a better place to suggest improvements
for the wasm assembler.

I am using a calling convention that does not place underscores
in label names. As a consequence, I can't have variables and other
label names that are the same as registers and other conflicting
names etc. However, only memory addresses with label names
should ever use a pointer qualifier such as "PTR WORD" preceding
a memory label. If wasm was modified so that it would force the
following label name to be interprested as a memory label, then its
use could remove the restriction from using register names as memory
identifiers. Unfortunately, wasm doesn't do this. If I write a statement
such as...

add ax,ptr word ax

...it just generates code for...

add ax,ax

... and it doesn't recognize a label that I defined with the same
name. Also, it emits no error. Preceding a register name with one
of these qualifiers is unnecessary and even misleading. Having no
need for such a prefix for register names frees the syntax to be used
for the purpose I describe. This use of "ptr xxx label" would be an
excellent mechanism for both overriding the declared size of the
memory location as well as forcing the assembler to look for a
memory location that happens to be given the same name as a register.


Hans-Bernhard Bröker

unread,
Jan 25, 2012, 6:37:54 PM1/25/12
to
On 25.01.2012 17:39, Paul K. McKneely wrote:
> I don't know if there is a better place to suggest improvements
> for the wasm assembler.

That would be the contributors' newsgroup. X-post and F'up2 set.

> I am using a calling convention that does not place underscores
> in label names. As a consequence, I can't have variables and other
> label names that are the same as registers and other conflicting
> names etc.

Hmmm... sounds to me like you've just demonstrated that that calling
convention needs re-thinking.

> However, only memory addresses with label names
> should ever use a pointer qualifier such as "PTR WORD" preceding
> a memory label. If wasm was modified so that it would force the
> following label name to be interprested as a memory label, then its
> use could remove the restriction from using register names as memory
> identifiers.

I'm afraid you have that backwards. Just because in _one_ particular
use case register names can be disallowed safely, that doesn't mean you
can mix up register names with asm symbol names in _all_other_ use
cases. And only in the latter case would it be useful to allow this.

Unfortunately, wasm doesn't do this. If I write a statement
> such as...
>
> add ax,ptr word ax
>
> ...it just generates code for...
>
> add ax,ax

That's arguably a good thing. That whole WORD PTR nonsense is one of
the silliest pieces of assembly language syntax ever "invented", anyway.

B-O Bergman

unread,
Jan 27, 2012, 3:03:30 AM1/27/12
to
Have you tried using TASM IDEAL mode? There you don't have word ptr, but a
more precise syntax.

Labels needs to avoid reserved words as the assembler need to know if the
instruction refer to a register or a symbol. Inside structure and unions you
can use any name, because the assembler know the difference.

Your idea is that the PTR construct should tell the assembler that it's a
variable. Well, that is possible but requires to much work, so the question
is if it's worth it.


If you need variables that has similar names as the CPU registers you can
put them all inside a structure. Otherwise you can prefix or suffix them.
It's legal to suffix or prefix your variables with an underscore even if you
dont follow a standard convention.

"Paul K. McKneely" <pkmck...@sbcglobal.net> skrev i meddelandet
news:jfpb8r$8dj$1...@www.openwatcom.org...
0 new messages