Error a2008 ассемблер

C++ Documentation. Contribute to MicrosoftDocs/cpp-docs development by creating an account on GitHub.

Permalink

Cannot retrieve contributors at this time

description title ms.date ms.custom f1_keywords helpviewer_keywords ms.assetid

Learn more about: ML Nonfatal Error A2008

ML Nonfatal Error A2008

12/17/2019

error-reference

A2008

A2008

ca24157f-c88a-4678-ae06-3bc3cd956001

syntax error :

A token at the current location caused a syntax error.

One of the following may have occurred:

  • A dot prefix was added to or omitted from a directive.

  • A reserved word (such as C or SIZE) was used as an identifier.

  • An instruction was used that was not available with the current processor or coprocessor selection.

  • A comparison run-time operator (such as ==) was used in a conditional assembly statement instead of a relational operator (such as EQ).

  • An instruction or directive was given too few operands.

  • An obsolete directive was used.

See also

ML Error Messages

I have a Visual Studio C/C++ project with a single assembly file main.asm in it. During the process of building the project I get the errors:

1>main.asm(5): error A2008: syntax error : .
1>main.asm(6): error A2008: syntax error : .
1>main.asm(7): error A2008: syntax error : .
1>main.asm(8): error A2008: syntax error : ,
1>main.asm(20): error A2008: syntax error : INVOKE

My code for main.asm is:

; program 3.1
; sample Assembly program - MASM (32-bit)


.386                                ; Line 5
.MODEL FLAT, stdcall                ; Line 6
.STACK 4096                         ; Line 7
ExitProcess PROTO, dwExitCode:DWORD ; Line 8

.data
sum DWORD 0

.code
_main PROC
mov eax, 25
mov ebx, 50
add ebx, ebx
mov sum, eax

INVOKE ExitProcess, 0               ; Line 20
_main ENDP
END

A screenshot of Visual Studio with my code and the errors:

 https://i.stack.imgur.com/VCtKg.jpg

Why am I getting these errors and how can I fix them?

Michael Petch's user avatar

Michael Petch

45.3k8 gold badges104 silver badges190 bronze badges

asked Oct 11, 2020 at 8:59

Kool Fuel's user avatar

7

Based on the errors you are showing on the line starting with .MODEL, .STACK, and .386 I can only gather that you are building for a 64-bit target rather than a 32-bit target. You likely also received errors related to the INVOKE directive as well. None of these directives are supported by 64-bit MASM and thus are generating errors. In 64-bit code the model is always assumed to be flat and the calling conventions for CDECL, STDCALL, THISCALL, FASTCALL etc are all the same and follow the Windows 64-bit Calling Convention.

You have two choices:

  • Build a 32-bit application. In Visual Studio as part of the menu bars there is a pull down box for the platform. The platform can be adjusted in the toolbar by changing x64 to x86:

    enter image description here

  • Modify the code to work with 64-bit code. To build in 64-bit you have to replace INVOKE with CALL and the Windows 64-bit calling convention must be used. You can remove the .STACK, .MODEL, and .386 directives. Modify the definition of the external procedures by declaring them EXTERN with a PROC type. The code could look something like:

    ; program 3.1
    ; sample Assembly program - MASM (64-bit)
    
    extern ExitProcess:PROC
    public mainCRTStartup
    
    .data
    sum DWORD 0
    
    .code
    mainCRTStartup PROC       ; Use mainCRTStartup if making a CONSOLE app without
                              ;   any C/C++ files AND if you haven't overridden the
                              ;   ENTRY point in the Visual Studio Project.
      sub rsp, 8+32           ; Align stack on 16 byte boundary and allocate 32 bytes
                              ;   of shadow space for call to ExitProcess. Shadow space
                              ;   is required for 64-bit Windows Calling Convention as
                              ;   is ensuring the stack is aligned on a 16 byte boundary
                              ;   at the point of making a call to a C library function
                              ;   or doing a WinAPI call.
      mov eax, 25
      mov ebx, 50
      add ebx, ebx
      mov sum, eax
    
      xor ecx, ecx            ; Set Error Code to 0 (RCX is 1st parameter)
      call ExitProcess
    mainCRTStartup ENDP
    END
    

    The entry point may be different for your environment depending on whether you are creating a GUI or CONSOLE application and whether your project has a C/C++ file present.

    Function names in the 64-bit calling convention are not required to start with an underscore unlike 32-bit Windows code.

