Author Topic: MASM bug  (Read 599 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
MASM bug
« on: August 09, 2019, 10:49:26 PM »
Two lines from a source that assembles just fine with UAsm or AsmC:

Code: [Select]
DlgControl dcStatic,  "Files containing both strings:", SS_LEFT or WS_BORDER, 1, -7, 60.0
DlgControl dcStatic,  "maxMB=", SS_LEFT, 73.0%, -7, 31%

There are four methods to make it work with MASM (everything is fine with UAsm and AsmC):
1. add a comment to the second line
2. comment out the previous line
3. take a % sign off the second line (either 73.0% or 31%, both work)
4. brackets around SS_LEFT or WS_BORDER

To test it,
- install the latest MasmBasic package
- extract the attached files to a folder on your Masm32 drive
- open FindOnDiskMasmBug.asc in \Masm32\MasmBasic\RichMasm.exe
- hit F6 and see error A2026:constant expected DlgControl(1)
- apply any of the four methods above to fix the bug :cool:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6758
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: MASM bug
« Reply #1 on: August 09, 2019, 10:54:04 PM »
 :biggrin:

Is this another MASM feature you have not controlled properly ?  :skrewy:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: MASM bug
« Reply #2 on: August 09, 2019, 10:59:11 PM »
 :biggrin:

TimoVJL

  • Member
  • ***
  • Posts: 476
Re: MASM bug
« Reply #3 on: August 10, 2019, 02:50:20 AM »
Code: [Select]
.386
.model flat, stdcall

Test2 MACRO par1,par2,par3
LOCAL isp
ECHO Test2 <par1> <par2> <par3>
isp INSTR <par1>, <.>
if isp
ECHO isp 1
else
ECHO isp 0
endif
ENDM

.code
Test2 73, -7,10
Test2 73.0%, -7,10%
Test2 73.0%,-7,10.0%
ret
END
add ; after last Test2 line to see difference
without it:
Code: [Select]
Test2 <73.0> <-7> <10.0-0>
May the source be with you

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: MASM bug
« Reply #4 on: August 10, 2019, 03:32:07 AM »
Thanks, Timo, your example shows the problem very clearly. I've made a minor modification:
Code: [Select]
.386
.model flat, stdcall

Test2 MACRO par1,par2,par3
LOCAL isp
ECHO Test2 <par1> <par2> <par3>
isp INSTR <par1>, <.>
if isp
ECHO _isp 1
else
ECHO _isp 0
endif
ENDM

.code
Test2 71, -7,10
Test2 72.0%, -7,11%
Test2 73.0%,-7,12.3%
ret
END

Code: [Select]
*** Assemble using UAsm64  ***
Test2 <71> <-7> <10>
_isp 0
Test2 <72.0> <-7> <11>
_isp 1
Test2 <73.0> <-7> <12.3>
_isp 1

Code: [Select]
*** Assemble using ml  ***
Test2 <71> <-7> <10> ; passes, OK
_isp 0
Test2 <72.0> <-7> <11> ; passes, OK
_isp 1
tmp_file.asm(18) : error A2026:constant expected
 Test2(1): Macro Called From
  tmp_file.asm(18): Main Line Code
Test2 <73.0> <-7> <12.30> ; chokes and adds a zero
_isp 1

Now, if you change the second line from 11% to 11.1%, everything works fine again. Even the added zero in the next line disappears.

We can argue now whether it's a genuine MASM bug, if MASM is simply too old to be useful, or if MASM lacks important features. The conclusion is always the same: use UAsm or AsmC :biggrin:

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: MASM bug
« Reply #5 on: August 10, 2019, 04:11:43 AM »
Sorry I missed the purpose of "%". Is there any?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: MASM bug
« Reply #6 on: August 10, 2019, 04:27:20 AM »
Sorry I missed the purpose of "%". Is there any?

It's percent, and it's useful e.g. for telling the program "use 30% of the window width". Friendly syntax - BASIC :tongue:

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: MASM bug
« Reply #7 on: August 10, 2019, 04:40:53 AM »
It's percent, and it's useful e.g. for telling the program "use 30% of the window width". Friendly syntax - BASIC :tongue:

But removing every "%", nothing change.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: MASM bug
« Reply #8 on: August 10, 2019, 04:50:24 AM »
It's percent, and it's useful e.g. for telling the program "use 30% of the window width". Friendly syntax - BASIC :tongue:

But removing every "%", nothing change.

Right, the macro ignores it. It's just easier to recognise as a percentage from the coder's perspective.

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: MASM bug
« Reply #9 on: August 10, 2019, 04:51:59 AM »
Ok  :thumbsup: