News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

masm32 assembler linker error

Started by computerbum, February 21, 2011, 07:12:30 PM

Previous topic - Next topic

computerbum

Hello everyone!

I am new to masm32 programming so please go easy on me.

Anyways I am trying to run the program below. This program came from the book 80x86 Assembly language and computer architecture.

First off, I opened the qeditor then opened the project example.asm, then navigated to project assemble. After running assemble this works fine but when I rung link OBJ file it fails and I get this error:

Quote

"C:\Users\Robert\Desktop\masm32\example"
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: C:\Users\Robert\Desktop\masm32\example.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

example.obj : error LNK2001: unresolved external symbol itoaproc
example.obj : error LNK2001: unresolved external symbol atoiproc
example.obj : error LNK2001: unresolved external symbol dtoaproc
example.obj : error LNK2001: unresolved external symbol atodproc
example.obj : error LNK2001: unresolved external symbol inproc
example.obj : error LNK2001: unresolved external symbol outproc
example.obj : error LNK2001: unresolved external symbol _ExitProcess@4
LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
example.exe : fatal error LNK1120: 8 unresolved externals
_
Link error
Press any key to continue . . .





; Example assembly language program -- adds two numbers
; Author:  R. Detmer
; Date:    revised 7/97

.386
.MODEL FLAT

ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

INCLUDE io.h            ; header file for input/output

cr      EQU     0dh     ; carriage return character
Lf      EQU     0ah     ; line feed

.STACK  4096            ; reserve 4096-byte stack

.DATA                   ; reserve storage for data
number1 DWORD   ?
number2 DWORD   ?
prompt1 BYTE    "Enter first number:  ", 0
prompt2 BYTE    "Enter second number:  ", 0
string  BYTE    40 DUP (?)
label1  BYTE    cr, Lf, "The sum is "
sum     BYTE    11 DUP (?)
        BYTE    cr, Lf, 0

.CODE                           ; start of main program code
_start:
        output  prompt1         ; prompt for first number
        input   string, 40      ; read ASCII characters
        atod    string          ; convert to integer
        mov     number1, eax    ; store in memory

        output  prompt2         ; repeat for second number
        input   string, 40
        atod    string
        mov     number2, eax
       
        mov     eax, number1    ; first number to EAX
        add     eax, number2    ; add second number
        dtoa    sum, eax        ; convert to ASCII characters
        output  label1          ; output label and sum

        INVOKE  ExitProcess, 0  ; exit with return code 0

PUBLIC _start                   ; make entry point public

END                             ; end of source code






"C:\Users\Robert\Desktop\masm32\example"
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: C:\Users\Robert\Desktop\masm32\example.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

example.obj : error LNK2001: unresolved external symbol itoaproc
example.obj : error LNK2001: unresolved external symbol atoiproc
example.obj : error LNK2001: unresolved external symbol dtoaproc
example.obj : error LNK2001: unresolved external symbol atodproc
example.obj : error LNK2001: unresolved external symbol inproc
example.obj : error LNK2001: unresolved external symbol outproc
example.obj : error LNK2001: unresolved external symbol _ExitProcess@4
LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
example.exe : fatal error LNK1120: 8 unresolved externals
_
Link error
Press any key to continue . . .

dedndave

you need to include windows.inc, as well as - it looks like msvcrt.inc and lib
doesn't Detmer cover that stuff ?

welcome to the forum   :U

another issue you are going to have....
the masm32 package includes a set of libraries and macros
it is designed to be installed in the root directory of the drive on which you plan to assemble
this mechanism is not compatible with Detmer, Irvine, or other libraries

computerbum

it does not cover that it's actually making me assemble and link the program manually through the command line.

Let me see if that works

by the way, is that a mandlebrot set equation I see at the bottom of your page?

dedndave

yes - surprisingly, few seem to recognize it

if you take some of the function names from the Detmer library and use them as search terms,
you will probably find several examples where the library has been used in the past

dedndave

ok - i found an example on one of my old drives
it appears that Detmer is somewhat compatible with masm32
still, you will want to install the masm32 folder on the root
i can't think of any reason why you couldn't just drag it there and fix the PATH variable to point to it

the program i have starts with
        INCLUDE \masm32\include\masm32rt.inc
        INCLUDE DetmerIO.inc

which - i think i renamed io.inc to DetmerIO.inc

computerbum

Thanks for your help

I thought that's what that was, it's been a while since I played with the mandlebrot set. Love it!


Anyways, looking forward to learning masm, I am hoping to learn more about assembly and find some good tutorials, do you know a few good ones by any chance?


dedndave

to be honest.....
scrap Detmer and his book - lol
not that he is a bad guy or a bad author
but, his library will cause trouble for you, because his book is the only place it's used
this is also true with Kip Irvine's stuff - another fine author
actually - no library at all is the way to learn - it's just harder

i would suggest you get with Randall Hyde's old html form of AoA for some basics...
http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/toc.html
the first few chapters are important basics - and chapter 6 has the instruction set

for GUI apps, Iczelion's tutorial will get you started
the link is somewhere in the stuff in the upper right-hand corner of the forum
also in there someplace - the Intel manuals
Iczelion's tutorials are a bit out of date, but still usable

for FPU stuff - Ray has a tutorial in the masm32\tutorials folder

also - the masm32\examples and masm32\help folders have a lot of good material

computerbum

Hey thanks alot, hope to hear more from you in the future!