News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

HJWasm

Started by habran, July 07, 2015, 04:38:55 PM

Previous topic - Next topic

habran

Hi folks,

I'd like to introduce here JWasm hybrid I renamed to HJWasm
There are some new feature built in:
2 new flugs EQUAL and BELOW,
which can be handy with UCOMISS, UCOMISD, VUCOMISS, VUCOMISD instructions
4 new AVX2 instructions: VPGATHERDD, VPGATHERQD, VPGATHERDQ, VPGATHERQQ
added also VCMPxxPD, VCMPxxPS, VCMPxxSD, VCMPxxPD, VCMPxxSS
I have added in this version data definition directive 'DO' data for XMMWORD, 'DY' data for YMMWORD and 'DZ' for ZMMWORD

you have to change in your sources and includes  (windows.inc line 12948 )dy to _dy
however I would prefer dx_ and dy_

MOUSEINPUT STRUCT
   _dx                    DWORD ?
   _dy                    DWORD ?    ;windows.inc line 12948
   mouseData         DWORD ?
   dwFlags              DWORD ?
   time                   DWORD ?
   dwExtraInfo        DWORD ?
MOUSEINPUT ENDS


I have included a source code with examples how they could be used
included also the HJWasm targets for the Visual Studio

This is still in development so please let me know if you encounter some bugs :biggrin:
Cod-Father

Gunther

Hi Habran,

great job. Is that the newest version? Should I use this version for compiling to other OS?

Gunther
You have to know the facts before you can distort them.

habran

Thanks Gunther :biggrin:

This is a new version, I don't know if you can use it without sources for other OS-es

I will post sources after little bit of testing
Cod-Father

HSE

Hi habran!

I take the 32. There is some problems with ObjAsm32 that don't exist before. Surely Biterider understand better what happen.

Have You modified the nesting limits?




HJWasm v2.12pre, Jul  7 2015, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

STRING TYPE: ANSI
D:\masm32\Include\Windows.inc(12948) : Error A2209: Syntax error:
D:\masm32\Include\Windows.inc(12948): Included by
  SysSetup(42)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\Include\Windows.inc(19071) : Error A2209: Syntax error:
D:\masm32\Include\Windows.inc(19071): Included by
  SysSetup(42)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2151: Unexpected literal found in expression: ¼c
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2209: Syntax error: @
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2209: Syntax error: @
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2209: Syntax error: @
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2209: Syntax error: @
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2209: Syntax error: @
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(788) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(788): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(797) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(797): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(803) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(803): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(803) : Error A2082: Must be in segment block
D:\masm32\ObjAsm32\Code\Macros\System.inc(803): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
D:\masm32\ObjAsm32\Code\Macros\System.inc(810) : Error A2162: Unmatched macro nesting
D:\masm32\ObjAsm32\Code\Macros\System.inc(810): Included by
  SysSetup(45)[Model.inc]: Macro called from
   Demo02.asm(20): Main line code
