News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MIRROR$

Started by jj2007, July 04, 2009, 09:57:25 PM

Previous topic - Next topic

jj2007

mov eax, MIRROR$("1234") assembles fine on ml 6.14 and ml 9.0 but chokes with JWasm. Any ideas why?

include \masm32\include\masm32rt.inc

MIRROR$ MACRO arg:REQ ;;usg: mirror text: cmp eax, MIRROR$("Masm")
LOCAL tmp$
  tmp$ equ <>
  FORC char, <arg>
   tmp$ CATSTR <char>, tmp$
  ENDM
  EXITM <tmp$>
ENDM

.code

start:
mov eax, MIRROR$("1234")
print hex$(eax)
getkey
exit ; short form of invoke ExitProcess, 0
end start

jj2007

Since we are already on Jwasm:

Quote   exit MACRO optional_return_value
      IFNDEF optional_return_value
        invoke ExitProcess, 0
      ELSE
        invoke ExitProcess,optional_return_value
      ENDIF
    ENDM
Warning! W286: IF[n]DEF expects a plain symbol as argument: IFNDEF

Quote   exit MACRO optional_return_value
      IFB <optional_return_value>
        invoke ExitProcess, 0
      ELSE
        invoke ExitProcess,optional_return_value
      ENDIF
    ENDM
Works fine...

Jimg

first question,   clearly a bug-

  start:
=                         1 ??0019 equ <>
                           1 FORC char, <"1234">
>                         1 ??0019 CATSTR <char>, ??0019
>                         1 ENDM
00000000                   2 ??0019 CATSTR <">>, <>
                           Error! E048: Syntax error
= 1                       2 ??0019 CATSTR <1>, <>
= 21                      2 ??0019 CATSTR <2>, <1>
= 321                     2 ??0019 CATSTR <3>, <21>
= 4321                    2 ??0019 CATSTR <4>, <321>
00000000                   2 ??0019 CATSTR <">>, <4321>
                           Error! E048: Syntax error

edit: nonsense statement removed.

on ifndef, does a zero length string exist by definition?  Different, but not necessarily wrong.

jj2007

Quote from: Jimg on July 04, 2009, 10:27:44 PM

<"1234">
<4321>

Although I don't see why you would write a macro that returned a string identical to the input.

It mirrors the string, e.g. .if eax==MIRROR$("Jimg")
Works fine with ML, 6.14 and 9.0

Quote
on ifndef, does a zero length string exist by definition?  Different, but not necessarily wrong.

If it has not been defined, it does not exist. I use ifndef often, never had a problem.

Not that M$ was without problems - I just lost over an hour chasing a very odd bug. I have a 53k include file, it works fine with all my code except one source. That one works fine with ml/link 6.14, JWasm, polink but not with ml 9.0: It gave me a cryptic error message, "internal error" etc, plus a reg dump, until I had the bright idea to add

JustAnother MACRO
ENDM

at the bottom. Now it works :green2
Quote

Jimg

awww, you caught me before I could remove that stupid statement :)

Jimg

ifndef expects a symbol, not a null string, in jwasm.  One of many differences between it and masm.

As for the other, I guess you'll have to complain on sourceforge.  I lost interest after Japeth moved everything there.

jj2007

Quote from: Jimg on July 04, 2009, 10:58:40 PM
awww, you caught me before I could remove that stupid statement :)

Never mind :bg

Just found that I can solve my problem with ml 9.0 by inserting near the top of the include file

QuoteM$isCrap PROTO

If I comment it out, the bug comes back, even if I keep the number of characters constant. Cute ::)

MASM : fatal error A1016: Internal error

  Version 9.00.21022.08

  ExceptionCode            = C0000005
  ExceptionFlags           = 00000000
  ExceptionAddress         = 00428E55 (00400000) "D:\Masm32\bin\ml.exe"
  NumberParameters         = 00000002
  ExceptionInformation[ 0] = 00000000
  ExceptionInformation[ 1] = 00C26030

CONTEXT:
  Eax    = 00C26030  Esp    = 0012F8F4
  Ebx    = 0044A200  Ebp    = 0012F924
  Ecx    = 00000009  Esi    = 00C25FE9
  Edx    = 00000009  Edi    = 00000007
  Eip    = 00428E55  EFlags = 00010202
  SegCs  = 0000001B  SegDs  = 00000023
  SegSs  = 00000023  SegEs  = 00000023
  SegFs  = 0000003B  SegGs  = 00000000
  Dr0    = 00000000  Dr3    = 00000000
  Dr1    = 00000000  Dr6    = 00000000
  Dr2    = 00000000  Dr7    = 00000000

Ficko

Hi JJ,

Just a suggestion.

Try ML VER 10.00...

:8)
Some things are smoothed out some got worse.

Ficko

japheth

Hi jj,

the MIRROR$ is fixed in v1.96

the warning with IFxDEF is to make sure someone doesn't write

IFNDEF sym1 or sym2

because it won't work as expected.



jj2007

Quote from: japheth on July 09, 2009, 11:15:03 AM
Hi jj,

the MIRROR$ is fixed in v1.96
Thanx, works great :U

Quote
the warning with IFxDEF is to make sure someone doesn't write

IFNDEF sym1 or sym2

because it won't work as expected.


How would you rewrite the exit macro then?

exit MACRO optional_return_value
      IFNDEF optional_return_value
        invoke ExitProcess, 0
      ELSE
        invoke ExitProcess,optional_return_value
      ENDIF
ENDM

Warning! W284: IF[n]DEF expects a plain symbol as argument: IFNDEF
exit(2)

japheth


> How would you rewrite the exit macro then?

What's wrong with IFNB instead of IFNDEF?

jj2007

Quote from: japheth on July 09, 2009, 06:57:09 PM

> How would you rewrite the exit macro then?

What's wrong with IFNB instead of IFNDEF?

Nothing is wrong, but I would like to understand where I can use IFNDEF without getting a warning. I use it quite a bit...

As to the exit macro, this works and is more elegant:

exit MACRO optional_return_value:=<0>
        invoke ExitProcess, optional_return_value
ENDM