Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

[RESOLVED] Assembler within Visual Studio

2kaud

New member
Joined
May 7, 2014
Messages
654
I'm trying to use assembler from within Visual Studio 2017 by assembling an .asm file (no c/c++ anywhere!). I last used intel assembler over 20 years ago for ms-dos when you had segments and offsets etc. For the flat memory model for windows console it's all changed and I'm trying to get my head around this and I can't find any useful internet resource re VS and assembler. My test code is

Code:
.386
.MODEL flat, stdcall

STD_OUTPUT_HANDLE EQU -11

GetStdHandle PROTO NEAR32 stdcall,
    nStdHandle:DWORD

WriteFile PROTO NEAR32 stdcall,
    hFile:DWORD, lpBuffer:NEAR32, nNumberOfBytesToWrite:DWORD,
    lpNumberOfBytesWritten:NEAR32, lpOverlapped:NEAR32

ExitProcess PROTO NEAR32 stdcall,
    dwExitCode:DWORD

.STACK 4096

.DATA

msg DB "Hello, world.", 13, 10
written DW 0
hStdOut DD 0

.CODE
_start:
    INVOKE  GetStdHandle,
        STD_OUTPUT_HANDLE      ; Standard output handle
    mov hStdOut, eax

    INVOKE  WriteFile,
        hStdOut,               ; File handle for screen
        NEAR32 PTR msg,        ; Address of string
        LENGTHOF msg,          ; Length of string
        NEAR32 PTR written,    ; Bytes written
        0                      ; Overlapped mode

    INVOKE  ExitProcess,
        0                      ; Result code for parent process

end _start

and when I try to build this in VS2017 I get the linker errors

Code:
testasm.obj : error LNK2001: unresolved external symbol _GETSTDHANDLE@4
testasm.obj : error LNK2001: unresolved external symbol _WRITEFILE@20
testasm.obj : error LNK2001: unresolved external symbol _EXITPROCESS@4

Obviously there is a problem with linking somewhere. Would any kind guru advise as how I can get this program to assemble and build in VS.
 

2kaud

New member
Joined
May 7, 2014
Messages
654
Re: Assembler within Visual Studio

OK, solved it. Within the project properties/Microsoft Macro Assembler/General there is an option Preserve Identifier Case. The default is to Map All To Upper Case. Doh!! This property needs to be set to Preserve Identifier Case. The code then compiles/links OK and the .exe runs and displays as expected.
 
Top