answered Oct 11, 2020 at 20:31

Michael Petch's user avatar

Michael PetchMichael Petch

45.3k8 gold badges104 silver badges190 bronze badges

Ferreira

1 / 1 / 0

Регистрация: 12.11.2018

Сообщений: 5

1

MASM

18.09.2019, 23:37. Показов 6214. Ответов 2

Метки нет (Все метки)


Начал изучать книгу «Самоучитель Ассемблера» Александра Крупника, и в первой же программе ошибка.

Assembler
1
2
3
4
5
6
7
8
9
10
.586
.model flat, stdcall
includelib D:masm32libkernel32.lib
ExitProcess proto :DWORD
.code
start:
mov eax. 2
add eax. 3 
invoke ExitProcess. 0
end start

PowerShall:

PS D:Asemblersum> ml /c /coff new.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.

Assembling: new.asm
new.asm(7) : error A2008: syntax error : in instruction
new.asm(8) : error A2008: syntax error : in instruction
new.asm(9) : error A2166: structure field expected
PS D:Asemblersum>

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

18.09.2019, 23:37

2

Ушел с форума

Автор FAQ

15703 / 7377 / 980

Регистрация: 11.11.2010

Сообщений: 13,321

19.09.2019, 04:01

2

Ferreira,
в 7 и 8 строке должны быть запятые, а не точки

new.asm(7) : error A2008: syntax error : in instruction
new.asm(8) : error A2008: syntax error : in instruction

в 9 строке после ExitProcess должна быть запятая

new.asm(9) : error A2166: structure field expected



2



1 / 1 / 0

Регистрация: 12.11.2018

Сообщений: 5

19.09.2019, 19:20

 [ТС]

3

Спасибо, разобрался.



0



hey Max

thanks for the help.

I am using MS compiler to compile from .cpp to .asm.

As per your suggestion i turned the RTC option off and now it doesnt show this error …..BUT now it shows a new error to me

Compiling…
test.cpp
Linking…

test.obj : error LNK2005: «`string'» (??_C@_0M@LACCCNMM@hello?5world?$AA@) already defined in test.obj

test.obj : error LNK2005: _main already defined in test.obj

Debug/test.exe : fatal error LNK1169: one or more multiply defined symbols found

i am pasting my small test.cpp code and the .asm generated

test.cpp

#include «stdafx.h»

int

_tmain(int argc, _TCHAR* argv[])

{

printf(«hello world»);

return 0;

}

test.asm

; Listing generated by Microsoft Optimizing Compiler Version 13.10.3077

TITLE . est.cpp

.386P

include listing.inc

if @Version gt 510

.model FLAT

else

_TEXT SEGMENT PARA USE32 PUBLIC ‘CODE’

_TEXT ENDS

_DATA SEGMENT DWORD USE32 PUBLIC ‘DATA’

_DATA ENDS

CONST SEGMENT DWORD USE32 PUBLIC ‘CONST’

CONST ENDS

_BSS SEGMENT DWORD USE32 PUBLIC ‘BSS’

_BSS ENDS

$$SYMBOLS SEGMENT BYTE USE32 ‘DEBSYM’

$$SYMBOLS ENDS

$$TYPES SEGMENT BYTE USE32 ‘DEBTYP’

$$TYPES ENDS

_TLS SEGMENT DWORD USE32 PUBLIC ‘TLS’

_TLS ENDS

; COMDAT ??_C@_0M@LACCCNMM@hello?5world?$AA@

CONST SEGMENT DWORD USE32 PUBLIC ‘CONST’

CONST ENDS

xdata$x SEGMENT DWORD USE32 PUBLIC ‘CONST’

xdata$x ENDS

; COMDAT _main

_TEXT SEGMENT PARA USE32 PUBLIC ‘CODE’

_TEXT ENDS

; COMDAT ?_Psave@?$_Facetptr@V?$ctype@G@std@@@std@@2PBVfacet@locale@2@B

_DATA SEGMENT DWORD USE32 PUBLIC ‘DATA’

_DATA ENDS

; COMDAT ?_Psave@?$_Facetptr@V?$ctype@D@std@@@std@@2PBVfacet@locale@2@B

_DATA SEGMENT DWORD USE32 PUBLIC ‘DATA’

_DATA ENDS

sxdata SEGMENT DWORD USE32 ‘SXDATA’

sxdata ENDS

FLAT GROUP _DATA, CONST, _BSS

ASSUME CS: FLAT, DS: FLAT, SS: FLAT

endif

INCLUDELIB LIBCD

INCLUDELIB OLDNAMES

PUBLIC _main

PUBLIC ??_C@_0M@LACCCNMM@hello?5world?$AA@ ; `string’

