Error a2008 syntax error addr

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

Содержание

  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.

Источник

I literally started learning MASM32 yesterday so bear with me if this is a dumb question.

My understanding of addr and offset is as follows: both return the memory address of a variable but offset only works on global variables (whose memory addresses are know at assemble time) and addr will work on both global and local variables. I know what global and local variables are in higher level languages; my understanding is that variables declared in the .data, .data?, and .const blocks are global and that variable declared with the local keyword inside of procedures are local.

My entire code is:

.386
.model flat, stdcall
option casemap:none

include masm32includewindows.inc
include masm32includeuser32.inc
includelib masm32libuser32.lib
include masm32includekernel32.inc
includelib masm32libkernel32.lib

.data

szCap db "Hello", 0                   ;caption for the MessageBox
szMsg db "Hello, world!", 0           ;text for the MessageBox

.code

;Procedure for creating a MessaheBox with NULL parent and variable text
TestProcedure proc msg:dword, cap:dword     
    invoke MessageBox, NULL, msg, cap, MB_OK
    ret
TestProcedure endp

main:
    ; error on these lines
    push addr szCap ; C:masm32My filesHelloWorld.asm(35) : error A2008: syntax error : addr
    push addr szMsg ; C:masm32My filesHelloWorld.asm(36) : error A2008: syntax error : addr

    call TestProcedure

    invoke ExitProcess, 0
end main

However, if I change addr to offset, the code works perfectly. Why does addr fail to assemble in this instance?

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

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

  • 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 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии