The MASM Forum

64 bit assembler => UASM Assembler Development => Topic started by: jj2007 on October 12, 2016, 11:03:34 AM

Title: Minor incompatibility ML vs Watcom family
Post by: jj2007 on October 12, 2016, 11:03:34 AM
With the code below, HJWasm and AsmC fail, while ML executes the <inc ebx> correctly.

include \masm32\include\masm32rt.inc ; plain Masm32 for the fans of pure assembler
mcs MACRO args:VARARG
Local isL, isR, isQ
  isR=0
  While 1
isL=isR+1
isR INSTR isL, <args>, <#>
if isR
% echo EXE @SubStr(<args>, isL, isR-isL)
@SubStr(<args>, isL, isR-isL)
else
@SubStr(<args>, isL)
EXITM
endif
  ENDM
ENDM

.code

start: inkey "Hello World", 13, 10

  mcs xor ebx, ebx#<inc ebx>#cmp ebx, 20
  exit

end start
Title: Re: Minor incompatibility ML vs Watcom family
Post by: jj2007 on October 14, 2016, 10:28:34 AM
It seems the Watcom crew are very busy, which I can understand ;-)

I have changed the wording for the mcs macro in the help file accordingly, recommending to put macros that depend on previous values into the next line. This is already online here (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1336). There was also a typo in GetDevicesArray (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1356).
Title: Re: Minor incompatibility ML vs Watcom family
Post by: habran on October 14, 2016, 11:47:07 PM
Sorry JJ, we are still busy with fine-tuning EVEX and AVX2 instructions, if it is something urgent,  please PM me source and disassembly and we'll look at it ASAP 8)
Title: Re: Minor incompatibility ML vs Watcom family
Post by: jj2007 on October 15, 2016, 02:47:02 AM
It's not urgent, as it concerns so far only the exotic case that somebody wants to squeeze a macro into a multiple commands line. Here is a source in case somebody is interested.

include \masm32\include\masm32rt.inc

mcs MACRO args:VARARG
Local isL, isR, isQ
  isR=0
  While 1
isL=isR+1
isR INSTR isL, <args>, <#>
if isR
% echo EXE @SubStr(<args>, isL, isR-isL)
@SubStr(<args>, isL, isR-isL) ; Watcom: emits <inc ebx> instead of inc ebx
else
@SubStr(<args>, isL) ; last element in the list
EXITM
endif
  ENDM
ENDM

.code

start:
  mov eax, 12345
  print str$(eax), 13, 10
  int 3
  mcs xor ebx, ebx#<inc ebx>#cmp ebx, 20 ; builds with ML, code OK
  nops 4
  mcs mov eax, 12345#<print str$(eax)>#nop ; builds with ML but bad code generated
  nops 4
  print chr$(13, 10, "---------------", 13, 10)
  mcs mov eax, 12345#print str$(eax)#nop ; builds with ML but bad code generated

  exit
end start


Strangely enough, print str$() fails always to print the correct result, while MasmBasic Print Str$() succeeds with ML.
Title: Re: Minor incompatibility ML vs Watcom family
Post by: habran on November 09, 2016, 04:23:20 PM
Hi JJ,
Sorry mate, I couldn't make it work.
Maybe you can tweak the macro, you are "The Lord Of The Macros" :biggrin:
I am just a pure Gandalf at your service ;)