News:

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

Main Menu

.listmacro

Started by jimg, April 10, 2020, 07:50:34 AM

Previous topic - Next topic

jimg

.listmacro  (the default)  lists much more than it should.

jimg

Perhaps I should have been clearer.   .listmacro in masm only lists the instructions that were assembled.  Uasm is treating .listmacro as if it were .listmacroall, listing everything in the macro every time.
I'm working on developing/debugging a 250 line macro and it's pretty tough to find the one or two lines that result from the macro, and it really blows up the listing.  If I say .nolistmacro then I don't get a list of the lines that were assembled at all.
I realize this can't be very high on your list of things to do, but please at least put it on the list somewhere :)

habran

Hi Jimg
You are correct, .listmacro is not filtered at all.
I have looked it up and it is not very complicated to fix. I don't know if John can upload a new version soon, so if you are in a hurry I can give you here how you can make it work, if you are able to build uasm from the source.
It is in listing.c from line 139 to line 168:
void LstWrite( enum lsttype type, uint_32 oldofs, void *value )
/*************************************************************/
{
    uint_32 newofs = 0;
    struct asym *sym = value;
    int     len;
    int     i;
    int     len2;
    int     idx;
    int     srcfile;
    char    *p1;
    char    *p2;
    char    *pSrcline;
    struct lstleft *pll;
    struct lstleft ll;
    //char    buffer2[MAX_LINE_LEN]; /* stores text macro value */

    if ( ModuleInfo.list == FALSE || CurrFile[LST] == NULL || ( ModuleInfo.line_flags & LOF_LISTED ) )
        return;
    if ( ModuleInfo.GeneratedCode && ( ModuleInfo.list_generated_code == FALSE ) )
        return;
    if ( MacroLevel ) {
        switch ( ModuleInfo.list_macro ) {
        case LM_NOLISTMACRO:
            return;
        case LM_LISTMACRO:
            /* todo: filter certain macro lines */
            break;
        }
    }

as you can see case LM_LISTMACRO: doesn't do nothing
so here is the code with the fix:
void LstWrite( enum lsttype type, uint_32 oldofs, void *value )
/*************************************************************/
{
    uint_32 newofs = 0;
    struct asym *sym = value;
    int     len;
    int     i;
    int     len2;
    int     idx;
    int     srcfile;
    char    *p1;
    char    *p2;
    char    *pSrcline;
    struct lstleft *pll;
    struct lstleft ll;
    //char    buffer2[MAX_LINE_LEN]; /* stores text macro value */

    if ( ModuleInfo.list == FALSE || CurrFile[LST] == NULL || ( ModuleInfo.line_flags & LOF_LISTED ) )
        return;
    if ( ModuleInfo.GeneratedCode && ( ModuleInfo.list_generated_code == FALSE ) )
        return;
    if ( MacroLevel ) {
        switch ( ModuleInfo.list_macro ) {
        case LM_NOLISTMACRO:
            return;
        case LM_LISTMACRO:
          type = LSTTYPE_CODE; /* this is a fix */
            break;
        }
    }

I hope that helps :biggrin:
Cod-Father

jimg

Thank you.  I can wait.  I've never tried to compile UASM itself.  The only c compiler I have is Pelles, will that work?

habran

You can download and install for free Microsoft Visual Studio 2019 Community and build it with UASM.sln which is inside the folder. It is easier than use Pellesc, because you don't know which file to include in build.
I would take it as a challenge and learn how to use MSVC :wink2:
Cod-Father

TimoVJL

uasm isn't strictly written for C99 language, it's written in msvc C/C++, so it need to fix for PellesC.
clang can handle it too.

Last time i used this:
@SET Path=C:\code\PellesC9\bin
@SET INCLUDE=C:\code\PellesC9\include
@SET LIB=C:\code\PellesC9\lib;C:\code\PellesC9\lib\Win64
@SET SRC=..\UASM-2.50
ECHO PellesC 9 > _Errors64.txt
for %%c in (%SRC%\*.c) do pocc.exe -Ze -O2 -Go -Tx64-coff -I%SRC%\H -I. %%c -Fo"%%~nc.obj" -DWIN32 -D_W64 -DNDEBUG 2>> _Errors64.txt

polink main.obj apiemu.obj assemble.obj assume.obj atofloat.obj backptch.obj bin.obj branch.obj cmdline.obj codegen.obj codegenv2.obj coff.obj condasm.obj context.obj cpumodel.obj data.obj dbgcv.obj directiv.obj elf.obj end.obj equate.obj errmsg.obj expans.obj expreval.obj extern.obj fastpass.obj fixup.obj fpfixup.obj hll.obj input.obj invoke.obj label.obj linnum.obj listing.obj loop.obj lqueue.obj ltype.obj macho64.obj macro.obj macrolib.obj mangle.obj memalloc.obj msgtext.obj omf.obj omffixup.obj omfint.obj option.obj orgfixup.obj parser.obj posndir.obj preproc.obj proc.obj pseudoFilter.obj queue.obj reswords.obj safeseh.obj segment.obj simd.obj simsegm.obj string.obj symbols.obj tbyte.obj tokenize.obj types.obj -out:uasm64poc9.exe -map
@DEL *.obj
pause
May the source be with you

johnsa

I've updated 2.50 branch on Git with this fix now.

I've been absolutely swamped my side, hopefully soon I will finish the last few fixes I wanted for 2.50 to make a set binaries which I will include on the website as well as git releases page!

jimg

Quote from: johnsa on April 17, 2020, 04:36:43 AM
I've updated 2.50 branch on Git with this fix now.

I've been absolutely swamped my side, hopefully soon I will finish the last few fixes I wanted for 2.50 to make a set binaries which I will include on the website as well as git releases page!

Thanks John.  I read this to mean there is no binary yet, correct?

johnsa

Correct, there is one last remaining thing I want sorted before I can do the release builds, FYI here is the list of changes for 2.50:

Fix vmovdqu encoding, moved to new CodeGen.
Fix listing .listmacro
Fix movd/q encodings.
Prevent option stackbase rsp: with elf64 for now.
Dont optimise prologues based on hasInvoke, this is completely removed as it prevent libraries or code without visible invokes from generating correctly.
Prevent FPO based purely on USES.
Improve win64:0/1 lower modes compatibility and prologue generation.
Add option support to allow WIN64 procedures to not affect flags in epilogue.
Include W.I.P. codegen v2 files in repository
Fix encoding of SIB with vctsi2ss
Allow REP prefix on REPxx instructions without needing M510 compatibility.
Allow type size specifiers on immediate->memory operations
Improved consistency of SSE/AVX opcode selection for OPTION ARCH
Added new RawInterface and stdfunc types
Add support for \r \n and \t to unicode string literals
Ensure Arch SSE is the default
Ensure @Arch variable correctly reflects Arch setting (affected macro library items like LOADSS)
Fixed two bugs when using C-style HLL calls (using any TYPE PTR paramter and case sensitivity issue in 32bit)
Fixed undeclared identifier causing uasm to hang
More updates for CodegenV2
Fixed listing file delimiter issue on Windows
Unicode/Wide character string declarations would crash Uasm when split over multiple lines
Update Linux Makefile (GccLinux64.mak)
Improved BSS Data warnings for BIN files
Fixed LOADPS macro library function
Improved byte/word immediate to memory sizing coercion in codegen.
Fixed a parser bug preventing negative numbers greater than a byte from warning when used with a byte reg or mem location.

The one remaining thing I want is as mentioned in another thread, preventing generating of useless relocations in COFF when RIP referencing items in .code.. I'm still mulling this one, as it would be really nice to have a generic rip-relative method to address anything, IE: make the entire code position independant however I don't think under Windows this is possible as you have no guarantee about the positions/address of the sections in memory (someone correct me if' i'm wrong) however for the code section in which the LEA exists it should always be safe.