News:

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

Link error

Started by tinkywinky, September 23, 2005, 12:58:08 PM

Previous topic - Next topic

tinkywinky

Hi, I'm here again, haha
I borrowed a book from the library called "Assembly Language for Intel-based Computers"
by KIP R. Irvine
I tried a simple code from the book

TITLE Add and Substract
include \masm32\include\irvine32.inc
.code
main PROC

    mov eax,10000h
    add eax,40000h
    sub eax,20000h
    call DumpRegs

    exit
main ENDP
END start


the weird thing is that after I assembled it
it appeared LINK error

addsub.obj : error LNK2001: unresolved external symbol _ExitProcess@4
addsub.obj : error LNK2001: unresolved external symbol _DumpRegs@0
addsub.exe : fatal error LNK1120: 2 unresolved externals


I think the book cannot be wrong
so there maybe something I did wrong? ::)
thanks

AeroASM

Did you forget something like:

includelib \masm32\lib\irvine32.lib

?

tinkywinky

no I don't think so
else the error code would have been "cannot find the file"
but thanks anyway :8)

P1

There is a Lib file missing !!!

If you use MASM32, AeroASM is right.  Make sure you copied the Lib file to the right location.

Otherwise you use the build/make file from the book and it will put the location of the Lib file on the command line of Link.

Either do it all the way from the book or properly convert the code for MASM32 usage.

Regards,  P1  :8)

MichaelW

I think your attempt to combine the Irvine libraries and include files with the MASM32 libraries and include files is making the project unnecessarily difficult. I think it would be easier to place the source and all of the Irvine components in a separate directory and assemble and link with a batch file. If the batch file were named MAKEIT.BAT then you could do everything from within QE, including running the EXE or disassembling it (using Run makeit.bat and Run Program from the Project menu, or Dis-assemble EXE file from the Tools menu).

Here is a listing for a directory that I used to do this (to answer a question on this or the old forum, IIRC).
Directory of C:\masm32\My\Irvine32

05/13/2005  03:36a      <DIR>          .
05/13/2005  03:36a      <DIR>          ..
05/13/2005  12:28p                 911 concat.asm
05/04/2005  11:51p               2,613 irvine32.inc
05/04/2005  11:51p              29,780 irvine32.lib
09/23/2005  02:44p                 136 MAKEIT.BAT
05/13/2005  03:45a              13,204 SmallWin.inc
09/23/2005  02:44p                 841 concat.obj
09/23/2005  02:44p               7,168 concat.exe

And the source file (modified from the poster's source, IIRC):

TITLE Concact                    (Concact.asm)

INCLUDE Irvine32.inc

Str_concat PROTO,
source1:PTR BYTE, ; source string
source2:PTR BYTE, ; target string
target:PTR BYTE,
maxChars:DWORD

Str_length PROTO,
pString:PTR BYTE ; pointer to string

.data
VAL1 BYTE "ABCDE",0
VAL2 BYTE "FGHIJ",0
CONCAT BYTE (sizeof VAL1 + sizeof VAL2) dup(?)

.code
main PROC

call Clrscr

INVOKE Str_concat,
ADDR val1,
ADDR val2,
ADDR concat,
(sizeof VAL1 + sizeof VAL2)

mov edx, OFFSET concat
call writestring

      call ReadChar

exit
main ENDP

Str_concat PROC USES eax ecx esi edi,
source1:PTR BYTE,
source2:PTR BYTE,
target:PTR BYTE,
maxChars:DWORD

mov ecx,maxChars
mov esi,source1
mov edi,target
cld
rep movsb

;mov ecx,maxChars
;mov esi,source2
mov edi,target + (lengthof VAL1)
;cld
;rep movsb

ret
Str_concat ENDP

END main

And the contents of MAKEIT.BAT (note that the directory is assumed to be on the same drive as MASM32):

\masm32\bin\ml /c /coff concat.asm
pause
\masm32\bin\Link concat.obj irvine32.lib \masm32\lib\kernel32.lib /SUBSYSTEM:CONSOLE
pause


eschew obfuscation