open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
986 stars 161 forks source link

Local label support in assembler #388

Open hightowera opened 7 years ago

hightowera commented 7 years ago

I've looked through the WASM code and ran several tests and outside of TASM compatibility and TASM ideal mode, there doesn't appear to be local label support in the assembler; unless I'm mistaken and missed the syntax.

This would be a nice feature - ie. limited namespace scope between 'proc ' and 'endp ' for labels without having simple loop points conflict with all other labels of similar nature. NASM uses a leading '.' to denote local labels and TASM ideal uses a leading @@. The former is nicer from an aesthetic point of view.

If I were to try and tackle this feature addition, anything I should lookout for?

jmalak commented 7 years ago

Try to look on support for handling local labels @F (forward) and @B (backward) in bld/wasm/c/asmlabel.c May be extended to support "true" local symbols, but it can be dead tree. It is only quick idea.

hightowera commented 7 years ago

If I modify the code (with command line switch for compatibility) to rewrite any label that starts with a '.', such as '.loop', to be extended by the current procedure name - eg. '.myfunc_loop', a) would it horribly break anything I'm not aware of, and b) is there a way to retrieve the current open proc/scope name?

jmalak commented 7 years ago

You should follow MASM rules for MASM mode and TASM rules for TASM mode. I think "." (dot) on begining of symbol is used for assembler directives that should not be used for symbols. Anyway "." character is not valid symbol character.

jmalak commented 7 years ago

Generaly MASM and TASM have configurable two characters for local labels that it is not fixed to @@. @@ is default value for both I think.

jmalak commented 7 years ago

CurrProc variable should hold pointer to structure for current procedure.

jmalak commented 7 years ago

WASM regression tests are available in bld/wasmtest sub-directory. During development you can run regression test quickly by command "builder buildtest" in bld/wasmtest directory. It will check current WASM build. It doesn't require any copying of build WASM to some directory or change OW environment setup.