DEBUG MODE : ACTIVE -> WND
STACKGUARD : ACTIVE
SUPPORT FOR: OOP
SUPPORT FOR: WINDOWS
Inheritance path: Primer
Inheritance path: Primer,DesLUT
Inheritance path: Primer,Stream
Inheritance path: Primer,Streamable
Inheritance path: Primer,Streamable,WinPrimer
Inheritance path: Primer,Streamable,WinPrimer,Dialog
Inheritance path: Primer,Streamable,WinPrimer,Dialog,DialogModal
Inheritance path: Primer,Streamable,WinPrimer,Dialog,DialogModal,DialogAbout
Inheritance path: Primer,Streamable,WinPrimer,Window
Inheritance path: Primer,Streamable,WinPrimer,Window,Splitter
Inheritance path: Primer,Streamable,WinPrimer,WinApp
Inheritance path: Primer,Streamable,WinPrimer,WinApp,SdiApp
Inheritance path: Primer,Streamable,Array
Inheritance path: Primer,Streamable,WinPrimer,Button
Inheritance path: Primer,LinkedList
Inheritance path: Primer,Streamable,WinPrimer,WinControl
Inheritance path: Primer,Streamable,WinPrimer,WinControl,ComboBox
Inheritance path: Primer,Streamable,WinPrimer,WinControl,STATIC
Inheritance path: Primer,Streamable,WinPrimer,WinControl,BUTTONW
Inheritance path: Primer,Puntito
Inheritance path: Primer,ObjetoD
Inheritance path: Primer,Streamable,WinPrimer,Window,Bag01
Inheritance path: Primer,MUESTRASIM
Inheritance path: Primer,ItemLayout
Inheritance path: Primer,Layout
Inheritance path: Primer,Layout,GridLayout
Inheritance path: Primer,Streamable,WinPrimer,Window,GridW
Inheritance path: Primer,ACUo
Inheritance path: Primer,AnimalSim
Inheritance path: Primer,AnimalSim,AnimalModelo2
Inheritance path: Primer,Streamable,WinPrimer,Window,Resul02
Inheritance path: Primer,GDMRK
Inheritance path: Primer,GDMRK,GDMSIM
Inheritance path: Primer,Streamable,WinPrimer,WinApp,SdiApp,DemoApp02
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
MacroLoop(1): iteration 1: Macro called from
  MacroLoop(5): iteration 1: Macro called from
   lst_create(10)[misc.inc]: Macro called from
    ll_MathTokenize(15)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_move(8)[linked_list.inc]: Macro called from
  tmt_on_oprt(65)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 2: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_move(10)[linked_list.inc]: Macro called from
  tmt_on_oprt(65)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 2: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_move(36)[linked_list.inc]: Macro called from
  tmt_on_oprt(65)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 2: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_move(37)[linked_list.inc]: Macro called from
  tmt_on_oprt(65)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 2: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_move(38)[linked_list.inc]: Macro called from
  tmt_on_oprt(65)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 2: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_move(39)[linked_list.inc]: Macro called from
  tmt_on_oprt(65)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 2: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_move(41)[linked_list.inc]: Macro called from
  tmt_on_oprt(65)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 2: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_insert(22)[linked_list.inc]: Macro called from
  tmt_on_oprt(135)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 4: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_insert(24)[linked_list.inc]: Macro called from
  tmt_on_oprt(135)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 4: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_insert(25)[linked_list.inc]: Macro called from
  tmt_on_oprt(135)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 4: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_insert(26)[linked_list.inc]: Macro called from
  tmt_on_oprt(135)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 4: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code
\masm32\Projects\odm01\DemoMuestra.inc(338) : Error A2100: Nesting level too deep
ll_insert(28)[linked_list.inc]: Macro called from
  tmt_on_oprt(135)[math_tokenizer.inc]: Macro called from
   MacroLoop(6): iteration 4: Macro called from
    ll_MathTokenize(111)[math_tokenizer.inc]: Macro called from
     fSlv8(51)[SmplMath.inc]: Macro called from
      \masm32\Projects\odm01\DemoMuestra.inc(338): Included by
       \masm32\Projects\odm01\Demo02_Main.inc(436): Included by
        \masm32\Projects\odm01\engine.inc(17): Included by
         IncludeObjectSrc(4)[Objects.inc]: Macro called from
          MakeObjects(1)[Objects.inc]: Macro called from
           Demo02.asm(76): Main line code


There is not response after the errors. The english expression have run from me, but in spanish we say "se cuelga".

later: HJWasm comebak:

\masm32\Projects\odm01\DemoMuestra.inc(338) : Fatal error A1105: Out of Memory

Perhaps in the logo you can show that it's de 32 version. HSE
Equations in Assembly: SmplMath

habran

Hi HSE,
I have built here special for you 32 bit version with 80 level macro nesting,
however, I don't take responsibility if something goes wrong

I have added in this version data definition directive 'DY' data for YMMWORD

you have to change in your sources and windows.inc line 12948 dy to _dy

MOUSEINPUT STRUCT
   _dx                    DWORD ?
   _dy                    DWORD ?    ;windows.inc line 12948
   mouseData         DWORD ?
   dwFlags              DWORD ?
   time                   DWORD ?
   dwExtraInfo        DWORD ?
MOUSEINPUT ENDS


Cod-Father

habran

Hey hutch,

Could it be possible to change _dx to dx_  and dy to dy_ in windows.inc
this is because of having data definition directive 'DY' data for YMMWORD

mov eax, [ecx].MOUSEINPUT.dx_
looks beter than
mov eax, [ecx].MOUSEINPUT._dx

for the reason
MOUSEINPUT STRUCT
   dx_                    DWORD ?
   dy_                    DWORD ?    ;windows.inc line 12948
   mouseData         DWORD ?
   dwFlags              DWORD ?
   time                   DWORD ?
   dwExtraInfo        DWORD ?
MOUSEINPUT ENDS

it is defined in winuser.inc

as well as in HELPWININFOA, HELPWININFOW, MDICREATESTRUCTA, MDICREATESTRUCTW, NMLVSCROLL
Cod-Father

HSE

There is another in line 19071  of Windows.inc:

NMLVSCROLL STRUCT
   hdr                    NMHDR <>
   _dx                    DWORD ?
   _dy                     DWORD ?
NMLVSCROLL ENDS


There is a .for macro in ObjAsm32
Equations in Assembly: SmplMath

habran

Cod-Father

HSE

Thanks habran for the experiment!

But nothing change. I have used the little test writed by rrr, and results are exactly the same: only 39 works. 

Viewing in your code, the same error is emitted when MAX_MACRO_NESTING,  MAX_SEG_NESTING,  MAX_IF_NESTING or MAX_RSP_NESTING are exceded. Perhaps it's posible a different message for a different error.


Equations in Assembly: SmplMath

habran

I'll investigate if there is a good reason to limit it to 40 levels and report it here 8)
Cod-Father

habran

As it can be seen below other definitions are connected to the MAX_MACRO_NESTING
/* input buffers
* 1. src line stack ( default I86: 2*600  = 1200 )
* 2. tokenarray     ( default I86: 150*12 = 1800 )
* 3. string buffer  ( default I86: 2*600  = 1200 )
*/

#ifdef __I86__
#define SIZE_SRCLINES     ( MAX_LINE_LEN * 2 )
#define SIZE_TOKENARRAY   ( sizeof( struct asm_tok ) * MAX_TOKEN )
#define SIZE_STRINGBUFFER ( MAX_LINE_LEN * 2 )
#else
#define SIZE_SRCLINES     ( MAX_LINE_LEN * ( MAX_MACRO_NESTING + 1 ) )
#define SIZE_TOKENARRAY   ( sizeof( struct asm_tok ) * MAX_TOKEN * MAX_MACRO_NESTING )
#define SIZE_STRINGBUFFER ( MAX_LINE_LEN * MAX_MACRO_NESTING )
#endif
Cod-Father

rrr314159

Don't forget the test I wrote might be limited by the IF / ENDIF not the macros, when I get around to it I can do one without IF / ENDIF
I am NaN ;)

habran

Thanks rrr314159 :t
Cod-Father

rrr314159

To remove all doubts about nesting I made this program, CreateNestedMacros.asm which creates a new file "NestedMacros.asm" with the requested number (levels) of nested macros. Then you compile this created asm file to see if the levels go that deep. It's possible to skip the intermediate file creation, by using macros to create the nested macros, but then it's hard (impossible?) to be sure just how many levels there are.

With JWasm64 it goes only to 20, blows up at 21. I don't know why my previous tester, which uses an IF / ENDIF construction, apparently can go twice as deep. But this program seems more authoritative. I also don't know why it seems to disagree with the JWasm setting at 40. You can also use this technique with ML, ML64, and JWasm 32-bit, they all give the same answer. Just modify this version appropriately. (Of course you'll have to modify the paths in the Compile batch files anyway).

The whole procedure is complicated enough that I threw in this instructions.txt:

Quote from: instructions.txtPurpose is to test how many levels deep Macro calls can go.

This is more complicated than it should be: 3 steps:

1) At top of CreateNestedMacros.asm set numberNestedMacrostoTest

2) at Command line run CreateNestedMacros.bat

3) then run CompileNestedMacros.bat

... you will see message "Nested Levels: --". If it's 0 you'll also see the error message, Error A2101: Macro nesting level too deep. Else it will be the number you entered (numberNestedMacrostoTest).

Sample run: (with 20 levels requested)

C:\NestedMacros>CreateNestedMacros

C:\NestedMacros>CompileNestedMacros
Nested Levels: 20
NestedMacros.asm: 94 lines, 2 passes, 0 ms, 0 warnings, 0 errors

