Fatal error a1008 unmatched macro nesting

Fatal error a1008 unmatched macro nesting Welcome, Guest. Please login or register. January 16, 2023, 11:20:04 PM The MASM Forum Archive 2004 to 2012 General Forums The Workshop fatal error A1008: unmatched macro nesting « previous next » Pages: [1] Author Topic: fatal error A1008: unmatched macro nesting (Read 6978 times) Seb I’m trying […]
Seb

I’m trying to translate a C function to Assembly, and it all seemed to float on quite well (when it comes to my understanding of what I’m doing :D), but when trying to compile I get the error described in the topic. Any ideas?

PublicAlias MACRO MangledName ; macro for giving a function alias public names
MangledName label near
public MangledName
ENDM

RETURN MACRO VAL
MOV EAX, VAL
RET
RETURN ENDM

allocate_buffers PROC alac:DWORD
PUSH EBX
PUSH ECX
MOV EBX, alac
MOV ECX, [EBX+40] ; setinfo_max_samples_per_frame
MUL ECX, 4

INVOKE Alloc, ECX
OR EAX, EAX
JZ Error
MOV DWORD PTR [EBX+24], EAX
INVOKE Alloc, ECX
OR EAX, EAX
JZ Error
MOV DWORD PTR [EBX+28], EAX
INVOKE Alloc, ECX
OR EAX, EAX
JZ Error
MOV DWORD PTR [EBX+32], EAX
INVOKE Alloc, ECX
OR EAX, EAX
JZ Error
MOV DWORD PTR [EBX+36], EAX

POP ECX
POP EBX
RETURN 1
Error:
RET ; EAX is already 0
allocate_buffers ENDP

alac_set_info PROC NEAR
PUBLIC alac_set_info
PublicAlias _alac_set_info
PUSH EAX
PUSH EBX
PUSH EDX

MOV EAX, [ESP+8] ; EAX = inputbuffer;
MOV EBX, [ESP+4] ; EBX = alac
; CX = tmp
; EDX = tmp2
ADD EAX, 24 ; ptr+=24;
MOV EDX, DWORD PTR [EAX]
BSWAP EDX
MOV DWORD PTR [EBX+40], EDX ; alac->setinfo_max_samples_per_frame=tmp2;
ADD EAX, 4 ; ptr+=4;
INC EAX
MOV BYTE PTR [EBX+41], EAX ; alac->setinfo_7a=*ptr++;
INC EAX
MOV BYTE PTR [EBX+42], EAX ; alac->setinfo_sample_size = *ptr++;
INC EAX
MOV BYTE PTR [EBX+43], EAX ; alac->setinfo_rice_historymult = *ptr++;
INC EAX
MOV BYTE PTR [EBX+44], EAX ; alac->setinfo_rice_initialhistory = *ptr++;
INC EAX
MOV BYTE PTR [EBX+45], EAX ; alac->setinfo_rice_kmodifier = *ptr++;
INC EAX
MOV BYTE PTR [EBX+46], EAX ; alac->setinfo_7f = *ptr++;
MOV CX, WORD PTR [EAX] ; tmp=*(uint16_t*)ptr;
ROL CX, 8 ; _Swap16(tmp);
MOV WORD PTR [EBX+48], CX ; alac->setinfo_80=tmp;
ADD EAX, 2 ; ptr+=2;
MOV EDX, DWORD PTR [EAX] ; tmp2=*(uint32_t*)ptr;
BSWAP EDX ; _Swap32(tmp2);
MOV DWORD PTR [EBX+52], EDX ; alac->setinfo_82=tmp2;
ADD EAX, 4 ; ptr+=4;
MOV EDX, DWORD PTR [EAX] ; tmp2=*(uint32_t*)ptr;
BSWAP EDX ; _Swap32(tmp2);
MOV DWORD PTR [EBX+56], EDX ; alac->setinfo_86=tmp2;
ADD EAX, 4 ; ptr+=4;
MOV EDX, DWORD PTR [EAX] ; tmp2=*(uint32_t*)ptr;
BSWAP EDX ; _Swap32(tmp2);
MOV DWORD PTR [EBX+60], EDX ; alac->setinfo_8a_rate=tmp2;
ADD EAX, 4 ; ptr+=4;

