News:

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

fatal error A1008: unmatched macro nesting

Started by Seb, October 14, 2005, 09:02:14 AM

Previous topic - Next topic

Seb

Hello!

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?


.386
.MODEL FLAT

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

.CODE

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

END


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

Regards,
Seb

MichaelW

Quote
Syntax:   name MACRO [parameter[:tag]] [,parameter[:tag]]...]
              [LOCAL varlist]
              statements
              [EXITM [textitem]]
            ENDM
Note that the name is not repeated before ENDM. 
eschew obfuscation