Here's created "NestedMacros.asm" for 20 levels:

;================
echonum MACRO thenum, thetext:=<>
LOCAL ts$
ts$ TEXTEQU %thenum
% echo thetext &ts$
ENDM

;================
SumMacro0 MACRO NN
EXITM<NN>
ENDM
;================
SumMacro1 MACRO NN
EXITM <SumMacro0 (1 + NN)>
ENDM
;================
SumMacro2 MACRO NN
EXITM <SumMacro1 (1 + NN)>
ENDM
;================
SumMacro3 MACRO NN
EXITM <SumMacro2 (1 + NN)>
ENDM
;================
SumMacro4 MACRO NN
EXITM <SumMacro3 (1 + NN)>
ENDM
;================
SumMacro5 MACRO NN
EXITM <SumMacro4 (1 + NN)>
ENDM
;================
SumMacro6 MACRO NN
EXITM <SumMacro5 (1 + NN)>
ENDM
;================
SumMacro7 MACRO NN
EXITM <SumMacro6 (1 + NN)>
ENDM
;================
SumMacro8 MACRO NN
EXITM <SumMacro7 (1 + NN)>
ENDM
;================
SumMacro9 MACRO NN
EXITM <SumMacro8 (1 + NN)>
ENDM
;================
SumMacro10 MACRO NN
EXITM <SumMacro9 (1 + NN)>
ENDM
;================
SumMacro11 MACRO NN
EXITM <SumMacro10 (1 + NN)>
ENDM
;================
SumMacro12 MACRO NN
EXITM <SumMacro11 (1 + NN)>
ENDM
;================
SumMacro13 MACRO NN
EXITM <SumMacro12 (1 + NN)>
ENDM
;================
SumMacro14 MACRO NN
EXITM <SumMacro13 (1 + NN)>
ENDM
;================
SumMacro15 MACRO NN
EXITM <SumMacro14 (1 + NN)>
ENDM
;================
SumMacro16 MACRO NN
EXITM <SumMacro15 (1 + NN)>
ENDM
;================
SumMacro17 MACRO NN
EXITM <SumMacro16 (1 + NN)>
ENDM
;================
SumMacro18 MACRO NN
EXITM <SumMacro17 (1 + NN)>
ENDM
;================

%echonum SumMacro18 (2), Nested Levels:

.code
;================
start PROC
ret
start endp
;================
end

CreateNestedMacros.asm: 66 lines, 2 passes, 0 ms, 0 warnings, 0 errors


The zip contains:

CreateNestedMacros.asm: creates NestedMacros.asm
NestedMacros.asm: a sample with 20 levels
CreateNestedMacros.bat: does what it says
CompileNestedMacros.bat: ditto (modify JWasm path here and next batch file)
CompileCreateNestedMacros.bat: this is run by CreateNestedMacros.bat. Seems clumsy but appears to be the simplest way to accomplish the objective
instructions.txt: as above

hope it's useful

[edit] of course if you just want to test 20 and 21 levels it's no trouble. Just compile the above NestedMacros.asm - see that it works - then it's very simple to add one more level (SumMacro19) and see that it doesn't.
I am NaN ;)

rrr314159

It turns out that the "EXITM" counts as one macro, that's why the above only goes to 20 levels. Here's a new version which goes to 40 levels, and blows up at 41, like it should.

;================
echonum MACRO thenum, thetext:=<>
LOCAL ts$
ts$ TEXTEQU %thenum
% echo thetext &ts$
ENDM

;================
SumMacro0 MACRO NN
%echonum NN + 2, Nested Levels:
ENDM
;================