POP EDX
POP EBX
POP EAX
INVOKE allocate_buffers, EBX ; return allocate_buffers(alac);
RET
alac_set_info ENDP

Any tips on how this code can be optimized (speed or size) is of course also welcome.

#1

Posted 05 March 2013 — 12:31 AM

drew77

  • Reputation:
    21
    • Gender:Male
    • Location:Texas
    • Interests:Bicycling, Photography, Electronics, Swimming
    • Coding:32 bit Assembly, C, C++

    I am getting fatal error A1008: unmatched macro nesting with this code that uses some seh macros.

     
    ; Clear_dr0.asm
    ;
    ;
    include masm32includemasm32rt.inc  
    
    @TRY_BEGIN MACRO Handler
    	 pushad						  ; Save Current State
    	 mov esi, offset Handler		 ; Address of New Exception Handler
    	 push esi					    ; Save Old Exception Handler
    	 push dword ptr fs:[0]		   ; Install New Handler
    	 mov dword ptr fs:[0], esp
    ENDM
    
    @TRY_EXCEPT MACRO Handler
    	 jmp NoException&;Handler	    ; No Exception Occured, so jump over
    Handler:
    	 mov esp, [esp + 8]			  ; Exception Occured, Get old ESP
    	 pop dword ptr fs:[0]		    ; Restore Old Exception Handler
    	 add esp, 4					  ; ESP value before SEH was set
    	 popad						   ; Restore Old State
    ENDM
    
    @TRY_END MACRO Handler
    	 jmp ExceptionHandled&;Handler    ; Exception was handled by @TRY_EXCEPT
    NoException&;Handler:			    ; No Exception Occured
    	 pop dword ptr fs:[0]			 ; Restore Old Exception Handler
    	 add esp, 32 + 4				  ; ESP value before SEH was set. 32 for pushad and ...
    ExceptionHandled&;Handler:		   ; ...4 for push offset Handler. (No Restore State)
    									  ; Exception has been handled, or no exception occured
    ENDM
    .CONST
    .data
      
    WaterMark   db  "SiegeWorks 2013 ð__ð" ; Alt 240 char
    %Date	   db  " &@Date " ; Compile date
    %time	   db  " &@Time"
    
    .data?
    
    .code
    
    start:
    
    ; push offset handler
    ; push dword ptr fs:[0]
    ; mov fs:[0],esp
    ; xor eax, eax
    ; div eax ;generate exception
    ; pop fs:[0]
    ; add esp, 4
    @TRY_BEGIN MACRO Handler
    
    @TRY_EXCEPT MACRO Handler
    	
    xor eax, eax
    div eax ;generate exception
    
    ;continue execution
    ;...
    fn MessageBox,0,str$(eax),"Title",MB_OK
    handler:
    mov ecx, [esp+0Ch] ;skip div
    add dword ptr [ecx+0B8h], 2 ;skip div
    mov dword ptr [ecx+04h], 0 ;clean dr0
    mov dword ptr [ecx+08h], 0 ;clean dr1
    mov dword ptr [ecx+0Ch], 0 ;clean dr2
    mov dword ptr [ecx+10h], 0 ;clean dr3
    mov dword ptr [ecx+14h], 0 ;clean dr6
    mov dword ptr [ecx+18h], 0 ;clean dr7
    xor eax, eax
    
    @TRY_END MACRO Handler
    
    invoke ExitProcess,0
    
    end	 start
    

    • Back to top


    #2

    Posted 05 March 2013 — 04:04 AM

    rohitab

      Founder

    • Super Administrators
    • 952 posts
  • Reputation:
    492
    • Gender:Male
    • Location:Mass, USA
    • Interests:Chess, Reverse Engineering Software, Horse Riding, XBOX Live!

    Disclaimer: Any errors in spelling, tact or fact are transmission errors.

    • Back to top


    #3

    Posted 06 March 2013 — 04:13 PM

    drew77

  • Reputation:
    21
    • Gender:Male
    • Location:Texas
    • Interests:Bicycling, Photography, Electronics, Swimming
    • Coding:32 bit Assembly, C, C++

    I got it working correctly.

    • Back to top


    KnowledgeBase Archive

    An Archive of Early Microsoft KnowledgeBase Articles

    View on GitHub


    Article: Q113420
    Product(s): Microsoft Macro Assembler
    Version(s): 6.0,6.0a,6.0b,6.1,6.11,6.1a
    Operating System(s): 
    Keyword(s): 
    Last Modified: 06-MAY-2001
    
    -------------------------------------------------------------------------------
    The information in this article applies to:
    
    - Microsoft Macro Assembler (MASM), versions 6.0, 6.0a, 6.0b, 6.1, 6.1a, 6.11 
    -------------------------------------------------------------------------------
    
    SYMPTOMS
    ========
    
    Angle brackets ("<>") are required for the argument list of a FOR
    statement. If the angle brackets are missing from the argument list of a FOR
    statement in a macro, no listing file will be created and errors A1008 and A2008
    will be generated. The sample given at the end of this article generates the
    following errors:
    
      test.asm(17): error A2008: syntax error : integer
    
      numargs(3): Macro Called From
      test.asm(17): Main Line Code
    
      test.asm(17): fatal error A1008: unmatched macro nesting
    
      numargs(5): Macro Called From
      test.asm(17): Main Line Code
    
    CAUSE
    =====
    
    Because A1008 is a fatal error, no listing file is created.
    
    RESOLUTION
    ==========
    
    The error messages indicate where the error occurs, but may be difficult to
    interpret. The first message line indicates that an A2008 error occurred at line
    17 of the program (see the sample below). The second message shows that the
    actual error is on line 3 of the numargs macro. The error can be located and
    eliminated by finding this line and adding the angle brackets around varg (shown
    as a commented line in the sample).
    
    STATUS
    ======
    
    Microsoft has confirmed this to be a problem in MASM versions 6.x. We are
    researching this problem and will post new information here in the Microsoft
    Knowledge Base as it becomes available.
    
    Sample Code
    -----------
    
      ; Assemble options needed:  /c /Fl /Sa
    
        .MODEL small
    
        numargs  MACRO varg:VARARG
          mov ax,0
          ; Following line should be FOR val, <varg>
          FOR val, varg
            inc ax
          ENDM
        ENDM
    
        .STACK
        .DATA
        .CODE
        .STARTUP
          numargs 1,1,1
        .EXIT
        END
    
    Additional query words: 6.00 6.00a 6.10 6.10a 6.x 6.1x buglist6.00 buglist6.10 buglist6.11
    
    ======================================================================
    Keywords          :  
    Technology        : kbMASMsearch kbAudDeveloper kbMASM600 kbMASM610 kbMASM611 kbMASM610a kbMASM600a kbMASM600b
    Version           : :6.0,6.0a,6.0b,6.1,6.11,6.1a
    
    =============================================================================
    

    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
    PROVIDED «AS IS» WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS
    ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO
    EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
    ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
    CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
    MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION
    OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
    SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Copyright Microsoft Corporation 1986-2002.

    Понравилась статья? Поделить с друзьями:

    Читайте также:

  • Fatal error a1007 nesting level too deep
  • Fatal error a1000 cannot open file masm
  • Fatal error a1000 cannot open file irvine32 inc
  • Fatal error 99 faceit как решить
  • Fatal error 980

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии