The MASM Forum

General => The Laboratory => Topic started by: aw27 on December 04, 2017, 01:20:10 AM

Title: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: aw27 on December 04, 2017, 01:20:10 AM
This will crash in recent releases of MASM. Builds fine in MASM 6.xxx
SDWORD appears to be the culprit



.686
.MODEL FLAT, STDCALL

.data
myVar SDWORD ?

.code

main PROC
int 3 ; <- Remove to run on the command line

mov eax, 3
.IF SDWORD PTR eax > 0
.IF eax==3
lea eax, [eax+2*eax]
mov ecx, 3
mov SDWORD PTR myVar, ecx
.ENDIF
.ENDIF

ret
main ENDP

END main


or this:


.686
.MODEL FLAT, STDCALL

.data
myVar SDWORD ?


.code

main PROC
int 3 ; <- Remove to run on the command line

        mov myVar, 3
.IF SDWORD PTR myVar > 0
.IF myVar==3
lea eax, [eax+2*eax]
mov ecx, 3
mov SDWORD PTR myVar, ecx
.ENDIF
.ENDIF

ret
main ENDP

END main
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: nidud on December 04, 2017, 02:02:26 AM
deleted
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: jj2007 on December 04, 2017, 02:07:21 AM
Looks similar to the MASM 14.0 .if signed comparison bug (http://masm32.com/board/index.php?topic=6447.0) thread.

The SDWORD ptr doesn't work e.g. in ML 14 and 15, the jmp is one byte off. It works fine in ML 6.14 ... 10.0, though. It seems M$ has recently lost control over their pile of s**t.

Workaround:
         mov SDWORD PTR myVar, ecx
         nop

Rumours say there is also a perfect clone for ML that handles all recent opcodes perfectly, is three times faster and absolutely bug-free, at least compared to recent M$ assemblers 8)
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: aw27 on December 04, 2017, 02:15:27 AM
I was not aware of the need for the nop   :(

So, now everybody knows that the bug is still on the latest and greatest:
Microsoft (R) Macro Assembler Version 14.11.25547.0
Copyright (C) Microsoft Corporation.  All rights reserved.
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: nidud on December 04, 2017, 02:26:34 AM
deleted
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: jj2007 on December 04, 2017, 02:26:55 AM
Quote from: aw27 on December 04, 2017, 02:15:27 AM
I was not aware of the need for the nop   :(

Contact Hyde, Irvine, Kusswurm and Iczelion - they must update their books and tutorials 8)

(hint: UAsm works without the magic nop (http://www.terraspace.co.uk/uasm.html))
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: nidud on December 04, 2017, 02:57:09 AM
deleted
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: aw27 on December 04, 2017, 03:04:19 AM
Quote from: nidud on December 04, 2017, 02:57:09 AM
Re: MASM 14.0 .if signed comparison bug

Quote from: aw27 on August 06, 2017, 03:08:43 PM
Quote from: Queue on August 05, 2017, 08:19:07 PM
Quote from: LiaoMi on August 05, 2017, 06:03:40 PM
did you report this discovery to Microsoft?
No, I haven't. I don't even know where I could report this sort of information to Microsoft.
You can try https://connect.microsoft.com/VisualStudio/

LOL  :icon_eek:
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: aw27 on December 04, 2017, 03:21:57 AM
And the case of the mysterious disappearance of "dec ebx" (yes, NOP shall fix).


.686
.MODEL FLAT, STDCALL

.data
myValue SDWORD 10


.code

main PROC
int 3 ; <- Remove to run on the command line

mov edx, 3
mov ebx, edx
.WHILE ebx>0
.WHILE ecx<myValue
inc ecx
.ENDW
dec ebx ; <-- will disappear
.ENDW

ret
main ENDP

END main
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: jj2007 on December 04, 2017, 03:28:29 AM
Quote from: aw27 on December 04, 2017, 03:21:57 AMAnd the case of the mysterious disappearance of "dec ebx" (yes, NOP shall fix).
We shouldn't be too critical, José. At least, with the extra nop, this is one of the last Micros**t assemblers who understand the .While ... .Endw syntax :t
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: aw27 on December 04, 2017, 04:44:37 AM
Quote from: jj2007 on December 04, 2017, 03:28:29 AM
Quote from: aw27 on December 04, 2017, 03:21:57 AMAnd the case of the mysterious disappearance of "dec ebx" (yes, NOP shall fix).
We shouldn't be too critical, José. At least, with the extra nop, this is one of the last Micros**t assemblers who understand the .While ... .Endw syntax :t

Let's enjoy it while it lasts then.  :biggrin:
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: hutch-- on December 04, 2017, 09:47:55 AM
 :biggrin:

Real Men[tm] code in mnemonics, if you need lots of high level hand holding, try a visual garbage generator.  :P
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: jj2007 on December 04, 2017, 10:29:30 AM
Quote from: hutch-- on December 04, 2017, 09:47:55 AMReal Men[tm] code in mnemonics

Quote from: aw27 on December 04, 2017, 03:21:57 AM
      dec ebx ; <-- will disappear

The dec ebx is a mnemonic. For recent MASM versions, you need to resort to the level below mnemonics:db 4bh ; dec ebx

For Real MenTM, the db nnn notation should be made obligatory 8)
Title: Re: Guaranteed to crash in MASM (unless you are using MASM 6.xx)
Post by: HSE on December 04, 2017, 12:43:41 PM
Quote from: jj2007 on December 04, 2017, 10:29:30 AM
For Real MenTM, the db nnn notation should be made obligatory 8)
You have tried to say "Real Crazy MenTM"?  :biggrin: