News:

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

Some syntactical questions

Started by Randall Hyde, August 08, 2006, 11:02:41 PM

Previous topic - Next topic

Randall Hyde

I'm currently trying to decide how to map HLA stdlib names to MASM.

HLA supports the concept of namespaces that MASM does not. A namespace allows me to put a set of symbols (constants, procs, types, etc.) "behind" some other name and then reference those names using dot notation. For example, in the "stdout" library module (and namespace), there is a "putc" routine that prints a character to the standard output device. To call this particular putc routine, you use the following syntax:


stdout.putc( character )


Now ideally, it would be nice if all assemblers I port the stdlib to could use the same syntax.  With assemblers like FASM and NASM (which don't directly support structs), a period is just like any other character in a name, so I can call the standard output putc routine "stdout.put" just as in HLA. In MASM, however, the period is not a general character to be used in an identifier as it's used to separate struct/union/record field names.  So I've got to come up with something else.

The contenders are:


stdout_putc
stdout?putc
stdout@putc


I'm somewhat leaning towards the first item because if another assembler doesn't allow periods in the names, I'd like to keep the naming convention as consistent as possible (to make writing documentation easier).  Unfortunately, using underscores in names like this is a very common practice and increases the possibility of namespace pollution.  In any case, I thought I'd throw this idea out for discussion before deciding one way or the other.
Cheers,
Randy Hyde

hutch--

Randy,

Have a look at an example in the current version of masm32 called "vhll" in the EXAMPL11 directory. I did it as a test piece but if you don't mind writing nested structures you can build a whole system in that manner.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Tedd

use__two_underscores_instead :bg
No snowflake in an avalanche feels responsible.

Vortex

In my modest opinion, underscores are improving the readability.

James Ladd


Randall Hyde

Quote from: Vortex on August 09, 2006, 05:01:56 PM
In my modest opinion, underscores are improving the readability.

Looks like it will be underscores.
Cheers,
Randy Hyde

Randall Hyde

Quote from: hutch-- on August 09, 2006, 02:56:09 AM
Randy,

Have a look at an example in the current version of masm32 called "vhll" in the EXAMPL11 directory. I did it as a test piece but if you don't mind writing nested structures you can build a whole system in that manner.

That trick works okay for procedure calls (as long as you're willing to live with an indirect call rather than a direct call), but it doesn't work for things like non-numeric constants, text equates, and so on. I did discover the fact that you can specify *numeric* constants by using an ORG directive before fields in a struct (and then referencing the field using the struct name). But I really need to be able to define *any* symbol table in the STRUCT to do what I want to do. 
Cheers,
Randy Hyde