News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

MASM32 compiler error with labels

Started by patriciocs, August 14, 2019, 10:46:33 PM

Previous topic - Next topic

patriciocs

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:

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:): 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

fearless

Labels cant start with numbers , but can have number values in them

Label_1:
Label2:
L4b3l3:

fearless

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)

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
   

patriciocs

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?

FORTRANS

Hi,

Quote from: patriciocs on August 15, 2019, 12:09:43 AM
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.

hutch--

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 ....

jj2007

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 @@:

tenkey

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.

hutch--

 :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

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

patriciocs

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!!!