EXTRN _printf:NEAR

; COMDAT ??_C@_0M@LACCCNMM@hello?5world?$AA@

; File c:documents and settingssdesaimy documentsvisual studio projects est est.cpp

CONST SEGMENT

??_C@_0M@LACCCNMM@hello?5world?$AA@ DB ‘hello world’, 00H ; `string’

; Function compile flags: /Odt /ZI

CONST ENDS

; COMDAT _main

_TEXT SEGMENT

_argc$ = 8 ; size = 4

_argv$ = 12 ; size = 4

_main PROC NEAR ; COMDAT

; Line 7

push ebp

mov ebp, esp

sub esp, 64 ; 00000040H

push ebx

push esi

push edi

; Line 8

push OFFSET FLAT:??_C@_0M@LACCCNMM@hello?5world?$AA@

call _printf

add esp, 4

; Line 9

xor eax, eax

; Line 10

pop edi

pop esi

pop ebx

mov esp, ebp

pop ebp

ret 0

_main ENDP<
/P>

_TEXT ENDS

END

thanks in advance for your help

Shippi

Содержание

  1. Visual Studio C/C++ Project with MASM code produces error `error A2008: syntax error : .` [closed]
  2. 1 Answer 1
  3. Error a2008 syntax error addr
  4. error A2008: syntax error : . in the .asm file

Visual Studio C/C++ Project with MASM code produces error `error A2008: syntax error : .` [closed]

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 2 years ago .

I have a Visual Studio C/C++ project with a single assembly file main.asm in it. During the process of building the project I get the errors:

My code for main.asm is:

A screenshot of Visual Studio with my code and the errors:

Why am I getting these errors and how can I fix them?

1 Answer 1

Based on the errors you are showing on the line starting with .MODEL , .STACK , and .386 I can only gather that you are building for a 64-bit target rather than a 32-bit target. You likely also received errors related to the INVOKE directive as well. None of these directives are supported by 64-bit MASM and thus are generating errors. In 64-bit code the model is always assumed to be flat and the calling conventions for CDECL, STDCALL, THISCALL, FASTCALL etc are all the same and follow the Windows 64-bit Calling Convention.

You have two choices:

Build a 32-bit application. In Visual Studio as part of the menu bars there is a pull down box for the platform. The platform can be adjusted in the toolbar by changing x64 to x86 :

Modify the code to work with 64-bit code. To build in 64-bit you have to replace INVOKE with CALL and the Windows 64-bit calling convention must be used. You can remove the .STACK , .MODEL , and .386 directives. Modify the definition of the external procedures by declaring them EXTERN with a PROC type. The code could look something like:

The entry point may be different for your environment depending on whether you are creating a GUI or CONSOLE application and whether your project has a C/C++ file present.

Function names in the 64-bit calling convention are not required to start with an underscore unlike 32-bit Windows code.

Источник

Error a2008 syntax error addr

Success! Subscription added.

Success! Subscription removed.

Sorry, you must verify to complete this action. Please click the verification link in your email. You may re-send via your profile.

  • Intel Communities
  • Developer Software Forums
  • Software Development Tools
  • Intel® C++ Compiler
  • error A2008: syntax error : . in the .asm file

error A2008: syntax error : . in the .asm file

  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

__RTC_InitBase.rtc$IMZ DD FLAT:__RTC_InitBase

__RTC_Shutdown.rtc$TMZ DD FLAT:__RTC_Shutdown

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

I don’t have a windows compiler to try this out and it’s unclear if you are using the MS compiler or icl to compile from .cpp to .asm.

From the symbols shown that seem to cause the error, here’s a guess — RTC = run time check. Do you have options on the command line to specify some run time checks? Maybe if you turn those options off, you may have better results. Just a guess for now.

As an aside, our compiler does not make the explicit promise that code compiled to asm can be assembled into an object file. It’s more of a ‘for your reference’ listing.

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

thanks for the help.

I am using MS compiler to compile from .cpp to .asm.

As per your suggestion i turned the RTC option off and now it doesnt show this error . BUT now it shows a new error to me

test.obj : error LNK2005: «`string’» (??_C@_0M@LACCCNMM@hello?5world?$AA@) already defined in test.obj

