简体   繁体   中英

How can I include several source files in x86 assembly using Visual Studio 2022?

Here are the simplified versions of my two files:

macros.asm:

INCLUDE Irvine32.inc

mSampleMacro MACRO prompt_address
    MOV     EDX, prompt_address
    CALL    WriteString
ENDM

END

main.asm:

INCLUDE macros.asm

.data
titleMsg        BYTE "              TITLE",0
instructions    BYTE "Insert instructions.",0

.code
main PROC
    
    PUSH    OFFSET titleMsg
    PUSH    OFFSET instructions
    CALL    DisplayTitleAndInstructions
    Invoke ExitProcess,0
main ENDP

DisplayTitleAndInstructions PROC
    PUSH    EBP
    MOV     EBP, ESP

    MOV     EDX, [EBP + 12]     ; title
    CALL    WriteString
    CALL    Crlf
    CALL    Crlf
    MOV     EDX, [EBP + 8]      ; instructions
    CALL    WriteString
    CALL    Crlf
    CALL    Crlf

    POP     EBP
    RET     12
DisplayTitleAndInstructions ENDP

I get the errors when building:

LNK2001 unresolved external symbol _mainCRTStartup  Project Z:\project\LINK
LNK1120 1 unresolved externals  Project D:\autodelete_noav\Debug\Project.exe

What I've tried: I have changed the entry point in the Project properties to main, but I get the same error with _main instead of _mainCRTStartup. When I change the main proc to be named _main I still get this error. I have tried changing include paths, including/excluding END in macros.asm, switching the System type of the linker to Windows/Console/Native (all give a similar error), etc.

I'm unsure whether it's something in the files themselves or in the way I'm configuring everything in Visual Studio.

Thanks in advance to anyone willing to help.

Thanks to Michael Petch, renaming macros.asm to macros.inc and removing the END statement fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM