News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Minor incompatibility ML vs Watcom family

Started by jj2007, October 12, 2016, 11:03:34 AM

Previous topic - Next topic

jj2007

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

jj2007

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. There was also a typo in GetDevicesArray.

habran

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)
Cod-Father

jj2007

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.

habran

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 ;)
Cod-Father