The MASM Forum

Projects => MASM32 => Topic started by: patriciocs on August 14, 2019, 10:46:33 PM

Title: MASM32 compiler error with labels
Post by: patriciocs on August 14, 2019, 10:46:33 PM
Hello, this is my first post. I am new in all this assembler development and after reading a lot searching all over internet I have an issue with a DLL I am building I hope you could help me to sort out.

The dll have this procedure:

Code: [Select]
align 4
procesarComando proc Cadena:DWORD
.data
    align 4
    procComTbl \
        dd 10,11,12,13,14,15,16,17,18,19,110,111,112,113
.code
    invoke getComandoNum,Cadena
    cmp eax, 13
    ja error
    jmp DWORD PTR [procComTbl+eax*4]
   
align 4
error:
    mov eax, -1
    jmp quit_procesarComando
align 4
10:
invoke putRespuestaBase,Cadena
    invoke putRespuestaComando1, Cadena
    jmp quit_procesarComando
 
align 4
11: ;verificar
    mov eax, 1
    jmp quit_procesarComando
...
align 4
113:
    mov eax, 13
    jmp quit_procesarComando
   
align 4
quit_procesarComando:
    Ret
procesarComando endp
   

When I try to compile this I receive this error in each of the labels (10: 11: 12: ... 113:):
Code: [Select]
error A2008: syntax error : integer
I am completely lost as it is supposed that this code should compile with MASM6 and MASM32. I tried with both compilers with no luck. Do you have any recommendation about what could be wrong or how could be fixed in this procedure. I though that perhaps I should change the numeric labels but it looks like if I do that the procedure will not work.

Thank you all in advance
Title: Re: MASM32 compiler error with labels
Post by: fearless on August 14, 2019, 11:20:01 PM
Labels cant start with numbers , but can have number values in them

Code: [Select]
Label_1:
Label2:
L4b3l3:
Title: Re: MASM32 compiler error with labels
Post by: fearless on August 14, 2019, 11:28:27 PM
Not sure if this would work (haven't tested it), but could try to get the address of the labels and store them in the array (procComTbl)

Code: [Select]
align 4
procesarComando proc Cadena:DWORD
.const
    L10 equ Offset Label10
    L11 equ Offset Label11
    L12 equ Offset Label12
    L13 equ Offset Label13
    L14 equ Offset Label14
    L15 equ Offset Label15
    L16 equ Offset Label16
    L17 equ Offset Label17
    L18 equ Offset Label18
    L19 equ Offset Label19
    L110 equ Offset Label110
    L111 equ Offset Label111
    L112 equ Offset Label112
    L113 equ Offset Label113
.data
    align 4
    procComTbl \
        dd L10,L11,L12,L13,L14,L15,L16,L17,L18,L19,L110,L111,L112,L113
.code
    invoke getComandoNum,Cadena
    cmp eax, 13
    ja error
    jmp DWORD PTR [procComTbl+eax*4]
   
align 4
error:
    mov eax, -1
    jmp quit_procesarComando
align 4
Label10:
    invoke putRespuestaBase,Cadena
    invoke putRespuestaComando1, Cadena
    jmp quit_procesarComando
 
align 4
Label11: ;verificar
    mov eax, 1
    jmp quit_procesarComando
...
align 4
Label113:
    mov eax, 13
    jmp quit_procesarComando
   
align 4
quit_procesarComando:
    Ret
procesarComando endp
   
Title: Re: MASM32 compiler error with labels
Post by: patriciocs on August 15, 2019, 12:09:43 AM
Thank you very much for your amazingly quick response!!!

I modified the code following your suggestions and now it compiles successfully. Now I must test if it is working as expected.

Just a doubt. The developer of the code told me that it compiled fine years ago when he wrote this code. He told me he used MASM6. Could it be that in the past there were not that limitation about labels not starting with digits?
Title: Re: MASM32 compiler error with labels
Post by: FORTRANS on August 15, 2019, 12:36:00 AM
Hi,

Just a doubt. The developer of the code told me that it compiled fine years ago when he wrote this code. He told me he used MASM6. Could it be that in the past there were not that limitation about labels not starting with digits?

   No.  That has been a requirement since version one.

Regards,

Steve N.
Title: Re: MASM32 compiler error with labels
Post by: hutch-- on August 15, 2019, 01:07:14 AM
Just as a personal preference, I regularly name labels like this if I don't need to use specific names for labels.

lbl0:
  ....
lbl1:
  ....
etc ....


You can make tables like this.

  .data
    align 4
    deftbl \
      dd l0,l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15
  .code

lo l1 l2 etc .... are written as normal labels.

l0:
....
l1:
....
etc ....
Title: Re: MASM32 compiler error with labels
Post by: jj2007 on August 15, 2019, 01:11:17 AM
Last but not least: Labels inside procedures are local, invisible from outside. Have a look also at anonymous labels, i.e. jmp @B, jmp @F and @@:
Title: Re: MASM32 compiler error with labels
Post by: tenkey on August 15, 2019, 01:24:00 AM
Lower case letter l and numeral 1 can look alike in some character fonts. If the original code worked, the labels were probably L0, L1, etc. The jump from 19 to 110 was probably a sequencing from L9 to L10.
Title: Re: MASM32 compiler error with labels
Post by: hutch-- on August 15, 2019, 01:50:05 AM
 :biggrin:

I cheated, I used a tool I wrote years ago to make a branching proc based on the table. It looks like this.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

align 4

default proc value:DWORD

  .data
    align 4
    deftbl \
      dd l0,l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15
  .code


    mov eax, value
    cmp eax, 15
    ja error
    jmp DWORD PTR [deftbl+eax*4]

  align 4
  error:
    mov eax, -1
    jmp quit_default

  align 4
  l0:
    mov eax, 0
    jmp quit_default

  align 4
  l1:
    mov eax, 1
    jmp quit_default

  align 4
  l2:
    mov eax, 2
    jmp quit_default

  align 4
  l3:
    mov eax, 3
    jmp quit_default

  align 4
  l4:
    mov eax, 4
    jmp quit_default

  align 4
  l5:
    mov eax, 5
    jmp quit_default

  align 4
  l6:
    mov eax, 6
    jmp quit_default

  align 4
  l7:
    mov eax, 7
    jmp quit_default

  align 4
  l8:
    mov eax, 8
    jmp quit_default

  align 4
  l9:
    mov eax, 9
    jmp quit_default

  align 4
  l10:
    mov eax, 10
    jmp quit_default

  align 4
  l11:
    mov eax, 11
    jmp quit_default

  align 4
  l12:
    mov eax, 12
    jmp quit_default

  align 4
  l13:
    mov eax, 13
    jmp quit_default

  align 4
  l14:
    mov eax, 14
    jmp quit_default

  align 4
  l15:
    mov eax, 15
    jmp quit_default

  quit_default:


    ret

default endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
Title: Re: MASM32 compiler error with labels
Post by: patriciocs on August 15, 2019, 01:51:48 AM
guys you are amazing! That was the issue!!!!! I copied the code and probably the labels were with l and not 1.

What a noob. Thank you very much, what an amazing community is this!!!