News:

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

MASM32 version 11 pre-Release 3

Started by hutch--, November 24, 2011, 07:36:25 AM

Previous topic - Next topic

jj2007

#15
Hutch,

No error for useMB=0, i.e. no MasmBasic.
chr$ is the culprit, and the new version below works fine with MasmBasic & useMB=1.

The goto lb1 technique may save some lines, but it chokes in this particular setting. The same might happen with other macros that my code does not use...

Here is an optimised version:

include \masm32\include\masm32rt.inc
include \masm32\macros\ucmacros.asm

if 0
__UNICODE__=1 ; comment out to see the ANSI version
endif

chr$ MACRO any_text:VARARG
LOCAL txtname
.data
  align 4
  IFNDEF __UNICODE__
txtname db any_text,0
  ELSE
WSTR txtname,any_text
  ENDIF
  .code
  EXITM <OFFSET txtname>
ENDM

.code
start:
  IFNDEF __UNICODE__
invoke MessageBoxA, 0, chr$("ANSI"), chr$("it works"), MB_OK
  ELSE
invoke MessageBoxW, 0, chr$("UNICODE"), chr$("it works"), MB_OK
  ENDiF
  exit

end start

Ramon Sala

Hutch,

I tested MASM32 version 11 pre-Release 3 as much as I could and everything seems to work fine.

Good work!

Ramon
Greetings from Catalonia

hutch--

Thanks Ramon.  :U

JJ, I used the goto label technique for a reason, some combinations cause nesting level depth problems with MASM with IFDEF - IFNDEF so I wrote an alternative to it.

You are mixing old code with a line like this.


include \masm32\macros\ucmacros.asm


In version 11 the ucmacros.asm file is a stub that displays an error if it is included.

What I don't know is if you are building the test piece with MASM or JWASM. The macros were written and tested on ML 6.14 and also tested on later versions of ML.EXE. I would expect JWASM to be properly MASM compliant but its not in the testing range I undertake with this project.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on November 25, 2011, 10:29:16 PM
JJ, I used the goto label technique for a reason, some combinations cause nesting level depth problems with MASM with IFDEF - IFNDEF so I wrote an alternative to it.
I'd love to see an example for that. Must have driven you crazy chasing this one :green

QuoteYou are mixing old code with a line like this.
I know. It's simply because I have not yet installed the new version on my home PC. Inter alia because the installer tells me every time I should delete all the previous stuff :toothy

QuoteWhat I don't know is if you are building the test piece with MASM or JWASM. The macros were written and tested on ML 6.14 and also tested on later versions of ML.EXE. I would expect JWASM to be properly MASM compliant but its not in the testing range I undertake with this project.
JWasm is insofar "incompliant" as it is the only one that does assemble the test piece with useMB=1 and the "goto" version of chr$.

hutch--

You don't have to delete it, just temporarily rename your old MASM32 installation to something else. The install tests for an existing MASM32 installation by the directory name and if its present on that partition, it will not install there.

>  Must have driven you crazy chasing this one

It was a genuine joy, with the level of interdependence I have to go backwards re-writing a whole heap of the macros.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on November 26, 2011, 10:01:18 AM
You don't have to delete it, just temporarily rename your old MASM32 installation to something else. The install tests for an existing MASM32 installation by the directory name and if its present on that partition, it will not install there.
So i rename while launching the installer, and before installing "for good", I rename again to masm32? And it will not overwrite or delete any non-Masm32 files?

Quote
>  Must have driven you crazy chasing this one

It was a genuine joy, with the level of interdependence I have to go backwards re-writing a whole heap of the macros.

Can you test it with the "shortened" chr$ again? If it chokes with MasmBasic, it may choke with other complex macros, too... I had no problems with my standard MB testbed, it's sheer accident that I opened this one and found the problem.

Vortex

Another option for Masm32 test installations is to use a virtual disk driver. ImDisk can create very fast  RAM Disks :

http://www.ltr-data.se/opencode.html/#ImDisk

Create a virtual partition and assign a letter with ImDisk. After formatting the partition, the installation of Masm32 goes very fast.

hutch--

Thanks for the link Erol, that is the first decent ramdisk I have seen for a long time. Saves the drive image to disk and can be opened again as a drive.  :U

JJ,

The shortened version is almost identical to the version I had to re-write into the current one. The "chr$()" macro uses standard MASM notation and the goto label approach was used to step out of the conditional block so that the EXITM code was not contained in it.

Now when you have a working version 11 installed instead of the hybrid you have so far tested, the next step would be to see why your macro "chokes".
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Hutch,

Attached a version that boils it down to one line or even one half line:
print str$(eax) ; works
print str$(eax), 9 ; chokes

Two LST files are attached - one with MasmBasic enabled (it chokes with ml.exe but not with JWasm), the other uses Masm32 only (it works with ML.exe and JWasm). The two files are almost identical - see line 214 for a difference...
Note the code starts working if either
- you take away the "9" after print str$() or
- you comment out the empty else

It is pretty mysterious, but as far as I can see my macros are not directly involved. At least, I don't see any of them, even in a more complete listing. I guess it has to do with the local macro variables.

Again, the shortened chr$ works fine, and I would like to see a case where that one fails ::)

hutch--

I am not seeing it here with simple example. The "print" macro uses the "chr$()" macro to handle the VARARG data after the 1st argument and its working exactly as it is supposed to.



IF 0  ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                      Build this template with "CONSOLE ASSEMBLE AND LINK"
ENDIF ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    __UNICODE__ equ 1

    include \masm32\include\masm32rt.inc

    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    LOCAL var   :DWORD

    mov var, 1234567

    print "Numbers ",48,49,50,51,52,53,54,55,56,57,13,10
    print "Howdy "
    print ustr$(var)
    print chr$(13,10)

    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start


The output is,


Numbers 0123456789
Howdy 1234567
Press any key to continue ...
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on November 26, 2011, 08:31:56 PM
I am not seeing it here with simple example. The "print" macro uses the "chr$()" macro to handle the VARARG data after the 1st argument and its working exactly as it is supposed to.

Yes, there is no problem in a simple app. But Masm is a buggy pig. The error message says there is one else too much.
I have stripped it down to the absolute minimum:


Quote.nolist
useMB = 1      ; 1 to choke, 0 to go
ife useMB
   include \masm32\include\masm32rt.inc
else
   include \masm32\MasmBasic\MasmBasic.inc
endif
.listall
.code
start:
  if 1   ; <<<<<<<<<<<<<< trouble starts here <<<<<<<<<<<<<<<<<
   nop           ; v v v v v no trouble without the 9 v v v v
   print "Ciao ", 9
   nop
  else
   ; <<<<<<<<<<<<<<<<< works if commented out <<<<<<<<<<<<<<<<
   
NOP
  endif
   inkey "bye"
   exit

end start

Full "testbed" attached. The two LST files differ only marginally...

jj2007

Now, just in case somebody might suspect that MasmBasic was the culprit, here a version that definitely does not use MB:

Quote.nolist
useMasm32 = 0      ; 1 to choke, 0 to go
ife useMasm32
   include \masm32\include\masm32rt.inc
else
   include \masm32\include\masm32rt.inc
endif
.listall
.code
start:
  if 1   ; <<<<<<<<<<<<<< trouble starts here <<<<<<<<<<<<<<<<<
   nop           ; v v v v v no trouble without the 9 v v v v
   print "Ciao ", 9
   nop
  else   ; <<<<<<<<<<<<<<<<< works if commented out <<<<<<<<<<<<<<<<
   
nop
  endif
   inkey "bye"
   exit
end start


hutch--

Builds perfectly here with version 11. Am I missing something or is it the case that it builds OK in MASM but fails when the MasmBasic macros are added ?



Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: K:\jj\elsebug2\ElseBug.asm

***********
ASCII build
***********

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Volume in drive K is drv_k
Volume Serial Number is 4421-FFA6

Directory of K:\jj\elsebug2

11/26/2011  10:06 PM               517 ElseBug.asm
11/27/2011  08:20 AM             2,560 ElseBug.exe
11/27/2011  08:20 AM             1,045 ElseBug.obj
               3 File(s)          4,122 bytes
               0 Dir(s)  248,225,169,408 bytes free
Press any key to continue . . .


RE : Nesting macros that contain chr$().


    print right$(left$(rev$(ustr$(uval(rev$(chr$(48,49,50,51,52,53,54,55))))),6),5),13,10


Works fine.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

qWord

I can confirm this bug.
In my experience, MASM some time simply goes crazy when using GOTO. A common IF/ELSE construct should solve the problem.
FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: hutch-- on November 26, 2011, 09:29:23 PM
Builds perfectly here with version 11. Am I missing something or is it the case that it builds OK in MASM but fails when the MasmBasic macros are added ?

See the post above yours, and qWord's answer. It's not MasmBasic.
Actually, the trigger is this one:
useMasm32 = 1 ; 1 to choke, 0 to go
ife useMasm32
include \masm32\include\masm32rt.inc
else
include \masm32\include\masm32rt.inc
endif

A simple include does not exhibit the problem. Somewhere in masm32rt.inc it starts choking over an unbalanced if/else/endif construct.