test.obj : error LNK2005: _main already defined in test.obj

Debug/test.exe : fatal error LNK1169: one or more multiply defined symbols found

i am pasting my small test.cpp code and the .asm generated

_tmain( int argc, _TCHAR* argv[])

; Listing generated by Microsoft Optimizing Compiler Version 13.10.3077

if @Version gt 510

_TEXT SEGMENT PARA USE32 PUBLIC ‘CODE’

_DATA SEGMENT DWORD USE32 PUBLIC ‘DATA’

CONST SEGMENT DWORD USE32 PUBLIC ‘CONST’

_BSS SEGMENT DWORD USE32 PUBLIC ‘BSS’

$$SYMBOLS SEGMENT BYTE USE32 ‘DEBSYM’

$$TYPES SEGMENT BYTE USE32 ‘DEBTYP’

_TLS SEGMENT DWORD USE32 PUBLIC ‘TLS’

CONST SEGMENT DWORD USE32 PUBLIC ‘CONST’

xdata$x SEGMENT DWORD USE32 PUBLIC ‘CONST’

_TEXT SEGMENT PARA USE32 PUBLIC ‘CODE’

_DATA SEGMENT DWORD USE32 PUBLIC ‘DATA’

_DATA SEGMENT DWORD USE32 PUBLIC ‘DATA’

sxdata SEGMENT DWORD USE32 ‘SXDATA’

FLAT GROUP _DATA, CONST, _BSS

ASSUME CS: FLAT, DS: FLAT, SS: FLAT

PUBLIC ??_C@_0M@LACCCNMM@hello?5world?$AA@ ; `string’

; File c:documents and settingssdesaimy documentsvisual studio projects est est.cpp

??_C@_0M@LACCCNMM@hello?5world?$AA@ DB ‘hello world’, 00H ; `string’

; Function compile flags: /Odt /ZI

_argc$ = 8 ; size = 4

_argv$ = 12 ; size = 4

_main PROC NEAR ; COMDAT

sub esp, 64 ; 00000040H

push OFFSET FLAT. _C@_0M@LACCCNMM@hello?5world?$AA@

thanks in advance for your help

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

finally got the .asm file working. phew.

I went in to project>properties>c/c++>code generation . and set the basic runtime checks field as default. This took care of the _RTC errors.

Источник

This says no active RAS connection when there is an internet connection via dial up ??

; Hang_Up.asm Sever POT connection huntingspace,
;
include masm32includemasm32rt.inc
include MASM32includerasapi32.inc
includelib MASM32librasapi32.lib

 .data?

