Author Topic: Minor incompatibility ML vs Watcom family  (Read 919 times)

jj2007

  • Member
  • *****
  • Posts: 7542
  • Assembler is fun ;-)
    • MasmBasic
Minor incompatibility ML vs Watcom family
« on: October 12, 2016, 11:03:34 AM »
With the code below, HJWasm and AsmC fail, while ML executes the <inc ebx> correctly.

Code: [Select]
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

  • Member
  • *****
  • Posts: 7542
  • Assembler is fun ;-)
    • MasmBasic
Re: Minor incompatibility ML vs Watcom family
« Reply #1 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. There was also a typo in GetDevicesArray.

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: Minor incompatibility ML vs Watcom family
« Reply #2 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)
 
Cod-Father

jj2007

  • Member
  • *****
  • Posts: 7542
  • Assembler is fun ;-)
    • MasmBasic
Re: Minor incompatibility ML vs Watcom family
« Reply #3 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.

Code: [Select]
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

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: Minor incompatibility ML vs Watcom family
« Reply #4 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 ;)
Cod-Father