SumMacro1 MACRO NN
SumMacro0 NN
ENDM
;================
SumMacro2 MACRO NN
SumMacro1 NN
ENDM
;================
SumMacro3 MACRO NN
SumMacro2 NN
ENDM
;================
SumMacro4 MACRO NN
SumMacro3 NN
ENDM
;================
SumMacro5 MACRO NN
SumMacro4 NN
ENDM
;================
SumMacro6 MACRO NN
SumMacro5 NN
ENDM
;================
SumMacro7 MACRO NN
SumMacro6 NN
ENDM
;================
SumMacro8 MACRO NN
SumMacro7 NN
ENDM
;================
SumMacro9 MACRO NN
SumMacro8 NN
ENDM
;================
SumMacro10 MACRO NN
SumMacro9 NN
ENDM
;================
SumMacro11 MACRO NN
SumMacro10 NN
ENDM
;================
SumMacro12 MACRO NN
SumMacro11 NN
ENDM
;================
SumMacro13 MACRO NN
SumMacro12 NN
ENDM
;================
SumMacro14 MACRO NN
SumMacro13 NN
ENDM
;================
SumMacro15 MACRO NN
SumMacro14 NN
ENDM
;================
SumMacro16 MACRO NN
SumMacro15 NN
ENDM
;================
SumMacro17 MACRO NN
SumMacro16 NN
ENDM
;================
SumMacro18 MACRO NN
SumMacro17 NN
ENDM
;================
SumMacro19 MACRO NN
SumMacro18 NN
ENDM
;================
SumMacro20 MACRO NN
SumMacro19 NN
ENDM
;================
SumMacro21 MACRO NN
SumMacro20 NN
ENDM
;================
SumMacro22 MACRO NN
SumMacro21 NN
ENDM
;================
SumMacro23 MACRO NN
SumMacro22 NN
ENDM
;================
SumMacro24 MACRO NN
SumMacro23 NN
ENDM
;================
SumMacro25 MACRO NN
SumMacro24 NN
ENDM
;================
SumMacro26 MACRO NN
SumMacro25 NN
ENDM
;================
SumMacro27 MACRO NN
SumMacro26 NN
ENDM
;================
SumMacro28 MACRO NN
SumMacro27 NN
ENDM
;================
SumMacro29 MACRO NN
SumMacro28 NN
ENDM
;================
SumMacro30 MACRO NN
SumMacro29 NN
ENDM
;================
SumMacro31 MACRO NN
SumMacro30 NN
ENDM
;================
SumMacro32 MACRO NN
SumMacro31 NN
ENDM
;================
SumMacro33 MACRO NN
SumMacro32 NN
ENDM
;================
SumMacro34 MACRO NN
SumMacro33 NN
ENDM
;================
SumMacro35 MACRO NN
SumMacro34 NN
ENDM
;================
SumMacro36 MACRO NN
SumMacro35 NN
ENDM
;================
SumMacro37 MACRO NN
SumMacro36 NN
ENDM
;================
SumMacro38 MACRO NN
SumMacro37 NN
ENDM
;================
;================
SumMacro39 MACRO NN
SumMacro38 NN
ENDM
;================

SumMacro38 38

.code
;================
start PROC
ret
start endp
;================
end


This does 40, to try 41 just change the line near the bottom "SumMacro38 38" to "SumMacro39 39".

Here's the prog used to create the above, in case you ever want to test 256! Use the same .bat files and the same instructions as in the previous prog using EXITM.

;; Set numberNestedMacrostoTest to desired level. 20 works, 21 gives error "Nesting too deep"

numberNestedMacrostoTest = 41

;; ------------------------------------------------------------------------------------------------


numberNestedMacros = numberNestedMacrostoTest - 2

nNM$ textequ %numberNestedMacros

commentline textequ <;================>

%echo &commentline ;================
echo echonum MACRO thenum, thetext:=<>
echo LOCAL ts$
echo     ts$ TEXTEQU %thenum
echo     % echo thetext &ts$
echo ENDM
echo

%echo &commentline ;================
echo SumMacro0 MACRO NN
%echo %echonum NN + 2, Nested Levels:
echo ENDM
%echo &commentline ;================
echo
;***********************
echonumname MACRO thenum
;***********************
LOCAL ts$, thenumminus1
    thenumminus1 = thenum - 1
    ts$ TEXTEQU %thenum
    % echo SumMacro&&ts$ MACRO NN
    ts$ TEXTEQU %thenumminus1
    % echo     SumMacro&&ts$ NN
    %echo ENDM
%echo &commentline ;================
ENDM
;***********************

_loop = 0
REPEAT numberNestedMacros
    _loop = _loop + 1
    echonumname _loop
ENDM
echo

%echo SumMacro&nNM$ &nNM$
echo

echo .code

%echo &commentline ;================
echo start PROC
echo    ret
echo start endp
%echo &commentline ;================
echo end
echo

.code

start PROC
    ret
start endp

end
I am NaN ;)