lpRasConn     dd ?
dwCb          dd ?
dwConnections dd ?

l_RASCONN RASCONN 0FFh dup ({})
l_Buffer_Size dd   ?
l_Conn_Count  dd   ?

.code

start:

xor eax,eax
mov dwCb,eax
mov dwConnections,eax
mov lpRasConn,eax

; Call RasEnumConnections with lpRasConn = NULL.
; dwCb is returned with the required buffer size and a return code of ERROR_BUFFER_TOO_SMALL

;invoke RasEnumConnections,lpRasConn, addr dwCb,addr dwConnections

invoke RasEnumConnections, addr l_RASCONN, addr l_Buffer_Size, addr l_Conn_Count

.if (eax== ERROR_BUFFER_TOO_SMALL)

; Allocate the memory needed for the array of RAS structure(s).

invoke GetProcessHeap
 mov edi,eax
 invoke HeapAlloc,edi,HEAP_ZERO_MEMORY,dwCb
 .if !(eax & eax)

 printf("HeapAlloc failed!",13,10)
;printf("RegOpenKeyEx %snn", LastError$())

jmp exit0
 .endif
 mov lpRasConn,eax

; The first RASCONN structure in the array must contain the RASCONN structure size

 mov esi,lpRasConn
 mov [esi].RASCONN.dwSize,sizeof RASCONN

; Call RasEnumConnections to enumerate active connections

 invoke RasEnumConnections,esi,addr dwCb,addr dwConnections

; If successful, print the names of the active connections.

 .if !(eax & eax)

  printf("The following RAS connections are currently active:",13,10)
   xor ebx,ebx
     .repeat
       lea eax,[esi].RASCONN.szEntryName
       ;printf("%s",13,10),eax
       printf("%sn",eax)
       add esi,sizeof RASCONN
       inc ebx
     .until (ebx>=dwConnections)
  .endif

;Deallocate memory for the connection buffer

 invoke HeapFree,edi,0,lpRasConn
 jmp exit0

.endif

; There was either a problem with RAS or there are no connections to enumerate

.if(dwConnections >= 1)

 printf("The operation failed to acquire the buffer size.",13,10)

.else

printf("There are no active RAS connections.",13,10)

.endif

exit0:

; terminate the Remote Access Connection

invoke RasHangUp, l_RASCONN.hrasconn

invoke Sleep,1500 ; give the system enuf time to end the connection
                  ; Don't want to leave the port in an inconsistent state.

invoke ExitProcess,0

end start

 ;
 ; i think you need fill some params in your sample before RasEnumConnections API is called:
 ; CODE
 ;
 ; mov l_RASCONN.RASCONN.dwSize, sizeof RASCONN
 ; mov l_Buffer_Size, sizeof l_RASCONN

  • Remove From My Forums
  • Question

  • hello expert,

    I have an existing .asm code file in 32 bit, now I need to support for x64, but I get a lot of error when compile with ml64.exe in visual studio:

    error A2070: invalid instruction operands
     error A2008: syntax error : VirtualProtect
     error A2070: invalid instruction operands
     fatal error A1010: unmatched block nesting : unlockAddress

    Could you advise me what I should do? There is no error when compile in x86.

    Regards.

Answers

  • «Since I am not good in Assembly, could you please advise me the easy way to port this asm file to support x64?»

    I’m not sure what advice can I give you apart from «well, you need to learn x86 and x64 assembly». Depending on the complexity of the existing code this might somewhat easy or quite complex.

    For example I noticed that you seem to have a function named «getStackFrame». Such a function not only needs to be converted to x64 assembly but it also needs to be updated to take into account differences in stack frame handling between win32 and win64.

    • Marked as answer by

      Thursday, May 3, 2012 3:05 AM

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

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

  • Error a2006 undefined symbol messagebox
  • Error a2006 undefined symbol dgroup
  • Error a2005 symbol redefinition
  • Error a2004 symbol type conflict
  • Error a12 warning

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

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