Results 1 to 2 of 2

Thread: [RESOLVED] Assembler within Visual Studio

  1. #1

    Thread Starter
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Resolved [RESOLVED] Assembler within Visual Studio

    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.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  2. #2

    Thread Starter
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    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.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width